I am having a problem which is somewhat related and it is driving me up
the wall......
Essentially my application has a custom JAXBContextResolver object which
implements ContentResolver<JAXBContext>. I am using Mapped Notation.
My context resolver builds the type list based on my types in a
properties config file and sets up the mappings (all defined in this file)
I recently switched to Glassfish 3.0.1 Open Source instead of Tomcat.
My JPA app is currently RESOURCE_LOCAL so it works in either. I am
noticing a really strange difference between publishing the app in
Eclipse vs. deploying the maven "compiled and installed/distributed" WAR
file into glassfish. In eclipse (like Tomcat) when the app is started I
will see this output (the types and notation type are being printed from
my JAXBContextResolver class.....
INFO: Scanning for root resource and provider classes in the Web app
resource paths:
/WEB-INF/lib
/WEB-INF/classes
INFO: Root resource classes found:
class
org.javad.preferences.model.services.resources.PreferenceResource
class org.javad.stamp.model.services.resources.StampCollectionResource
class org.javad.stamp.model.services.resources.AlbumResource
class org.javad.stamp.model.services.resources.CatalogueNumberResource
class org.javad.stamp.model.services.resources.CountryResource
class org.javad.stamp.model.services.resources.StampResource
class org.javad.stamp.model.services.resources.CatalogueResource
INFO: Provider classes found:
class org.javad.xml.jaxb.JAXBContextResolver
INFO: Initiating Jersey application, version 'Jersey: 1.1.5
01/20/2010 04:04 PM'
INFO: Adding the following classes declared in
META-INF/services/jersey-server-components to the resource
configuration:
class com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider
class com.sun.jersey.multipart.impl.MultiPartConfigProvider
class com.sun.jersey.multipart.impl.MultiPartReader
class com.sun.jersey.multipart.impl.MultiPartWriter
INFO: Adding JAXB Resolver support for the following classes:
class org.javad.preferences.model.PreferenceValue
class org.javad.preferences.model.collections.PreferencesModelList
class org.javad.stamp.model.Stamp
class org.javad.stamp.model.Country
class org.javad.stamp.model.Catalogue
class org.javad.stamp.model.CatalogueNumber
class org.javad.stamp.model.Album
class org.javad.stamp.model.StampCollection
class org.javad.stamp.model.Ownership
class org.javad.stamp.model.collections.ModelList
class org.javad.stamp.model.collections.AlbumModelList
class org.javad.stamp.model.collections.StampCollectionModelList
class org.javad.stamp.model.collections.CountryModelList
class org.javad.stamp.common.model.StampIssue
class org.javad.util.common.status.ValidationStatus
INFO: Using notation: MAPPED
You'll notice only one provider is found..... my "JAXBContextResolver."
Now, when I deploy the WAR to glassfish I am getting a different result
for the providers....
INFO: Scanning for root resource and provider classes in the Web app
resource paths:
/WEB-INF/lib
/WEB-INF/classes
INFO: Root resource classes found:
class org.javad.stamp.model.services.resources.StampCollectionResource
class
org.javad.preferences.model.services.resources.PreferenceResource
class org.javad.stamp.model.services.resources.CountryResource
class org.javad.stamp.model.services.resources.StampResource
class org.javad.stamp.model.services.resources.AlbumResource
class org.javad.stamp.model.services.resources.CatalogueResource
class org.javad.stamp.model.services.resources.CatalogueNumberResource
INFO: Provider classes found:
class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper
class org.codehaus.jackson.jaxrs.JacksonJsonProvider
class org.javad.xml.jaxb.JAXBContextResolver
class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper
INFO: Initiating Jersey application, version 'Jersey: 1.1.5
01/20/2010 04:04 PM'
INFO: Adding the following classes declared in
META-INF/services/jersey-server-components to the resource
configuration:
class com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider
class com.sun.jersey.multipart.impl.MultiPartConfigProvider
class com.sun.jersey.multipart.impl.MultiPartReader
class com.sun.jersey.multipart.impl.MultiPartWriter
INFO: Adding JAXB Resolver support for the following classes:
class org.javad.preferences.model.PreferenceValue
class org.javad.preferences.model.collections.PreferencesModelList
class org.javad.stamp.model.Stamp
class org.javad.stamp.model.Country
class org.javad.stamp.model.Catalogue
class org.javad.stamp.model.CatalogueNumber
class org.javad.stamp.model.Album
class org.javad.stamp.model.StampCollection
class org.javad.stamp.model.Ownership
class org.javad.stamp.model.collections.ModelList
class org.javad.stamp.model.collections.AlbumModelList
class org.javad.stamp.model.collections.StampCollectionModelList
class org.javad.stamp.model.collections.CountryModelList
class org.javad.stamp.common.model.StampIssue
class org.javad.util.common.status.ValidationStatus
INFO: Using notation: MAPPED
Now it is finding the jackson/jaxrs providers/mappers, and while my
JAXBContextResolver was loaded, it is not using MAPPED notation in the
returning JSON (thus corrupting my client app - I believe it is using
either natural or mapped json?). I know this has to be a classpath
issue, in that in the eclipse embedded environment, it is not finding
the Jackson JARs whereas in the WAR deployment case, because they are
in the WAR it is using them. I did a small test where I actually added
jackson-jaxrs to my pom.xml and set it to "provided" instead of
compile. This did result in it being excluded from the output WAR.
Should I be setting this jackson JAR to provided? What about the other
ones? ( jackson-core-asl, jackson-mapper-asl, jackson-xc)?
This tripped me up for ~ 2.0 hours (why it worked perfectly in eclipse
and not at all in standalone deploy) and I'd like to make I
understand/set this up correctly.
Thanks
Jason