我在tomcat服务器上部署JAVA Jersy2.0 Async Restful Web服务时遇到问题。
当我在我的电脑上使用tomcat 7.0.41.0在本地运行此应用程序时工作正常。 但是当我使用tomcat 7.0.42在我的服务器上部署此服务时,它给出了错误。 请看下面的错误。
输入例外报告
用于servlet helloworld.ApplicationConfig的消息Servlet.init()抛出异常
说明服务器遇到内部错误,导致无法完成此请求。
例外
javax.servlet.ServletException:servlet helloworld.ApplicationConfig的Servlet.init()抛出异常 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run(AprEndpoint.java:1852) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:603) java.lang.Thread.run(Thread.java:722)
根本原因
org.glassfish.jersey.internal.ServiceConfigurationError:javax.ws.rs.ext.MessageBodyReader:实现提供程序接口javax.ws.rs的类com.sun.jersey.atom.abdera.impl.provider.entity.EntryProvider .ext.MessageBodyReader无法实例化:无法将com.sun.jersey.atom.abdera.impl.provider.entity.EntryProvider强制转换为javax.ws.rs.ext.MessageBodyReader org.glassfish.jersey.internal.ServiceFinder.fail(ServiceFinder.java:397) org.glassfish.jersey.internal.ServiceFinder.access $ 700(ServiceFinder.java:153) org.glassfish.jersey.internal.ServiceFinder $ LazyObjectIterator.hasNext(ServiceFinder.java:711) org.glassfish.jersey.internal.ServiceFinderBinder.configure(ServiceFinderBinder.java:68) org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:169) org.glassfish.hk2.utilities.binding.AbstractBinder.install(AbstractBinder.java:313) org.glassfish.jersey.message.internal.MessagingBinders $ MessageBodyProviders.configure(MessagingBinders.java:110) org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:169) org.glassfish.hk2.utilities.binding.AbstractBinder.install(AbstractBinder.java:313) org.glassfish.jersey.server.ServerBinder.configure(ServerBinder.java:109) org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:169) org.glassfish.jersey.internal.inject.Injections.bind(Injections.java:157) org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:147) org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:137) org.glassfish.jersey.server.ApplicationHandler。(ApplicationHandler.java:265) org.glassfish.jersey.servlet.WebComponent。(WebComponent.java:262) org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167) org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349) javax.servlet.GenericServlet.init(GenericServlet.java:160) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run(AprEndpoint.java:1852) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:603) java.lang.Thread.run(Thread.java:722)
根本原因
java.lang.ClassCastException:无法将com.sun.jersey.atom.abdera.impl.provider.entity.EntryProvider强制转换为javax.ws.rs.ext.MessageBodyReader java.lang.Class.cast(Class.java:3005) org.glassfish.jersey.internal.ServiceFinder $ LazyObjectIterator.hasNext(ServiceFinder.java:654) org.glassfish.jersey.internal.ServiceFinderBinder.configure(ServiceFinderBinder.java:68) org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:169) org.glassfish.hk2.utilities.binding.AbstractBinder.install(AbstractBinder.java:313) org.glassfish.jersey.message.internal.MessagingBinders $ MessageBodyProviders.configure(MessagingBinders.java:110) org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:169) org.glassfish.hk2.utilities.binding.AbstractBinder.install(AbstractBinder.java:313) org.glassfish.jersey.server.ServerBinder.configure(ServerBinder.java:109) org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:169) org.glassfish.jersey.internal.inject.Injections.bind(Injections.java:157) org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:147) org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:137) org.glassfish.jersey.server.ApplicationHandler。(ApplicationHandler.java:265) org.glassfish.jersey.servlet.WebComponent。(WebComponent.java:262) org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167) org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349) javax.servlet.GenericServlet.init(GenericServlet.java:160) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589) org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run(AprEndpoint.java:1852) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:603) java.lang.Thread.run(Thread.java:722)