I am working on Maven-EJB and want to convert a java object to JSON, I use Jackson jars lib but I got:
java.lang.ClassNotFoundException: com.fasterxml.jackson.core.Versioned
I added these dependencies in pom.xml file:
<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-jaxb-annotations</artifactId> <version>2.4.0</version> </dependency> </dependencies>
in Java Facade I write this lines to convert:
String json = "";
try { ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); json = ow.writeValueAsString(userlist); } catch (JsonProcessingException e) { throw new BusinessException("error_json"); }
and here is the imports:
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter;
I checked the classpath and make a lot of clean and build but no way,,,the same exception appear!!
I am working on NetBeans8 and Java 1.7
Thanks in advance Mariam
Thanks Couettos, it works, I checked the versions of application server and the maven jars then I downloaded the latest 2.4.0 jackson jars and upgrade the glassfish lib jars with the 2.4.0 version