本人使用`maven`来管理`jfinal`的依赖加入了一下包:
<dependency> <groupId>com.jfinal</groupId> <artifactId>jfinal</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>com.jfinal</groupId> <artifactId>jetty-server</artifactId> <version>8.1.8</version> </dependency> <dependency> <groupId>com.jfinal</groupId> <artifactId>jfinal-ext</artifactId> <version>3.1.4</version> </dependency> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.5.1</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.20</version> </dependency>
其他的为默认。Deployment里面的参数如下:
/src/main/java WEB-INF/classes /src/main/webapp / /src/main/webapp WEB-INF/classes /src/test/java WEB-INF/classes
在已经设置好的Controller里设置render
@ActionKey("/test") public void test(){ render("/test.jsp"); }
Starting JFinal 2.1 Starting scanner at interval of 5 seconds. Starting web server on port: 8080 /home/innerac/workspace/jfianlm/src/main/webapp 一月 17, 2016 6:16:33 下午 com.mchange.v2.log.MLog 信息: MLog clients using java 1.4+ standard logging. 一月 17, 2016 6:16:34 下午 com.mchange.v2.c3p0.C3P0Registry 信息: Initializing c3p0-0.9.5.1 [built 16-June-2015 00:06:36 -0700; debug? true; trace: 10] 一月 17, 2016 6:16:34 下午 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource 信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> z8kfsx9elxyyg31nac9a8|6e06451e, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> z8kfsx9elxyyg31nac9a8|6e06451e, idleConnectionTestPeriod -> 0, initialPoolSize -> 10, jdbcUrl -> jdbc:mysql://127.0.0.1/swjsysq, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 20, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ] Starting Complete. Welcome To The JFinal World :) /home/innerac/workspace/jfianlm/target/classes/edu/innerac/jfianlm/controller 一月 17, 2016 6:16:42 下午 com.jfinal.core.ActionHandler error 严重: /test java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.jfinal.aop.Invocation.invoke(Invocation.java:87) at com.jfinal.core.ActionHandler.handle(ActionHandler.java:82) at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:365) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.jfinal.aop.Invocation.invoke(Invocation.java:73) ... 25 more Caused by: java.lang.NoClassDefFoundError: javax/el/ELResolver at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at com.jfinal.render.JspRender.<clinit>(JspRender.java:41) at com.jfinal.render.RenderFactory$JspRenderFactory.getRender(RenderFactory.java:294) at com.jfinal.render.RenderFactory.getRender(RenderFactory.java:170) at com.jfinal.core.Controller.render(Controller.java:965) at edu.innerac.jfianlm.controller.InneracController.test(InneracController.java:42) ... 30 more Caused by: java.lang.ClassNotFoundException: javax.el.ELResolver at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 47 more
String webRoot = PathKit.getWebRootPath(); System.out.println(webRoot);
/home/innerac/workspace/jfianlm/src/main/webapp
求解答啊?
注意看这个异常信息:<spanstyle="font-family:Consolas,'BitstreamVeraSansMono','CourierNew',Courier,monospace;font-size:14px;line-height:15.3999996185303px;background-color:#FFFFFF;">Causedby:java.lang.NoClassDefFoundError:javax/el/ELResolver,证明是缺少jar包,在jfinal官网下载jfinal-2.1-all.zip这个文件,里面有个lib目录,其中有一个jar使用说明文件,打开这个文件,找到jsp、jstl所需要的相关jar包,放入即可。您好,能不能看一下下面的那个回答,请问有什么好的解决办法好的,谢谢我去试一试,主要是和我以前用非maven方式加入的包一样,可是这里出错了。再次感谢
发现了原因所在,在官网下载的jar包里面内容是这样的:
<imgsrc="http://static.oschina.net/uploads/space/2016/0118/113939_apQm_2614586.png"alt="">
而通过maven仓库下载下来的包是这样的
<imgsrc="http://static.oschina.net/uploads/space/2016/0118/114039_AF9p_2614586.png"alt="">
包里面的内容不太一样,所以找不到类了
java.lang.NoClassDefFoundError:javax/el/ELResolver<spanstyle="line-height:1.5;font-size:10pt;">
我将.m2下的jetty-server-8.1.8.jar这个依赖包换成官网下载的依赖包就可以用了。回复<aclass='referer'target='_blank'>@车开源:我的是这样的src/main/webapp8080/5应该是默认输出路径回复<aclass='referer'target='_blank'>@车开源:我的是这样的javax.servlet.ServletContext.getJspConfigDescriptor()Ljavax/servlet/descriptor/JspConfigDescriptor;最近我也闲得蛋痛,在折腾Maven,把原来的JFinal项目迁移到Maven下之后依赖包应该全了,应用也启动正常,就是访问出错。请教下:JFinal.start("xxxxxxxx",8090,"/web",5);这里的xxxx路径是指向哪个目录?版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。