I created Java web application and trying to force atmosphere to use JSR-356 since, as I understood, it's the only way to use original javax.servlet.HttpSession from AtmosphereResource object.
When I deploy my application to Jetty (v. 9.3.7), I get the following errors:
16:45:16.535 [Scanner-1] ERROR org.atmosphere.util.IOUtils -
java.lang.IllegalStateException: Unable to configure jsr356 at that stage. No Servlet associated with Key[type=org.atmosphere.guice.AtmosphereGuiceServlet, annotation=[none]]
at org.atmosphere.util.IOUtils.guestRawServletPath(IOUtils.java:274) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.util.IOUtils.guestServletPath(IOUtils.java:248) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:63) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:40) [atmosphere-runtime-2.4.3.jar:2.4.3]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [na:1.8.0_74]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [na:1.8.0_74]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [na:1.8.0_74]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [na:1.8.0_74]
at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:234) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolveWebSocket(DefaultAsyncSupportResolver.java:306) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolve(DefaultAsyncSupportResolver.java:292) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereFramework.autoDetectContainer(AtmosphereFramework.java:2082) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:914) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:838) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereFrameworkInitializer.configureFramework(AtmosphereFrameworkInitializer.java:75) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:84) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:80) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:75) [atmosphere-runtime-2.4.3.jar:2.4.3]
at com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:121) [guice-servlet-4.0.jar:na]
at com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:82) [guice-servlet-4.0.jar:na]
at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:103) [guice-servlet-4.0.jar:na]
at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:220) [guice-servlet-4.0.jar:na]
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:137) [jetty-servlet-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:856) [jetty-servlet-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:350) [jetty-servlet-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1379) [jetty-webapp-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1341) [jetty-webapp-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772) [jetty-server-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:263) [jetty-servlet-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:517) [jetty-webapp-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:188) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:499) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:147) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:458) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:610) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:529) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:392) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_74]
at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_74]
16:45:16.536 [Scanner-1] ERROR o.a.cpr.DefaultAsyncSupportResolver - Real error: Unable to configure jsr356 at that stage
java.lang.IllegalStateException: Unable to configure jsr356 at that stage
at org.atmosphere.util.IOUtils.guestRawServletPath(IOUtils.java:292) ~[atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.util.IOUtils.guestServletPath(IOUtils.java:248) ~[atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:63) ~[atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:40) ~[atmosphere-runtime-2.4.3.jar:2.4.3]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_74]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_74]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_74]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_74]
at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:234) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolveWebSocket(DefaultAsyncSupportResolver.java:306) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolve(DefaultAsyncSupportResolver.java:292) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereFramework.autoDetectContainer(AtmosphereFramework.java:2082) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:914) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:838) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereFrameworkInitializer.configureFramework(AtmosphereFrameworkInitializer.java:75) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:84) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:80) [atmosphere-runtime-2.4.3.jar:2.4.3]
at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:75) [atmosphere-runtime-2.4.3.jar:2.4.3]
at com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:121) [guice-servlet-4.0.jar:na]
at com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:82) [guice-servlet-4.0.jar:na]
at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:103) [guice-servlet-4.0.jar:na]
at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:220) [guice-servlet-4.0.jar:na]
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:137) [jetty-servlet-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:856) [jetty-servlet-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:350) [jetty-servlet-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1379) [jetty-webapp-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1341) [jetty-webapp-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772) [jetty-server-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:263) [jetty-servlet-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:517) [jetty-webapp-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:188) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:499) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:147) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:458) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64) [jetty-deploy-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:610) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:529) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:392) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329) [jetty-util-9.3.7.v20160115.jar:9.3.7.v20160115]
at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_74]
at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_74]
If I force native API to take the precedence with the following code
params.put(ApplicationConfig.WEBSOCKET_SUPPRESS_JSR356, "true");
then everything works fine.
Here is my deployment descriptor:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<listener>
<listener-class>com.sample.guice.GuiceContextListener</listener-class>
</listener>
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
The module used to provide all the bindings:
public class ServerModule extends AbstractModule
{
#Override
protected void configure()
{
install(new ServletModule() {
#Override
protected void configureServlets()
{
Map<String, String> params = new HashMap<>();
// params.put(ApplicationConfig.WEBSOCKET_SUPPRESS_JSR356, "true");
serve("/atmosphere").with(AtmosphereGuiceServlet.class, params);
}
});
}
}
I omitted the class annotated with #ManagedService and some other code since there are no problems. As I said, everything works fine with native websocket API.
the message:
Unable to configure jsr356 at that stage
means, that the jsr356 support needs to be added during ServletContextInitialization phase, the best in a ServletContextListener
my problem is that jetty 9.4 native websocket is not compatible with atmosphere anymore, on the other hand jsr356 is not compatible with guice
I managed to make jsr356 work with vaadin 8.8.1 and jetty 9.4, but it requires the VaadinServlet to be directly managed by Jetty. This doesn't work with Guice, which installs it's own GuiceFilter, and the servlets are not registered to Jetty directly.
look at JSR356WebsocketInitializer.initAtmosphereForVaadinServlet for more information
You can just add ApplicationConfig.JSR356_MAPPING_PATH initParameter and give it a try.
If it doesn't work ,may be you can initialize atmosphere framework explicitly and specify init param
ApplicationConfig.JSR356_MAPPING_PATH as valid key value pair .
For initialization you can see org.atmosphere.cpr.ContainerInitializer and for adding the path while initalizing the atmosphere framework
final AtmosphereFramework framework = AtmosphereFrameworkInitializer.newAtmosphereFramework(c, false, true);
// Hack to make jsr356 works. Pretty ugly.
DefaultAsyncSupportResolver resolver = new DefaultAsyncSupportResolver(framework.getAtmosphereConfig());
framework.getAtmosphereConfig().addInitParam(ApplicationConfig.JSR356_MAPPING_PATH,appropriateservletPath);
Related
My Payara REST API is working fine without DB Connection, and also Postgres localhost connection works fine through DriverManager i.e.:
Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "pass#123")
However, Datasource for postgresql in web.xml & Resource is throwing NullPointerException in below code:
public class AppService {
#Resource(name="java:global/esWf")
DataSource ds;
public Response test (
...
Connection conn = ds.getConnection();
...
WEB-INF/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"
version="3.1">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<display-name>PG-DataSource</display-name>
<data-source>
<name>java:global/esWf</name>
<class-name>org.postgresql.ds.PGSimpleDataSource</class-name>
<url>jdbc:postgresql://localhost:5432/postgres</url>
<user>postgres</user>
<password>pass#123</password>
<property>
<name>fish.payara.slow-query-threshold-in-seconds</name>
<value>5</value>
</property>
</data-source>
</web-app>
I have also tried replacing url with separate elements for server, port, db name!
This is first time I am trying to connect via Datasource & Resource, and could be am missing something minor!
Links referred: - https://blog.payara.fish/setting-up-a-data-source-in-payara-micro,
https://dzone.com/articles/easy-java-ee-microservices-with-payara-micro,
Payara DB Examples etc
Error: -
java.lang.NullPointerException
at es.dms.DmsSrv.test(DmsSrv.java:65)
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:498)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:253)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:232)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1636)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:259)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:757)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:158)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
at java.lang.Thread.run(Thread.java:748)
This looks like the same issue as in resource injection in cdi bean.
Injection using #Resource doesn't work in plain CDI beans and JAX-RS resources. It only works in enterprise beans.
You have 2 options:
turn your bean into a stateless EJB - just add #Stateless annotation to the class:
#Stateless
#RequestScoped
#Path("app")
public class AppService {
#Resource(name="java:global/esWf")
DataSource ds;
public Response test (
Create a CDI producer and then inject the datasource as a CDI bean. The best practice is to use a qualifier to mark which DS you want to inject (in case there are multiple datasources in the app):
#Qualifier
#Retention(RUNTIME)
#Target({METHOD, FIELD, PARAMETER, TYPE})
public #interface Eswf {
}
---------------
#RequestScoped
public DsProducer {
#Produces
#Resource(name="java:global/esWf")
#Eswf
Datasource eswfDatasource;
}
------------------
#RequestScoped
#Path("app")
public class AppService {
#Inject
#Eswf
DataSource ds;
public Response test (
P.S. I think that you also need to change the JNDI name to use the java:app/ namespace instad of java:global/ because the DS should be available only to the deployed application. You can test whether you can retrieve the DS by JNDI name using `new InitialContext().lookup("java:global/esWf"). That should work anywhere in your application, not only in EJBs.
I have a java project (tomcat webapp) with some REST Api. I want to generate swagger documentation for them. I started from this tutorial (github).
I don't have maven we use an ant task. I included swagger-annotations-1.5.0.jar and all jar that cames with swagger-jaxrs JAR 1.5.0 version( I can include a complete list if it is useful)
I've annotated some method and I have a configuration class like this:
#ApplicationPath("/api")
public class Configurator extends Application {
public Configurator() {
init();
}
private void init() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.0");
beanConfig.setSchemes(new String[]{"http"});
beanConfig.setHost("myserver.it:8080");
beanConfig.setBasePath("/swagger-demo/api");
beanConfig.setResourcePackage("myserver.rest");
beanConfig.setTitle("RESTEasy, Swagger and Swagger UI Example");
beanConfig.setScan(true);
}
}
when I deploy it agains tomcat 9 I can see this log in localhost.log file
java.lang.NoSuchMethodError: io.swagger.util.Json.create()Lcom/fasterxml/jackson/databind/ObjectMapper;
at io.swagger.jaxrs.json.JacksonJsonProvider.(JacksonJsonProvider.java:30)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1375)
at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:272)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:366)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:83)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:71)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154)
at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199)
at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:122)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2126)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:116)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:90)
at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.lambda$getAllServiceHolders$0(AbstractHk2InjectionManager.java:160)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.LinkedList$LLSpliterator.forEachRemaining(LinkedList.java:1235)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.getAllServiceHolders(AbstractHk2InjectionManager.java:164)
at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.getAllServiceHolders(ImmediateHk2InjectionManager.java:54)
at org.glassfish.jersey.internal.inject.Providers.getServiceHolders(Providers.java:337)
at org.glassfish.jersey.internal.inject.Providers.getCustomProviders(Providers.java:175)
at org.glassfish.jersey.message.internal.MessageBodyFactory.initialize(MessageBodyFactory.java:238)
at org.glassfish.jersey.message.internal.MessageBodyFactory$MessageBodyWorkersConfigurator.postInit(MessageBodyFactory.java:136)
at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$2(ApplicationHandler.java:372)
at java.util.Arrays$ArrayList.forEach(Arrays.java:3880)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:372)
at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$1(ApplicationHandler.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:256)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:315)
at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:282)
at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:335)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:178)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:370)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1124)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:974)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4813)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5125)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3700)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:292)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5447)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1396)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1400)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1400)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1368)
at java.lang.Thread.run(Thread.java:748)
If I try to reach http://myserver.it:8080/swagger-demo/api/ this give me 404 error.
I read this post about this error (here) but I really can't say what's wrong. I'm strugglin.
Any hints would be appreciated
I answer to myself since I finally find a solution. Problem was inconsistency with libraries. I solved using this site Jar download, that gives me all the dependencies. Then I compare some libraries that I already jave in my project and in caso of conflict I choose the newest one.
We're in the processing of moving a Weblogic 10.3.6 app to Weblogic 12.2.1.2. We have many EJB 2.1 beans that form part of the app. We've hit a strange problem with some of these beans.
When we have 1 ejb call another and this bean throws a checked exception (e.g. RuleException extends Exception) this is thrown as a RemoteException (RemoteEJBInvokeException). This only occurs if the app is running in a cluster. If I deploy against a standalone jvm it works fine.
The general EJB pattern is a Facade pattern. In the Facade bean we use a standard JNDI lookup to locate the Home and then run the create method to return the business interface/impl
InitialContext ctx = new InitialContext();
ReportManagementHome reportManagementHome = (ReportManagementHome) ctx.lookup("ReportManagement");
ReportManagement reportManagement = reportManagementHome.create();
ReportManagement bean runs the business logic and throws a RuleException.
This is an example method in the facade that calls the 2nd bean:
public String doTest() {
String s = null;
try
{
s = reportManagement.doValidate();
}
catch ( RuleException re )
{
rollBack();
} catch (RemoteException e)
{
e.printStackTrace();
}
return s;
}
Here is the doValidate() method in the 2nd bean:
public String doValidate( )
throws RuleException, CustomException
{
int test = 1;
if (test == 1)
{
throw new RuleException();
}
return "Hello";
}
Although the RuleException is correctly reached and thrown, by the time the facade catches it it is a RemoteException.
This is an example list of the ejbs/interfaces:
ReportManagement
ReportManagementBean
ReportManagementFacade
ReportManagementFacadeBean
ReportManagementFacadeHome
ReportManagementFacadeLocal
ReportManagementFacadeLocalHome
ReportManagementHome
ReportManagementLocal
ReportManagementLocalHome
Here is the ejb-jar.xml
<?xml version='1.0' encoding='UTF-8'?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
version="2.1">
<enterprise-beans>
<session>
<display-name>ReportManagementFacade</display-name>
<ejb-name>ReportManagementFacade</ejb-name>
<home>com.ejb.ReportManagementFacadeHome</home>
<remote>com.ejb.ReportManagementFacade</remote>
<local-home>com.ejb.ReportManagementFacadeLocalHome</local-home>
<local>com.ejb.ReportManagementFacadeLocal</local>
<ejb-class>com.ejb.ReportManagementFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<session>
<display-name>ReportManagement</display-name>
<ejb-name>ReportManagement</ejb-name>
<home>com.ejb.ReportManagementHome</home>
<remote>com.ejb.ReportManagement</remote>
<local-home>com.ejb.ReportManagementLocalHome</local-home>
<local>com.ejb.ReportManagementLocal</local>
<ejb-class>com.ejb.ReportManagementBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>ReportManagementFacade</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>ReportManagement</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
Here is the weblogic-ejb-jar.xml
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-ejb-jar xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.2/weblogic-ejb-jar.xsd">
<weblogic-enterprise-bean>
<ejb-name>ReportManagementFacade</ejb-name>
<jndi-name>Destin8.ejb.reportmanagement.ReportManagementFacade</jndi-name>
<local-jndi-name>Destin8.ejb.reportmanagement.ReportManagementFacadeLocal</local-jndi-name>
<enable-call-by-reference>true</enable-call-by-reference>
</weblogic-enterprise-bean>
<weblogic-enterprise-bean>
<ejb-name>ReportManagement</ejb-name>
<jndi-name>Destin8.ejb.reportmanagement.ReportManagement</jndi-name>
<local-jndi-name>Destin8.ejb.reportmanagement.ReportManagementLocal</local-jndi-name>
<enable-call-by-reference>true</enable-call-by-reference>
</weblogic-enterprise-bean>
<weblogic-compatibility>
<entity-always-uses-transaction>true</entity-always-uses-transaction>
</weblogic-compatibility>
</weblogic-ejb-jar>
And here is the StackTrace:
weblogic.rmi.RemoteEJBInvokeException: null; nested exception is:
com.exception.RuleException
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:27)
at com.ejb.ReportManagement_tq6u66_EOImpl.doLUMValidate(Unknown Source)
at com.ejb.ReportManagementFacadeBean.doLUM(ReportManagementFacadeBean.java:82)
at com.ejb.ReportManagementFacade_sidvua_EOImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invokeInternal(SessionRemoteMethodInvoker.java:54)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:21)
at com.ejb.ReportManagementFacade_sidvua_EOImpl.doLUM(Unknown Source)
at com.ajf.Page1ManagedBean.refreshDate(Page1ManagedBean.java:105)
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:498)
at com.sun.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:181)
at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:650)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:32)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3683)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259)
at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1691)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1651)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:270)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused by: com.exception.RuleException
at com.ejb.ReportManagementBean.doLUMValidate(ReportManagementBean.java:92)
at com.ejb.ReportManagement_tq6u66_EOImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invokeInternal(SessionRemoteMethodInvoker.java:54)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:21)
... 55 more
Any guidance in this matter will be much appreciated.
This was fixed in a patch by Oracle on my request. The link for that patch is here Patch Link. You will need an Oracle Support log on to be able to access it.
This:
<enable-call-by-reference>true</enable-call-by-reference>
causes your remote calls in the same JVM to have local call semantics, including exception handling.
I am getting this error in apache Tomcat logs:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataBaseInitializer' defined in class path resource [context.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
10-Oct-2015 00:41:01.266 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
10-Oct-2015 00:41:01.267 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1648)
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:601)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:791)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
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:601)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:791)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1447)
at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:89)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1292)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1380)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:812)
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:601)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
at net.dontdrinkandroot.example.angularrestspringsecurity.dao.JpaDao.save(JpaDao.java:69)
at net.dontdrinkandroot.example.angularrestspringsecurity.dao.DataBaseInitializer.initDataBase(DataBaseInitializer.java:46)
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:601)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1638)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1579)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
... 55 more
10-Oct-2015 00:41:01.370 WARNING [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
[2015-10-10 12:41:01,617] Artifact angular-rest-springsecurity:war exploded: Error during artifact deployment. See server log for details.
[2015-10-10 12:42:14,717] Artifact angular-rest-springsecurity:war exploded: Artifact is being deployed, please wait...
10-Oct-2015 00:42:43.433 INFO [Finalizer] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [com.mysql.jdbc.SQLError]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [com.mysql.jdbc.SQLError]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1335)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1321)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1203)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1164)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3246)
at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:1656)
at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4261)
at com.mysql.jdbc.ConnectionImpl.cleanup(ConnectionImpl.java:1248)
at com.mysql.jdbc.ConnectionImpl.finalize(ConnectionImpl.java:2655)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:101)
at java.lang.ref.Finalizer.access$100(Finalizer.java:32)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:178)
My web.xml file is this:
**<?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>angular-rest-springsecurity</display-name>
<!--
Load Spring Context
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/context.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--
Map the REST Servlet to /rest/
-->
<servlet>
<servlet-name>RestService</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>net.dontdrinkandroot.example.angularrestspringsecurity.rest</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestService</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<!--
Apply Spring Security Filter to all Requests
-->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>**
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence
version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="examplePU">
<class>net.dontdrinkandroot.example.angularrestspringsecurity.entity.NewsEntry</class>
<class>net.dontdrinkandroot.example.angularrestspringsecurity.entity.User</class>
</persistence-unit>
</persistence>
and Database Iniatilizer class:
package net.dontdrinkandroot.example.angularrestspringsecurity.dao;
import java.util.Date;
import net.dontdrinkandroot.example.angularrestspringsecurity.dao.newsentry.NewsEntryDao;
import net.dontdrinkandroot.example.angularrestspringsecurity.dao.user.UserDao;
import net.dontdrinkandroot.example.angularrestspringsecurity.entity.NewsEntry;
import net.dontdrinkandroot.example.angularrestspringsecurity.entity.User;
import org.springframework.security.crypto.password.PasswordEncoder;
/**
* Initialize the database with some test entries.
*
* #author Philip W. Sorst <philip#sorst.net>
*/
public class DataBaseInitializer
{
private NewsEntryDao newsEntryDao;
private UserDao userDao;
private PasswordEncoder passwordEncoder;
protected DataBaseInitializer()
{
/* Default constructor for reflection instantiation */
}
public DataBaseInitializer(UserDao userDao, NewsEntryDao newsEntryDao, PasswordEncoder passwordEncoder)
{
this.userDao = userDao;
this.newsEntryDao = newsEntryDao;
this.passwordEncoder = passwordEncoder;
}
public void initDataBase()
{
User userUser = new User("user", this.passwordEncoder.encode("user"));
userUser.addRole("user");
this.userDao.save(userUser);
User adminUser = new User("admin", this.passwordEncoder.encode("admin"));
adminUser.addRole("user");
adminUser.addRole("admin");
this.userDao.save(adminUser);
long timestamp = System.currentTimeMillis() - 1000 * 60 * 60 * 24;
for (int i = 0; i < 10; i++) {
NewsEntry newsEntry = new NewsEntry();
newsEntry.setContent("This is example content " + i);
newsEntry.setDate(new Date(timestamp));
this.newsEntryDao.save(newsEntry);
timestamp += 1000 * 60 * 60;
}
}
}
Error was because dispatcher Servlet file. The Correct way of declare entitymanagerfactory was different. DatabaseInitilizer Class is used to intialize the database username and password in a encrypted format.
Where is passwordEncoder being constructed and set in the DataBaseInitializer? It looks like its still null when initDataBase() is called here:
User userUser = new User("user", this.passwordEncoder.encode("user"));
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