Skip to main content

About jersey osgi-http-service sample in glassfish

7 replies [Last post]
codeprince
Offline
Joined: 2007-05-10
Points: 0

Hi Sahoo, Jersey Team

I have a question about jersey osgi-http-service sample[1].

[1]: https://github.com/jersey/jersey/tree/master/examples/osgi-http-service

After starting glassfish domain, if using "asadmin deploy --type=osgi
..." to deploy the jersey osgi sample bundle, anything is OK.

However, if I put the jersey osgi sample bundle into
glassfish/modules/autostart/ , then after starting glassfish domain, the
following exception happened in the server.log and rest endpoint is
created failed,

[#|2013-02-04T16:45:37.062+0900|INFO|glassfish
4.0|javax.enterprise.logging.stdout|_ThreadID=74;_ThreadName=pool-17-thread-1;_TimeMillis=1359963937062;_LevelValue=800;|ERROR:
Bundle org.glassfish.jersey.examples.osgi-http-service.bundle [272]
EventDispatcher: Error during dispatch. (java.lang.RuntimeException:
javax.servlet.ServletException: javax.servlet.ServletException: [failed
to localize]
resource.config.unable.to.load(org.glassfish.jersey.examples.osgihttpservice.JerseyApplication))|#]

[#|2013-02-04T16:45:37.078+0900|SEVERE|glassfish
4.0|javax.enterprise.logging.stderr|_ThreadID=74;_ThreadName=pool-17-thread-1;_TimeMillis=1359963937078;_LevelValue=1000;|java.lang.RuntimeException:
javax.servlet.ServletException: javax.servlet.ServletException: [failed
to localize]
resource.config.unable.to.load(org.glassfish.jersey.examples.osgihttpservice.JerseyApplication)
at
org.glassfish.jersey.examples.osgihttpservice.Activator.registerServlets(Activator.java:109)
at
org.glassfish.jersey.examples.osgihttpservice.Activator.access$100(Activator.java:60)
at
org.glassfish.jersey.examples.osgihttpservice.Activator$1.addingService(Activator.java:78)
at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:980)
at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:906)
at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:262)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:234)
at
org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:941)
at
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:932)
at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:793)
at
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4260)
at org.apache.felix.framework.Felix.registerService(Felix.java:3275)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:320)
at org.glassfish.osgihttp.Activator.doActualWork(Activator.java:137)
at org.glassfish.osgihttp.Activator.access$300(Activator.java:84)
at
org.glassfish.osgihttp.Activator$OSGiHtttpExtender.start(Activator.java:332)
at
org.glassfish.osgijavaeebase.ExtenderManager$ExtenderTracker.addingService(ExtenderManager.java:144)
at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:980)
at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:906)
at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:262)
at
org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:185)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:348)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:283)
at
org.glassfish.osgijavaeebase.ExtenderManager.startExtenders(ExtenderManager.java:109)
at
org.glassfish.osgijavaeebase.ExtenderManager.access$100(ExtenderManager.java:67)
at
org.glassfish.osgijavaeebase.ExtenderManager$GlassFishServerTracker$1.run(ExtenderManager.java:192)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
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: javax.servlet.ServletException:
javax.servlet.ServletException: [failed to localize]
resource.config.unable.to.load(org.glassfish.jersey.examples.osgihttpservice.JerseyApplication)
at
org.glassfish.osgihttp.GlassFishHttpService.registerServlet(GlassFishHttpService.java:105)
at
org.glassfish.osgihttp.HttpServiceWrapper.registerServlet(HttpServiceWrapper.java:93)
at
org.glassfish.jersey.examples.osgihttpservice.Activator.rawRegisterServlets(Activator.java:119)
at
org.glassfish.jersey.examples.osgihttpservice.Activator.registerServlets(Activator.java:105)
... 33 more
Caused by: javax.servlet.ServletException: [failed to localize]
resource.config.unable.to.load(org.glassfish.jersey.examples.osgihttpservice.JerseyApplication)
at
org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:378)
at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:251)
at
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:144)
at
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:326)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at
org.glassfish.osgihttp.OSGiServletWrapper.initializeServlet(OSGiServletWrapper.java:92)
at
org.glassfish.osgihttp.GlassFishHttpService.registerServlet(GlassFishHttpService.java:103)
... 36 more
Caused by: java.lang.ClassNotFoundException:
org.glassfish.jersey.examples.osgihttpservice.JerseyApplication not
found by org.glassfish.jersey.core.jersey-common [165]
at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at
org.glassfish.jersey.internal.util.ReflectionHelper.classForNameWithException(ReflectionHelper.java:284)
at
org.glassfish.jersey.internal.util.ReflectionHelper.classForNameWithException(ReflectionHelper.java:262)
at
org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:368)
... 42 more
|#]

