I am working on Maven-EJB and want to convert a java object to JSON, I use json json lib, but I got:
java.lang.ClassNotFoundException: com.fasterxml.jackson.core.Versioned
I added these dependencies to the 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 these lines for conversion:
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 import:
import com.fasterxml.jackson.core.JsonProcessingException; Import com.fasterxml.jackson.databind.ObjectMapper; Import com.fasterxml.jackson.databind.ObjectWriter;
I checked the path to the classes and made a lot of clean and prefabricated, but could not, the same exception appears !!
I am working on NetBeans8 and Java 1.7
Thanks in advance Mariam
source share