[Solved] Warning: Servlet threw load() exception java.lang.ClassNotFoundException: org.glassfish.jersey.servlet…

I need to use Jersey to rewrite the previous environment SSH Jersey version 1.19 these days

Use this

<servlet>
        <servlet-name>Way REST Service</servlet-name>  
         <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>  
          <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>  
            <param-value>com.bzt.jersey.resources</param-value>  
           </init-param>
       <load-on-startup>3</load-on-startup>  
     </servlet>
     <servlet-mapping>
       <servlet-name>Way REST Service</servlet-name>  
       <url-pattern>/rest/*</url-pattern>  
     </servlet-mapping>

error

Warning: Servlet threw load() exception
java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1143)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

 

Solution:

So it was changed to a com start

<servlet>
        <servlet-name>Way REST Service</servlet-name>  
         <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>  
          <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>  
            <param-value>com.bzt.jersey.resources</param-value>  
           </init-param>
       <load-on-startup>3</load-on-startup>  
     </servlet>
     <servlet-mapping>
       <servlet-name>Way REST Service</servlet-name>  
       <url-pattern>/rest/*</url-pattern>  
     </servlet-mapping>

Similar Posts: