2

Hi I am encountering following error in my glassfish

Warning: A system exception occurred during an invocation on EJB FileUpload, method: public java.lang.String com.sahvidya.ejb.entityoperations.FileUpload.personalFileUploadFromSystem(com.sahvidya.entity.entitysystem.PersonalDirectory,org.primefaces.model.UploadedFile,java.lang.String) throws java.io.IOException


Warning: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.enable([Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/databind/ObjectMapper;

By looking at various blogs I understand glassfish version 4.1 has older jackson library(2.4) which does not have this method and need to upgrade Jakcson version(2.8). I thought of upgrading my glassfish but other issue were encountered. Keeping same glassfish version what would be the way to upgrade jackson version. Just adding updated jackson jar files project will solve the purpose? Will there be not version conflict issue for two jackson version available in project. One from Netbeans and other I have manually added.

alessandrio
  • 4,282
  • 2
  • 29
  • 40

1 Answers1

2

glassfish 4.1.1 does bunde in some jackson jars:

./glassfish/modules/jackson-jaxrs-base.jar
./glassfish/modules/jackson-annotations.jar
./glassfish/modules/jersey-media-json-jackson.jar
./glassfish/modules/jackson-databind.jar
./glassfish/modules/jackson-jaxrs-json-provider.jar
./glassfish/modules/jackson-core.jar

jackson-core.jar is at version 2.3.2 so this is why our glassfish deployed app is getting problems.

Overriding is easy. Add WEB-INF/glassfish-web.xml to your webapp with later jackson dependencies with this content:

<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD 
GlassFish Application Server 3.1 Servlet 3.0//EN" 
"http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
   <class-loader delegate="false"/>
</glassfish-web-app>

Despite the references to 3.1 in DOCTYPE it works fine with 4.1.1.