javarestjerseyjax-rsglassfish-4.1

Why did this jersey-ejb example fail?


Building and deploying the ejb example in the Jersey project here using JDK 8 and Glassfish 4.1 on OSX in Netbeans 8.2, the project builds a war and deploys ok but then gives the following issues in the Glassfish logs:

"...org.glassfish.jersey.examples.jersey_ejb.entities.Message registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER".. (and with errors on screen about javax.ejb.EJBException)

I found similar a SO question: Restful webservices - NoClassDefFoundError: org/glassfish/jersey/ExtendedConfig where the solution was to add jersy-common to the classpath.

I added it to the /Users/myusername/GlassFish_Server/glassfish/lib folder.

The application now works without issue.

I want to know why it failed and whether it is a bug in the example and if there a better solution than this manual jar copy.

Early in the glassfish logs it talks about the bundle provisioner errors:

WARNING: Skipping entry because it is not an absolute URI.

Later the problem classes that use the problem org.glassfish.jersey.examples.jersey_ejb.entities.Message are the only ones using Portable JNDI names:

Info: visiting unvisited references Info: Portable JNDI names for EJB MessageListWriter: [java:global/jersey-examples-ejb/MessageListWriter, java:global/jersey-examples-ejb/MessageListWriter!javax.ws.rs.ext.MessageBodyWriter]

Can anyone offer a better solution, or fix to the project that is better than the jar copy (that I should 'have' to do)? (Link to the full glassfish output https://gist.github.com/systemsincode/26afac851a72387047f62fe1803e089b)


Solution

  • TLDR: The version of Glasfish was too old.

    I am using code from the latest Jersey today which is 2.28

    According to this blog running unzip -p modules/jersey-common.jar META-INF/MANIFEST.MF | grep Bundle-Version in your glassfish directory should give you your run-time version.

    In Glassfish 4.1 I get Bundle-Version: 2.10.4

    In Glassfish 5 I get Bundle-Version: 2.26.0

    I likely got around one breaking change by including the common library in the lib directory, overriding of the provided version. But if you really must update glassfish 4.1 then follow the more complete instructions in the above blog.