在Eclipse IDE中使用JSP与Embedded Jetty 7,获取LogConfigurationException

时间:2010-10-29 15:05:16

标签: java exception jetty logging nullpointerexception

我已经包含了应用程序所需的所有jar,我正在尝试使用Jetty Embedded

我有一个简单的java类,其主要方法具有以下设置,servlet仍能正常工作,无法让JSP工作。包含所有必需的罐子,从基本的Jetty罐子开始,然后从jsp文件夹中添加所有罐子。

Server server = new Server(8080);

WebAppContext context = new WebAppContext();
context.setDescriptor("WebRoot/WEB-INF/web.xml");
context.setResourceBase("WebRoot/");
context.setContextPath("/");
context.setParentLoaderPriority(true);

server.setHandler(context);

server.start();
server.join();

错误:

2010-10-29 09:53:14.031:INFO::jetty-7.2.0.v20101020
2010-10-29 09:53:14.577:WARN::FAILED jsp: java.lang.ExceptionInInitializerError
2010-10-29 09:53:14.577:WARN::FAILED WebAppContext@1c0e45a@1c0e45a/,file:/D:/eclipseworkspaces/eone/dash/JettyEmbededWeb/WebRoot/: java.lang.ExceptionInInitializerError
2010-10-29 09:53:14.577:WARN::Error starting handlers
java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:602)
    at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:741)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:421)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:259)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:762)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:244)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1132)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:577)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:491)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)
    at org.eclipse.jetty.server.Server.doStart(Server.java:243)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at com.example.handlers.WebappCtxtHandlerNonWar.main(WebappCtxtHandlerNonWar.java:32)
Caused by: 
com.sun.org.apache.commons.logging.LogConfigurationException: com.sun.org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by com.sun.org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
    at com.sun.org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
    at org.apache.jasper.servlet.JspServlet.<clinit>(JspServlet.java:116)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:602)
    at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:741)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:421)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:259)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:762)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:244)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1132)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:577)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:491)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)
    at org.eclipse.jetty.server.Server.doStart(Server.java:243)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at com.example.handlers.WebappCtxtHandlerNonWar.main(WebappCtxtHandlerNonWar.java:32)
Caused by: 
com.sun.org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
    at com.sun.org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
    at org.apache.jasper.servlet.JspServlet.<clinit>(JspServlet.java:116)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:602)
    at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:741)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:421)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:259)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:762)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:244)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1132)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:577)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:491)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)
    at org.eclipse.jetty.server.Server.doStart(Server.java:243)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at com.example.handlers.WebappCtxtHandlerNonWar.main(WebappCtxtHandlerNonWar.java:32)
Caused by: 
java.lang.NullPointerException
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
    at com.sun.org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
    at com.sun.org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
    at org.apache.jasper.servlet.JspServlet.<clinit>(JspServlet.java:116)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:602)
    at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:741)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:421)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:259)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:762)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:244)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1132)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:577)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:491)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)
    at org.eclipse.jetty.server.Server.doStart(Server.java:243)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
    at com.example.handlers.WebappCtxtHandlerNonWar.main(WebappCtxtHandlerNonWar.java:32)
2010-10-29 09:53:14.592:INFO::Started SelectChannelConnector@0.0.0.0:8080

2 个答案:

答案 0 :(得分:2)

我更喜欢将jetty-jsp工件与聚合的jetty-all-server一起使用,因为两者都可以从相同的Jetty版本中获得:

    <dependency>
        <groupId>org.eclipse.jetty.aggregate</groupId>
        <artifactId>jetty-all-server</artifactId>
        <version>${jetty.version}</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-jsp</artifactId>
        <version>${jetty.version}</version>
    </dependency>

我已经使用Jetty版本7.6.12.v20130726进行了测试,这两个依赖项都可以在Maven central repo上使用。

答案 1 :(得分:0)

很可能是一个缺课。

我基本上使用相同的代码片段在

的maven构建下工作
    <dependency>
        <groupId>org.eclipse.jetty.aggregate</groupId>
        <artifactId>jetty-all</artifactId>
        <version>7.2.0.v20101020</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jsp-2.1-glassfish</artifactId>
        <version>2.1.v20100127</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

和log4j。