Search code examples
javajsonjacksonjboss7.xresteasy

JsonMappingException$Reference not found when calling a RESTful web service using JBoss 7 and RESTeasy


I have created a RESTful web service producing JSON content with JAX-RS, it uses some JPA entities, it runs on JBoss 7.1.3.

I get the following error message when calling this web service:

13:23:11,834 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/*****WebServices].[com.******.******.rest.config.ApplicationConfig]] (http-/127.0.0.1:8080-2) "Servlet.service()" for the servlet com.******.******.rest.config.ApplicationConfig threw an exception: java.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonMappingException$Reference from [Module "org.codehaus.jackson.jackson-mapper-asl:main" from local module loader @6514af16 (roots: C:**********\jboss-as-7.1.3.Final-bundled4STR\modules)] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:166) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112)

Before trying this solution, I replaced modules\org\codehaus\jackson\jackson-mapper-asl\main\jackson-mapper-asl-1.9.2.jar by a more recent version, I tried with the version 1.9.3 and with the version 1.9.7. It didn't help.

I added org.codehaus.jackson.jackson-mapper-asl into jboss-deployment-structure.xml but it didn't solve my problem.

I know that JBoss includes RESTeasy since its seventh version, at least one provider uses jackson: org.jboss.resteasy.resteasy-jackson-provider.

This kind of error can happen when different versions of the same libraries are used to compile and to run a project but I don't find the culprit. I don't use jackson in my own code.

Does this bug come from JBoss? Is it fixed in a later version? Switching to WildFly isn't an option.


Solution

  • I switched to Wildfly in the meantime for some projects (currently Wildfly 27). I can't confirm whether it's still reproducible with a more recent version of JBoss.