Discussion:
Not able to use packageNamesResourceConfig in OSGI environment
saikiran daripelli
2011-12-15 11:35:28 UTC
Permalink
Hi,

Currently we are using Jersey 1.8 and i am still not able to make
jersey work in OSGI specifying packages names.

I am able to run the same war in normal web container.

Here are the steps i followed,

1. Downloaded helloworld-osgi-webapp-1.11-project.zip, changed the
web.xml init params to following,

<init-param>

<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>

<param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>

</init-param>

<init-param>

<param-name>com.sun.jersey.config.property.packages</param-name>

<param-value>com.sun.jersey.samples.helloworld</param-value>

</init-param>

2. Installed Apache Felix latest version,4.0.2.

3. Followed the steps specified in README.html inside the helloworld
zip.



But, when i hit the URL, it shows 500 Internal Server Error.

I further tried to debug log, and got the below error message



Dec 13, 2011 10:11:22 PM
com.sun.jersey.api.core.PackagesResourceConfig init

INFO: Scanning for root resource and provider classes in the packages:

com.sun.jersey.samples.helloworld

Dec 13, 2011 10:11:45 PM
com.sun.jersey.server.impl.application.WebApplicationImpl _initiate

INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17
AM'

DEBUG: DYNAMIC WIRE: [58.0] osgi.wiring.package; (osgi.wiring.package=*) ->
[0]

DEBUG: Bundle com.sun.jersey.jersey-core [58]
com/sun/jersey/impl/impl_en.properties not found by
com.sun.jersey.jersey-core [58]

DEBUG: Bundle com.sun.jersey.jersey-core [58]
com/sun/jersey/impl/impl_en_US.properties not found by
com.sun.jersey.jersey-core [58]

Dec 13, 2011 10:11:45 PM
com.sun.jersey.server.impl.application.RootResourceUriRules <init>

SEVERE: The ResourceConfig instance does not contain any root resource
classes.





Are we doing anything wrong here? Do we need to pass anymore settings?

There was a Jira JERSEY-527 for it but it is marked as resolved longback,
and still i am unable to use packageNamesResourceConfig.

I logged a JIRA JERSEY-881.



Regards,

Saikiran
Tatu Saloranta
2011-12-15 18:36:45 UTC
Permalink
You might want to try explicitly wiring things -- I could be wrong,
but my gut feeling is that the kind of auto-magic needed for snooping
for things via classpath is not going to work with OSGi, by design.
And in many ways using auto-detection is bit dangerous practice even
otherwise (just in my opinion).

-+ Tatu +-

On Thu, Dec 15, 2011 at 3:35 AM, saikiran daripelli
Hi,
     Currently we are using Jersey 1.8 and i am still not able to make
jersey work in OSGI specifying packages names.
    I am able to run the same war in normal web container.
    Here are the steps i followed,
    1. Downloaded helloworld-osgi-webapp-1.11-project.zip, changed the
web.xml init params to following,
       <init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.sun.jersey.samples.helloworld</param-value>
       </init-param>
      2. Installed Apache Felix latest version,4.0.2.
      3. Followed the steps specified in README.html inside the helloworld
zip.
      But, when i hit the URL, it shows 500 Internal Server Error.
      I further tried to debug log, and got the below error message
          Dec 13, 2011 10:11:22 PM
com.sun.jersey.api.core.PackagesResourceConfig init
com.sun.jersey.samples.helloworld
Dec 13, 2011 10:11:45 PM
com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17
AM'
DEBUG: DYNAMIC WIRE: [58.0] osgi.wiring.package; (osgi.wiring.package=*) ->
[0]
DEBUG: Bundle com.sun.jersey.jersey-core [58]
com/sun/jersey/impl/impl_en.properties not found by
com.sun.jersey.jersey-core [58]
DEBUG: Bundle com.sun.jersey.jersey-core [58]
com/sun/jersey/impl/impl_en_US.properties not found by
com.sun.jersey.jersey-core [58]
Dec 13, 2011 10:11:45 PM
com.sun.jersey.server.impl.application.RootResourceUriRules <init>
SEVERE: The ResourceConfig instance does not contain any root resource
classes.
Are we doing anything wrong here? Do we need to pass anymore settings?
There was a Jira JERSEY-527 for it but it is marked as resolved longback,
and still i am unable to use packageNamesResourceConfig.
I logged a JIRA JERSEY-881.
Regards,
Saikiran
Loading...