users@jersey.java.net

[Jersey] Re: ApplicationPath and EclipseLink in Tomcat

From: Duc Luu <laudak_at_gmx.net>
Date: Fri, 29 Nov 2013 21:56:43 +0100

Hi Gili,

thanks for your quick reply.

Curiously AbstractPersistenceResource.getContext is only invoked when I
use @ApplicationPath("/"), but it is not invoked when I use
@ApplicationPath("/something-else-than-root"). It seems to change the
behaviour of Jersey during startup, but I wasn't able to find out the
reason yet.

For the persistence factory I'll ask the EclipseLink community.

Regards
Duc



On 29.11.2013 21:46, cowwoc wrote:
> Hi Duc,
>
> This seems to have nothing to do with Jersey. If you dig into the
> AbstractPersistenceResource.java source code you will notice that
> getPersistenceFactory() is returning null.
>
> 1. I would file a bug against EclipseLink asking them to throw more
> meaningful exceptions.
> 2. It sounds like you misconfigured EclipseLink. You need to somehow
> configure the persistence factory at startup.
>
> Good luck!
> Gili
>
> On 29/11/2013 3:33 PM, Duc Luu wrote:
>> Hi all,
>> I am using Jersey inside Tomcat 7 and configured the application with
>> @ApplicationPath("/"). It was working without problems.
>> This week I added EclipseLink, and when I start Tomcat, it throws a
>> NullPointerException (see below). When I change the configuration to
>> @ApplicationPath("/rest") or whatever, the NPE isn't thrown any more
>> during Tomcat startup.
>> Since I want to run the application on ROOT path without any prefix,
>> this isn't a solution.
>> Does anyone have an explaination or a solution? Thanks a lot in advance!
>> Regards
>> Duc
>> java.lang.NullPointerException
>> at
>> org.eclipse.persistence.jpa.rs.resources.common.AbstractPersistenceResource.getContexts(AbstractPersistenceResource.java:58)
>>
>> at
>> org.eclipse.persistence.jpa.rs.resources.unversioned.PersistenceResource.getContexts(PersistenceResource.java:47)
>>
>> 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.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
>>
>> at
>> org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151)
>>
>> at
>> org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171)
>>
>> at
>> org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
>>
>> at
>> org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
>>
>> at
>> org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:367)
>>
>> at
>> org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:349)
>>
>> at
>> org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:106)
>>
>> at
>> org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:259)
>> at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
>> at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
>> at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
>> at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
>> at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
>> at
>> org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318)
>>
>> at
>> org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236)
>> at
>> org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:983)
>>
>> at
>> org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:361)
>> at
>> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372)
>>
>> at
>> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335)
>>
>> at
>> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>
>> at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
>>
>> at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
>>
>> at
>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
>>
>> at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
>>
>> at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
>>
>> at
>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
>> at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>>
>> at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
>>
>> at
>> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
>>
>> at
>> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
>>
>> at
>> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
>>
>> 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:722)
>
>