users@jersey.java.net

[Jersey] Re: ServletException , need help

From: Michal Gajdos <michal.gajdos_at_oracle.com>
Date: Wed, 23 Jul 2014 08:16:22 +0200

Hi Denghui,

based on your web.xml and the provided stack-trace I’d say that you have both Jersey 1 and Jersey 2 (incl. JAX-RS 1.1 and JAX-RS 2.0 APIs) on your class-path which is causing you troubles. Remove Jersey 1 bits from your application and update web.xml accordingly (see [1]) to make sure your app only uses Jersey 2.

[1] http://blog.dejavu.sk/2013/11/19/registering-resources-and-providers-in-jersey-2/

Michal

> On 22 Jul, 2014, at 17:37 , huangdenghui <denghui.huang_at_outlook.com> wrote:
>
> 七月 22, 2014 6:59:13 下午 org.apache.coyote.AbstractProtocol init
> INFO: Initializing ProtocolHandler ["http-bio-8080"]
> 七月 22, 2014 6:59:13 下午 org.apache.catalina.mbeans.GlobalResourcesLifecycleLi
> stener createMBeans
> SEVERE: No global naming context defined for server
> 七月 22, 2014 6:59:13 下午 org.apache.catalina.core.StandardService startInterna
> l
> INFO: Starting service Catalina
> 七月 22, 2014 6:59:13 下午 org.apache.catalina.core.StandardEngine startInternal
>
> INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
> 七月 22, 2014 6:59:13 下午 org.apache.coyote.AbstractProtocol start
> INFO: Starting ProtocolHandler ["http-bio-8080"]
> 七月 22, 2014 6:59:17 下午 org.apache.catalina.core.StandardContext loadOnStartu
> p
> SEVERE: Servlet /controller/nb/cluster threw load() exception
> javax.servlet.ServletException: Resource configuration class com.testorg.sdnc.nor
> thbound.commons.NorthboundApplication is not a subclass of class javax.ws.rs.cor
> e.Application.
> at org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebCom
> ponent.java:461)
> at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:30
> 1)
> at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.j
> ava:170)
> at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.j
> ava:358)
> at javax.servlet.GenericServlet.init(GenericServlet.java:244)
> at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.
> java:1284)
> at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
> java:1197)
> at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:10
> 87)
> at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
> t.java:5210)
> at org.apache.catalina.core.StandardContext.startInternal(StandardContex
> t.java:5493)
> at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
> .java:901)
> at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87
> 7)
> at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
>
> at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWe
> bApplication(TomcatServletContainer.java:125)
> at org.eclipse.gemini.web.internal.StandardWebApplication.start(Standard
> WebApplication.java:109)
> at org.eclipse.gemini.web.extender.WebContainerBundleCustomizer.addingBu
> ndle(WebContainerBundleCustomizer.java:49)
> at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTr
> acker.java:467)
> at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTr
> acker.java:414)
> at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.jav
> a:256)
> at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
>
> at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTrack
> er.java:443)
> at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerC
> allback(EventDispatcher.java:868)
> at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(
> EventDispatcher.java:789)
> at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(Event
> Dispatcher.java:514)
> at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4403)
> at org.apache.felix.framework.Felix.startBundle(Felix.java:2092)
> at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1291)
>
> at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStart
> LevelImpl.java:304)
> at java.lang.Thread.run(Unknown Source)
>
> Above is my exception information, I have a custom application which implements Javax.ws.rs.core.application and deployed with web.xml
>
> Web.xml as the following
> 1 <web-app>
> 2 <servlet> 3
> <servlet-name>Jersey Web Application</servlet-name> 4
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> 5
> <init-param> 6
> <param-name>javax.ws.rs.Application</param-name> 7
> <param-value>com.testorg.sdnc.nor
> thbound.commons.NorthboundApplication </param-value> 8
> </init-param> 9
> ... 10 </servlet> 11 ...
> 12 </web-app>
>
> I can not figure out why I run into this exception, any help is appreciate.
>
> --denghui
>
> 发自我的 iPad