Start Jersey application with Jetty - java

I install jetty 9 server in my Ubuntu server VCS. Structure of java rest project:
/opt/jetty/webapps/backend /
build
conf
lib
libs
logs
src/com/example/package/backend
resources
CategoryResource.java
BackendServer.java
web
WEB-INF
web.xml
BackendServer.java
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.jersey.api.core.PackagesResourceConfig;
import com.sun.net.httpserver.HttpServer;
public class BackendServer {
public static void main(String[] args) throws IOException {
HttpServer server = HttpServerFactory.create("http://localhost:" + "8080" + "/" + "backend/rest", new PackagesResourceConfig("com.droidbrew.androcommerce.backend.resources"));
DbManager.getInstance();
server.start();
System.out.println("Server running");
System.out.println("Hit return to stop...");
System.in.read();
System.out.println("Stopping server");
server.stop(0);
System.out.println("Server stopped");
}
}
CategoryResource.java
Path("/category")
public class CategoryResource {
#GET
#Path("/get_all_categories")
#Produces({MediaType.APPLICATION_JSON})
public String getAllCategories() throws SQLException {
List<Category> categoryList = DbManager.getInstance().getBackendCategoryManager().getAllCategories();
Gson gson = new Gson();
return gson.toJson(categoryList);
}
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Jersey</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey 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.droidbrew.androcommerce.backend.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
/opt/jetty/webapps/backend.xml
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="configurationClasses">
<Array type="java.lang.String">
<Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
<Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
<Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
</Array>
</Set>
<Set name="contextPath">/</Set>
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webapps/backend</Set>
<New id="development" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/development</Arg>
<Arg>
<New class="org.postgresql.ds.PGConnectionPoolDataSource">
<Set name="User">user</Set>
<Set name="Password">1111</Set>
<Set name="DatabaseName">development</Set>
<Set name="ServerName">localhost</Set>
<Set name="PortNumber">5432</Set>
</New>
</Arg>
</New>
</Configure>
But after I start service jetty start and try connect ip:8085/backend/rest/category/get_all_categories I get:
HTTP ERROR: 404
Problem accessing /backend/rest/category/get_all_categories. Reason:
Not Found
UPDATE
Logs after java -DDEBUG -jar start.jar
sudo java -DDEBUG -jar start.jar
System Property [DEBUG] has been deprecated! (Use org.eclipse.jetty.LEVEL=DEBUG instead)
2014-10-06 13:09:09.522:INFO::main: Logging initialized #1090ms
ShutdownMonitor not in use (port < 0): -1
2014-10-06 13:09:10.047:INFO:oejs.Server:main: jetty-9.2.3.v20140905
2014-10-06 13:09:10.073:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/opt/jetty/webapps/] at interval 1
2014-10-06 13:09:10.096:WARN:oejd.DeploymentManager:main: Unable to reach node goal: started
java.lang.ClassNotFoundException: org.mortbay.jetty.webapp.WebAppContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.nodeClass(XmlConfiguration.java:364)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:304)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:262)
at org.eclipse.jetty.deploy.providers.WebAppProvider.createContextHandler(WebAppProvider.java:291)
at org.eclipse.jetty.deploy.App.getContextHandler(App.java:101)
at org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:36)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:560)
at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:387)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:354)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:310)
at org.eclipse.jetty.start.Main.start(Main.java:786)
at org.eclipse.jetty.start.Main.main(Main.java:111)
2014-10-06 13:09:10.111:WARN:oejuc.AbstractLifeCycle:main: FAILED ServerConnector#1d402894{HTTP/1.1}{0.0.0.0:8080}: java.net.BindException: Address already in use
java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:444)
at sun.nio.ch.Net.bind(Net.java:436)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:320)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:366)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:310)
at org.eclipse.jetty.start.Main.start(Main.java:786)
at org.eclipse.jetty.start.Main.main(Main.java:111)
2014-10-06 13:09:10.114:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.server.Server#5f281b8c: java.net.BindException: Address already in use
java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:444)
at sun.nio.ch.Net.bind(Net.java:436)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:320)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:366)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:310)
at org.eclipse.jetty.start.Main.start(Main.java:786)
at org.eclipse.jetty.start.Main.main(Main.java:111)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:310)
at org.eclipse.jetty.start.Main.start(Main.java:786)
at org.eclipse.jetty.start.Main.main(Main.java:111)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:444)
at sun.nio.ch.Net.bind(Net.java:436)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:320)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:366)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
... 7 more