From the above exception, this should belong to class loader issue.

Thanks
--Tang

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
codeprince
Offline
Joined: 2007-05-10
Points: 0

Hi sahoo,

Please ignore the mail and I have resolved the issue.

By setting correct thread current context classloader, I can register
jersey servlet while putting the bundle into autostart directory.

Thanks
--Tang

Tang Yong wrote:
> Hi Sahoo, Jersey Team
>
> I have a question about jersey osgi-http-service sample[1].
>
> [1]: https://github.com/jersey/jersey/tree/master/examples/osgi-http-service
>
> After starting glassfish domain, if using "asadmin deploy --type=osgi
> ..." to deploy the jersey osgi sample bundle, anything is OK.
>
> However, if I put the jersey osgi sample bundle into
> glassfish/modules/autostart/ , then after starting glassfish domain, the
> following exception happened in the server.log and rest endpoint is
> created failed,
>
> [#|2013-02-04T16:45:37.062+0900|INFO|glassfish
> 4.0|javax.enterprise.logging.stdout|_ThreadID=74;_ThreadName=pool-17-thread-1;_TimeMillis=1359963937062;_LevelValue=800;|ERROR:
> Bundle org.glassfish.jersey.examples.osgi-http-service.bundle [272]
> EventDispatcher: Error during dispatch. (java.lang.RuntimeException:
> javax.servlet.ServletException: javax.servlet.ServletException: [failed
> to localize]
> resource.config.unable.to.load(org.glassfish.jersey.examples.osgihttpservice.JerseyApplication))|#]
>
> [#|2013-02-04T16:45:37.078+0900|SEVERE|glassfish
> 4.0|javax.enterprise.logging.stderr|_ThreadID=74;_ThreadName=pool-17-thread-1;_TimeMillis=1359963937078;_LevelValue=1000;|java.lang.RuntimeException:
> javax.servlet.ServletException: javax.servlet.ServletException: [failed
> to localize]
> resource.config.unable.to.load(org.glassfish.jersey.examples.osgihttpservice.JerseyApplication)
> at
> org.glassfish.jersey.examples.osgihttpservice.Activator.registerServlets(Activator.java:109)
> at
> org.glassfish.jersey.examples.osgihttpservice.Activator.access$100(Activator.java:60)
> at
> org.glassfish.jersey.examples.osgihttpservice.Activator$1.addingService(Activator.java:78)
> at
> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:980)
> at
> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:906)
> at
> org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:262)
> at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:234)
> at
> org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:941)
> at
> org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:932)
> at
> org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:793)
> at
> org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543)
> at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4260)
> at org.apache.felix.framework.Felix.registerService(Felix.java:3275)
> at
> org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
> at
> org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:320)
> at org.glassfish.osgihttp.Activator.doActualWork(Activator.java:137)
> at org.glassfish.osgihttp.Activator.access$300(Activator.java:84)
> at
> org.glassfish.osgihttp.Activator$OSGiHtttpExtender.start(Activator.java:332)
> at
> org.glassfish.osgijavaeebase.ExtenderManager$ExtenderTracker.addingService(ExtenderManager.java:144)
> at
> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:980)
> at
> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:906)
> at
> org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:262)
> at
> org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:185)
> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:348)
> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:283)
> at
> org.glassfish.osgijavaeebase.ExtenderManager.startExtenders(ExtenderManager.java:109)
> at
> org.glassfish.osgijavaeebase.ExtenderManager.access$100(ExtenderManager.java:67)
> at
> org.glassfish.osgijavaeebase.ExtenderManager$GlassFishServerTracker$1.run(ExtenderManager.java:192)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
> at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> 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: javax.servlet.ServletException:
> javax.servlet.ServletException: [failed to localize]
> resource.config.unable.to.load(org.glassfish.jersey.examples.osgihttpservice.JerseyApplication)
> at
> org.glassfish.osgihttp.GlassFishHttpService.registerServlet(GlassFishHttpService.java:105)
> at
> org.glassfish.osgihttp.HttpServiceWrapper.registerServlet(HttpServiceWrapper.java:93)
> at
> org.glassfish.jersey.examples.osgihttpservice.Activator.rawRegisterServlets(Activator.java:119)
> at
> org.glassfish.jersey.examples.osgihttpservice.Activator.registerServlets(Activator.java:105)
> ... 33 more
> Caused by: javax.servlet.ServletException: [failed to localize]
> resource.config.unable.to.load(org.glassfish.jersey.examples.osgihttpservice.JerseyApplication)
> at
> org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:378)
> at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:251)
> at
> org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:144)
> at
> org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:326)
> at javax.servlet.GenericServlet.init(GenericServlet.java:244)
> at
> org.glassfish.osgihttp.OSGiServletWrapper.initializeServlet(OSGiServletWrapper.java:92)
> at
> org.glassfish.osgihttp.GlassFishHttpService.registerServlet(GlassFishHttpService.java:103)
> ... 36 more
> Caused by: java.lang.ClassNotFoundException:
> org.glassfish.jersey.examples.osgihttpservice.JerseyApplication not
> found by org.glassfish.jersey.core.jersey-common [165]
> at
> org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
> at
> org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
> at
> org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:186)
> at
> org.glassfish.jersey.internal.util.ReflectionHelper.classForNameWithException(ReflectionHelper.java:284)
> at
> org.glassfish.jersey.internal.util.ReflectionHelper.classForNameWithException(ReflectionHelper.java:262)
> at
> org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:368)
> ... 42 more
> |#]
>
>>From the above exception, this should belong to class loader issue.
>
> Thanks
> --Tang
>
>
>

