0

我正在构建一个 Web 应用程序。当我在 Tomcat 上运行它时,一切正常。但如果我使用 Glassfish,我会收到 NoClassDefFoundError 异常。这是为什么?它抛出异常的类是由 Maven 导入的,正如我所说,Tomcat 在运行应用程序和查找类时没有任何问题。为什么 Glassfish 有问题?

我得到的堆栈跟踪:

java.lang.NoClassDefFoundError: org/openrdf/rio/RDFHandlerException    



at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)    

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)    

at java.lang.reflect.Method.invoke(Method.java:597)    

at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)    

at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)    

at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)    

at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)    

at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)    

at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)    

at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)    

at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)    

at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)    

at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)    

at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)    

at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)    

at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)    

at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)    

at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)    

at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)    

at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)    

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)    

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)    

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)    

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)    

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)    

at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)    

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)    

at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)    

at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)    

at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)    

at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)    

at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)    

at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)    

at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)    

at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)    

at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)    

at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)    

at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)    

at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)    

at com.sun.grizzly.ContextTask.run(ContextTask.java:71)    

at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)    

at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)    

at java.lang.Thread.run(Thread.java:662)    

Caused by: java.lang.ClassNotFoundException: org.openrdf.rio.RDFHandlerException    

at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)    

at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)    

... 45 more

java.lang.ClassNotFoundException: org.openrdf.rio.RDFHandlerException
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
    at pl.psnc.synat.web.Service.runMapping(Service.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
4

2 回答 2

0

好像您正在使用openrdf。请确保您在运行时类路径中添加了sesame和相关 jar。为了让事情更清楚,在您的服务器启动脚本中添加一个回显以在启动期间显示 CLASSPATH(用于调试)

于 2012-09-03T08:44:14.063 回答
0
java.lang.NoClassDefFoundError: org/openrdf/rio/RDFHandlerException    

在glassfish服务器中部署war后似乎缺少一些jar文件。部署war后请检查您的WEB-INF/LIB文件夹是否正确包含所有jar文件?

于 2012-09-03T09:47:41.890 回答