Your XML files are referencing an old version of Jetty.
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
The org.mortbay.jetty namespace is for Jetty 6 or older versions of Jetty, (all of which have been EOLd for years now).
That entire XML document is wrong for Jetty 9, from the DOCTYPE, to the class references, even to the structure.
The <SystemProperty> element references a "jetty.home" variable that isn't used in jetty embedded (its only there for the jetty distribution, aka start.jar). The jetty-http-spi.jar doesn't even set or use this property.
The use of the Jetty Context XML Deployable is a feature that jetty-deploy.jar provides, however, that sort of deployable is not supported by the com.sun.net.httpserver.HttpServer concepts, either as a standalone deployable, or an internal WEB-INF/jetty-web.xml configuration.
That whole backend server war you are attempting to setup just cannot be on the com.sun.net.httpserver.HttpServer you started (not supported by that concept at a fundamental level)
Unfortunately, there is almost no troubleshooting available when you use the com.sun.net.httpserver.HttpServer techniques. Pretty much limited to logging output.
What does the logging output show?
Update: 2014, Oct 7:
About the logging output, lets see.
You are starting jetty via command line, using the Jetty 9.2.3 distribution.
That act is completely unrelated to your BackendServer use of com.sun.net.httpserver.HttpServer.
This would result in 2 different servers.
The standalone Jetty 9.2.3 distribution server
The com.sun.net.httpserver.HttpServer server
You have essentially 2 errors showing in those logs.
First is ...
java.lang.ClassNotFoundException: org.mortbay.jetty.webapp.WebAppContext
That's because you are using Jetty 6 techniques for Jetty 9. That class (actually package namespace) doesn't exist in Jetty 9.
That class (in Jetty 9) would be called org.eclipse.jetty.webapp.WebAppContext, see Configuring a Specific Web App Deployment in the Eclipse Jetty documentation website for details.
You will have to analyze and adjust most things in your example XML file to fit the realities of the nearly 200 releases since Jetty 6 and Jetty 9. Far too much time has elapsed between Jetty 6 and Jetty 9 to list what has changed. It would be equivalent to listing the differences between a Ford Model 18 and a Tesla Model S (it would be a huge list that would essentially mean 'everything' and be useless to work off of)
The other error ...
FAILED ServerConnector#1d402894{HTTP/1.1}{0.0.0.0:8080}:
java.net.BindException: Address already in use
means that this server cannot bind to port 8080, as some other server is already there.
This makes sense, as your BackendServer is also on port 8080 (per your example code).
Don't try to mix embedded-jetty and com.sun.net.httpserver.HttpServer, you will only tear your hair out trying to force com.sun.net.httpserver.HttpServer into doing what you want.
Consider using straight embedded-jetty + jersey servlet instead.
There's lots of examples of this technique online and in StackOverflow.
Here's the first one I found that had example code showing how to setup the ServletHolder for the jersey ServletContainer along with some relevant init parameters to configure it. Configuring Jersey + Jetty + JSP

Related

How to replace Jersey by Resteasy on a Jetty server?

I build a Java REST application that I want to deploy on a Jetty server.
I try to work with last versions of libraries (Java 8, Servlet 3.1, Jetty 9.4.7 and Resteasy 3.1.4).
I already make my server work with Jersey 2.26 but it has a limitation I hear that Resteasy does not have:
With Jersey I can't deploy if I define an interface with #Path annotation defined on the class because when I implement the interface the deployment failed due to a conflict about this non-unique resource. In other word to make it work I need to move the following commented annotation into the implementation :
//#Path("li")
public interface ILaptopInfo {
#Path("test/{test}")
#GET
public String test(#PathParam("test") String who);
}
I use Maven so I removed Jersey's dependencies and add Resteasy one's as documentation says:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-servlet-initializer</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
</dependency>
I does not change my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
metadata-complete="false"
version="3.1">
<servlet>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
But when I start my server I got a resteasy WARN and then a No class in holder javax.ws.rs.core.Application stacktrace. It makes me think it does not scan properly my project to find my resource or Resteasy stack does not properly start the scanning. Do you have an idea about that I could miss?
Below the stacktrace I got:
2017-10-26 14:12:33.519:INFO:oejs.Server:main: jetty-9.4.7.v20170914
2017-10-26 14:12:34.416:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=628ms
2017-10-26 14:12:34.432:WARN:oeja.WebServletAnnotation:main: org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher defines neither #WebServlet.value nor #WebServlet.urlPatterns
2017-10-26 14:12:34.770:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2017-10-26 14:12:34.770:INFO:oejs.session:main: No SessionScavenger set, using defaults
2017-10-26 14:12:34.770:INFO:oejs.session:main: Scavenging every 660000ms
2017-10-26 14:12:34.933:WARN:oejshC.ROOT:main: unavailable
javax.servlet.UnavailableException: No class in holder javax.ws.rs.core.Application#83f91b4==null,jsp=null,order=-1,inst=false
at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:86)
at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:362)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:759)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1514)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp(JettyWebAppContext.java:359)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1476)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:434)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
at org.eclipse.jetty.server.Server.start(Server.java:449)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:416)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:467)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:333)
at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:180)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
2017-10-26 14:12:34.971:WARN:oejshC.ROOT:main: unavailable
I had your same issue. Try this:
<servlet>
<servlet-name>Application</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.example.Application</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