Anonymous

codeprince wrote:
Please ignore the mail and I have resolved the issue. By
setting correct thread current context classloader, I can register jersey
servlet while putting the bundle into autostart directory.
Hi Tang,
I'm facing the same issue. However I couldn't follow what you meant by
setting the correct thread current context classloader. Could you please
elaborate or specify the changes that you have made to get this working?
Thanks!

--

[Message sent by forum member 'badger']

View Post: http://forums.java.net/node/894432

badger
Offline
Joined: 2013-04-02
Points: 0

Hi Tang,

I'm facing the same issue. However I couldn't follow what you meant by setting the correct thread current context classloader. Could you please elaborate or specify the changes that you have made to get this working?

Thanks!

codeprince
Offline
Joined: 2007-05-10
Points: 0

Hi Badger,

I am confirming the newest jersey example, please waiting for a while.

In addition, my previous way can be seen from the following,

https://github.com/tangyong/glassfish-obr-builder/blob/master/src/main/j...

pl.seeing rawRegisterServlets()

Thanks
--Tang

codeprince
Offline
Joined: 2007-05-10
Points: 0

I have confirmed the newest Jersey sample and the issue is still there.

Firstly, I assume that you are using glassfish v4.

Then, the jersey sample has a package issue[1] while deploying the sample into glassfish.
[1]: http://java.net/jira/browse/JERSEY-1834

Finally, I have made a modification for the sample and can deploy into gf successfully.

Pl. Seeing the attachment and try it.

If not OK, please tell me.

Thanks
--Tang Yong

Anonymous

Hi codeprince, Thank you for the helpful pointer! The modification
successfully worked on my environment as well.

--

[Message sent by forum member 'badger']

View Post: http://forums.java.net/node/894432

badger
Offline
Joined: 2013-04-02
Points: 0

Hi codeprince,

Thank you for the helpful pointer!
The modification successfully worked on my environment as well.