Glassfish, Hibernate and WebServices – WSGEN Classpath

Java XMLFollowing my quick and dirty how-to about using hibernate in glassfish I came across a small pitfall when dealing with metro webservices.

The glassfish’s wsgen classpath on Glassfish is not by domain, ie. the wsgen tool is not run in the domain class-loader.

When trying to deploy a webservice that returns an entity with a hibernate annotation, I got this following error :

Deploy error

Server logs showed the following trace :

/home/paul/Programs/glassfish-v2-b58g/domains/domain1/applications/j2ee-apps/ear-0.1-SNAPSHOT/lib/entities-0.1-SNAPSHOT.jar(app/model/entities/User.class):
        warning: Cannot find annotation method 'value()' in type 'org.hibernate.annotations.Fetch':
        class file for org.hibernate.annotations.Fetch not found
Problem encountered during annotation processing;
see stacktrace below for more information.
java.lang.NullPointerException
        at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.isSubtype(WebServiceAP.java:360)
        ...... SNIP ......
        at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:223)
error: compilation failed, errors should have been reported
Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException: WSGEN FAILED
        at com.sun.enterprise.webservice.WsUtil.genWSInfo(WsUtil.java:2

Adding the hibernate-annotations.jar file in the glassfish main lib/ directory added the necessary classes to the wsgen classpath.

Advertisements

2 thoughts on “Glassfish, Hibernate and WebServices – WSGEN Classpath

  1. I’ve added a lot of code in my projects and now my entities are at the webservices layer. So I had to add all the Hibernate jars to the main lib/ directory of Glassfish :(

    I don’t have time to investigate more so I’ll stick with this really dirty solution : having the hibernate jars in the both libs directory.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s