Failed to register library Extension-Name jenkins error on weblogic server

I tried to a deployment with Jenkins. But I got an error in web logic server 12.1.3. I configured "plugin-configuration.xsd" file in Jenkins web logic plugin. Also I configured Web logic Deployment Plugin parameters in Jenkins web interface.
additional classpath: C:\Oracle\Middleware\Oracle_Home\wlserver\server\lib\wlthint3client.jar
Configuration file: myPath\.jenkins\plugins\weblogic-deployer-plugin\config\plugin-configuration.xsd
How can I solve this?
In addition, my config.xsd file is that;
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.jenkinsci.plugins/WeblogicDeploymentPlugin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://org.jenkinsci.plugins/WeblogicDeploymentPlugin plugin-configuration.xsd">
<weblogic-targets>
<weblogic-target>
<name>weblogic_local_server</name>
<host>127.0.0.1</host>
<port>7001</port>
<login>admin</login>
<password>admin</password>
<authMode>BY_LOGIN</authMode>
</weblogic-target>
</weblogic-targets>
</config>
The error is here:
<BEA-149205> <Failed to initialize the application "jenkins [,LibImplVersion=2.60.3]" due to error weblogic.application.library.LibraryDeploymentException: [J2EE:160144]Failed to register library Extension-Name: jenkins, Implementation-Version: 2.60.3: Library cannot have Implementation-Version set, without also specifying its Specification-Version
weblogic.application.library.LibraryDeploymentException: [J2EE:160144]Failed to register library Extension-Name: jenkins, Implementation-Version: 2.60.3: Library cannot have Implementation-Version set, without also specifying its Specification-Version
at weblogic.application.internal.library.LibraryDeployment.prepare(LibraryDeployment.java:66)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:155)
at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)
at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:191)
at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)
at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)
at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)
at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)
at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:210)
at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:118)
at weblogic.server.AbstractServerService.postConstruct(AbstractServerService.java:78)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1017)
at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:388)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:430)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225)
at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606)
at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:77)
at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:231)
at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:254)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:413)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225)
at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1162)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1147)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpOneLevel.run(CurrentTaskFuture.java:753)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
>
Problem is that; Wblogic Deployment Plugin additional classpath parameter was wrong. It must be "C:\Oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic.jar".
java -cp C:/Oracle/Middleware/Oracle_Home/wlserver/server/lib/weblogic.jar weblogic.Deployer -adminurl t3://localhost:7001 -username admin -password q1w2e3r4 -deploy -name sample -targets AdminServer -source C:\sample.war

Exception occurred starting up Jetty while using URLRewrite

I configured URLRewrite to my application. But when I tried to start up my Jetty server with Java code, an exception occurred as below:
2016-11-22 14:23:34.756:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/,file:/Users/xxx/Documents/Developer/myapp/src/main/webapp/}
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:332)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1210)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:610)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:453)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
at org.eclipse.jetty.server.Server.doStart(Server.java:262)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
But it worked when I deployed it to Tomcat server.
Anyone can help with this? Thank you in advance!
Finally I found that it's caused by the version of servlet-api, which is embedded in Jetty but not the one supports. So I upgraded Jetty to a newer one and changed the version of web.xml to 3.0. Then it works.
Hope this helps!

Hazelcast on Glassfish as an OSGI bundle

