I am running a test on Ubuntu with an update to Oracle Java 7 3. According to the release notes, it includes JAXB-2.2.4.
/home/ubuntu
The machine says that it has JAXB-2.2.4:
$ wsimport -version JAX-WS RI 2.2.4-b01
$ java -version
java version "1.7.0_03" Java(TM) SE Runtime Environment (build 1.7.0_03-b04) Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode)
However, when I run my application that uses JAX-RS and marshalls some objects with JAXB, I get the following error:
Apr 05, 2012 10:45:50 AM com.sun.jersey.api.json.JSONConfiguration natural SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not found. For the recent builds to get this working correctly, you need even at least JAXB version 2.1.12. Please add it to your classpath! Apr 05, 2012 10:45:50 AM com.sun.jersey.core.spi.component.ProviderFactory __get ComponentProvider SEVERE: The provider class, class com.marketchorus.rest.config.JAXBContextResolv er, could not be instantiated. Processing will continue but the class will not b e utilized java.lang.RuntimeException: NATURAL JSON notation configured, but JAXB RI 2.1.10 not found. For the recent builds to get this working correctly, you need even a t least JAXB version 2.1.12. Please add it to your classpath!
On the server side, I got the same error, so I installed meto-2.2-standalone in tomcat, which fixed the problem. (Although it worked in java 7).
On a Windows client, I was forced to add JAXB-2.2.5 api, impl and jsr173 jars to my approved java directory in order to make it work (with Java 7 update 3 there too).
When I try to perform a jaxb trick under ubuntu, I put the files in / usr / lib / jvm / java -7-oracle / jre / lib / endorsed. I get another error:
ERROR 10:55:44.694 taskScheduler-1 org.springframework.scheduling.support.TaskUt ils$LoggingErrorHandler - Unexpected error occurred in scheduled task. javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParser Factory not found
I initialize the JAX-RS / JAXB code in my class as follows:
config = new DefaultClientConfig(); config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); config.getClasses().add(JAXBContextResolver.class); client = Client.create(config); service = client.resource(UriBuilder.fromUri(proc.getUrl()).build());
I tried to compile it with source = 1.7 and target = 1.7, as it was still installed for 1.6, and I thought that maybe it was assuming the old version from earlier versions 1.6, which was too old, but that doesnโt solve problem problem.
I ran the @andih test program and I still get the error. I am starting to think that this is a VM problem:
ubuntu@ip-10-202-155-29 :~/test$ java -cp jersey-client-1.12.jar:jersey-core-1.1 2.jar:jersery-fastinfoset-1.12.jar:jersey-json-1.12.jar:. TestNaturalJson Apr 23, 2012 10:17:21 AM com.sun.jersey.api.json.JSONConfiguration natural SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not found. For the recent builds to get this working correctly, you need even at least JAXB version 2.1.12. Please add it to your classpath! Exception in thread "main" java.lang.RuntimeException: NATURAL JSON notation con figured, but JAXB RI 2.1.10 not found. For the recent builds to get this working correctly, you need even at least JAXB version 2.1.12. Please add it to your cl asspath! at com.sun.jersey.api.json.JSONConfiguration.natural(JSONConfiguration.j ava:447) at TestNaturalJson.main(TestNaturalJson.java:6) ubuntu@ip-10-202-155-29 :~/test$ java -version java version "1.7.0_03" Java(TM) SE Runtime Environment (build 1.7.0_03-b04) Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode)
Looking back at the approved solution with JAXB-2.2.5 RI, I installed the files:
jaxb-api.jar jaxb-impl.jar jsr173_1.0_api.jar
in:
/usr/lib/jvm/java-7-oracle/jre/lib/endorsed
Catalog. When I do this, I get the above error from Spring MXParser error. The strange thing here is under the windows, it works, but not on Ubuntu. When I run the @andhi test program below with an approved setting, I get OK instead of an error. But for some reason, it looks like Spring under Ubuntu, does not collect the JSR173 jar file that is installed in the approved directory (which is an STAX implementation).