Good day. I have some difficulties using the Hazelcast in Glassfish OSGi environment.
I have an OSGi bundle, which provides some EJBs and intended to be deployed on glassfish. This bundle uses Hazelcast and imports some hazelcast packages. I don't want to embed hazelcast jar so I tried to deploy it in Glassfish prior to deploying the subj. bundle.
$ asadmin deploy --type=osgi minimal-json-0.9.1.jar
$ asadmin deploy --type=osgi hazelcast-3.3.3.jar
Hazelcast deployed successfully. But when I deploy my bundle, and when one of the EJBs from this bundle tries to create a HazelcastInstance, I get the following exception:
org.glassfish.osgijavaeebase.DeploymentException: Deployment of xxx.xxx.platon-cache [398] failed because of following reason: Failed while deploying bundle xxx.xxx.platon-cache [398] : java.lang.RuntimeException: Failed to deploy bundle [ xxx.xxx.platon-cache [398] ], root cause: Exception while loading the app
at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:127)
at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:109)
at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:153)
at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:150)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Failed to deploy bundle [ xxx.xxx.platon-cache [398] ], root cause: Exception while loading the app
at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:198)
at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:120)
at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:123)
... 9 more
Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Initialization failed for Singleton HazelcastService
at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:656)
at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:396)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:219)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:180)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:158)
at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:166)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:185)
... 11 more
Caused by: javax.ejb.CreateException: Initialization failed for Singleton HazelcastService
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:483)
at com.sun.ejb.containers.AbstractSingletonContainer.access$000(AbstractSingletonContainer.java:81)
at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:654)
... 22 more
Caused by: java.lang.IllegalArgumentException: PortableFactory[-17] is already registered! com.hazelcast.concurrent.atomiclong.client.AtomicLongPortableHook$1#682d1719 -> com.hazelcast.concurrent.atomiclong.client.AtomicLongPortableHook$1#68479fbd
at com.hazelcast.nio.serialization.PortableHookLoader.register(PortableHookLoader.java:84)
at com.hazelcast.nio.serialization.PortableHookLoader.load(PortableHookLoader.java:51)
at com.hazelcast.nio.serialization.PortableHookLoader.<init>(PortableHookLoader.java:41)
at com.hazelcast.nio.serialization.SerializationServiceImpl.<init>(SerializationServiceImpl.java:119)
at com.hazelcast.nio.serialization.SerializationServiceBuilder.build(SerializationServiceBuilder.java:175)
at com.hazelcast.instance.Node.createSerializationService(Node.java:195)
at com.hazelcast.instance.Node.<init>(Node.java:142)
at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:120)
at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:153)
at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:136)
at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:112)
at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58)
at xxx.xxx.platon.cache.HazelcastService.init(HazelcastService.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1035)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:412)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:375)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:1949)
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:475)
... 24 more
]]
The hazelcast instance is created in the only place, so there shouldn't be any conflicts with some other hazelcast cluster. Everything works correctly in non-osgi environment.
The hazelcast config is the simpliest one:
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.1.xsd" xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>dev</name>
<password>dev-pass</password>
</group>
<network>
<port auto-increment="true" port-count="100">5701</port>
<outbound-ports>
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="true">
<interface>127.0.0.1</interface>
</tcp-ip>
</join>
</network>
</hazelcast>
What is the reason of this exception?
it smells very much like this issue: https://github.com/hazelcast/hazelcast/issues/3922.
Can you please try it with the latest Hazelcast 3.3.4-SNAPSHOT? It should be fixed there.
EDIT: This workaround is not needed anymore; Latest releases of both 3.3 and 3.4 branches include this fix.

Tomcat Restart automatically Web Application on startup, after error

I've a big trouble on tomcat.
Before explaine, let me tell is the first time I see something like this...
I'm building an application using JPA on Hibernate, Spring 3.0 and Jersey REST Framework.
When using glassfish, everything works fine, but deployng the same application on tomcat, I registered the following error code:
GRAVE: Error deploying configuration descriptor java-zero.xml
java.lang.NoClassDefFoundError: com/sun/jersey/spi/container/servlet/ServletContainer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2527)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1010)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1483)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
... 34 more
Then tomcat restarts the application and again, the same error. In an infinite loop.
Looks like a library conflict, but I really don't have any ideas on how to solve it...
Any suggestion is appreciated!
Ciao, Davide.
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer suggests that you either don't have the Jersey JAR file or you've put it in the wrong place.
If it's the former, download it here and add it to Tomcat.
If it's the latter, put it and all its dependencies in either your WEB-INF/lib, server/lib for Tomcat 5.x or lib for Tomcat 6.x. (Just one, not all.)
It works with Glassfish because they've bundled it for you. Tomcat has not.
Remove all Jersey JAR from /WEB_INF/lib folder, refresh project and again paste all JARs of Jersey library into /WEB_INF/lib. Refresh project, stop server again, deploy and run.
It looks like either jersey.jar and/or jsr311-api.jar are missing from your webapp. You might check they are in the WEB-INF/lib folder.

Categories