Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Problem with Virgo 3.6.4 + Spring 3.1.3 + Jackson 2
Problem with Virgo 3.6.4 + Spring 3.1.3 + Jackson 2 [message #1751093] Wed, 04 January 2017 12:33 Go to next message
Matteo Cantarelli is currently offline Matteo CantarelliFriend
Messages: 26
Registered: June 2012
Junior Member
Hello and happy new year!

We have recently had to update some libraries in our application which as a consequence required us to move to Jackson 2.
In order to get Spring 3.1.0 (shipped with Virgo 3.6.4) to work with Jackson 2 following different posts we have added the following configuration to our app-config.xml

<mvc:annotation-driven>
		<mvc:message-converters>
			<bean
				class="org.geppetto.frontend.controllers.MappingJackson2HttpMessageConverter">
				<property name="objectMapper">
					<bean class="org.geppetto.frontend.controllers.GeppettoObjectMapper" />
				</property>
			</bean>
		</mvc:message-converters>
	</mvc:annotation-driven>


which specifies a custom converter which in turns uses Jackson 2.
The above worked and we moved on with our lives.
After weeks I have however found a problem. If in the pickup folder we don't have the JARs for the admin console

org.eclipse.virgo.management.console_3.6.4.RELEASE
org.eclipse.virgo.apps.splash_3.6.4.RELEASE.jar
org.eclipse.virgo.apps.repository_3.6.4.RELEASE.par


(which we don't for production deployments) the above configuration stops to work throwing the following exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#8': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
	... 40 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
	... 44 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
	at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.<init>(MappingJackson2HttpMessageConverter.java:55)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)


the MANIFEST file looks like this


Manifest-Version: 1.0
Bnd-LastModified: 1483531510490
Build-Jdk: 1.7.0_51
Built-By: matteocantarelli
Bundle-ClassPath: .,WEB-INF/classes
Bundle-ManifestVersion: 2
Bundle-Name: Geppetto Frontend
Bundle-SymbolicName: org.geppetto.frontend
Bundle-Version: 0.3.3
Created-By: Apache Maven Bundle Plugin
Export-Package: org.geppetto.frontend;uses:="org.springframework.context
 ,org.springframework.context.event";version="0.3.3",org.geppetto.fronte
 nd.controllers;uses:="org.geppetto.core.data,org.geppetto.core.data.mod
 el,org.apache.commons.logging,org.apache.shiro,org.springframework.bean
 s.factory.annotation,org.apache.shiro.subject,org.geppetto.core.utiliti
 es,org.springframework.web.bind.annotation,org.geppetto.core.manager,or
 g.geppetto.core.common,org.geppetto.core.auth,org.springframework.stere
 otype,com.google.gson,org.geppetto.frontend.tests,javax.servlet.http,or
 g.osgi.framework,org.geppetto.model.util,org.geppetto.model.datasources
 ,org.geppetto.core.datasources,org.eclipse.emf.ecore,org.geppetto.core.
 services.registry,org.geppetto.frontend,org.geppetto.simulation.manager
 ,org.geppetto.core.beans,org.geppetto.frontend.messages,com.fasterxml.j
 ackson.databind,com.fasterxml.jackson.core.type,org.geppetto.core.simul
 ation,org.geppetto.core.model,com.fasterxml.jackson.core,org.geppetto.m
 odel,org.apache.catalina.websocket,org.apache.shiro.authc,org.apache.sh
 iro.realm,javax.servlet,org.springframework.http.converter,org.springfr
 amework.util,org.springframework.http,com.google.gson.reflect,org.eclip
 se.emf.common.util,org.springframework.context,org.geppetto.frontend.me
 ssaging,org.springframework.web.context.support";version="0.3.3",org.ge
 ppetto.frontend.dashboard.service;uses:="org.geppetto.core.data,org.gep
 petto.core.data.model,org.springframework.beans.factory.annotation,org.
 springframework.core.io,org.geppetto.core.utilities,org.springframework
 .web.bind.annotation,org.geppetto.core.manager,org.geppetto.core.common
 ,org.geppetto.core.beans,org.springframework.stereotype,org.geppetto.si
 mulation.visitor,org.geppetto.model.util,org.geppetto.core.model,org.ec
 lipse.emf.ecore.util,org.eclipse.emf.ecore,org.geppetto.model,org.apach
 e.commons.logging,org.apache.shiro,org.apache.shiro.subject";version="0
 .3.3",org.geppetto.frontend.messages;uses:="org.geppetto.frontend,com.g
 oogle.gson";version="0.3.3",org.geppetto.frontend.messaging;uses:="org.
 apache.commons.logging,org.geppetto.frontend.messages,org.apache.catali
 na.websocket,com.google.gson";version="0.3.3",org.geppetto.frontend.tes
 ts;uses:="com.google.gson.annotations";version="0.3.3"
Import-Bundle: org.springframework.aop;version="3.1.3.RELEASE"
Import-Library: org.springframework.spring;version="3.1.3.RELEASE"
Import-Package: com.fasterxml.jackson.core;version="[2.8,3)",com.fasterx
 ml.jackson.core.type;version="[2.8,3)",com.fasterxml.jackson.databind;v
 ersion="[2.8,3)",com.google.gson;version="[2.2,3)",com.google.gson.anno
 tations;version="[2.2,3)",com.google.gson.reflect;version="[2.2,3)",jav
 ax.servlet;version="[2.4,3)",javax.servlet.http;version="[2.4,3)",net.s
 f.cglib.beans;version="[2.2,3)",net.sf.cglib.core;version="[2.2,3)",net
 .sf.cglib.proxy;version="[2.2,3)",net.sf.cglib.reflect;version="[2.2,3)
 ",net.sf.cglib.transform;version="[2.2,3)",net.sf.cglib.util;version="[
 2.2,3)",org.apache.catalina.websocket,org.apache.commons.logging;versio
 n="[1.1,2)",org.apache.shiro;version="[1.2,2)",org.apache.shiro.authc;v
 ersion="[1.2,2)",org.apache.shiro.realm;version="[1.2,2)",org.apache.sh
 iro.subject;version="[1.2,2)",org.apache.shiro.web.env;version="[1.2,2)
 ",org.apache.shiro.web.servlet;version="[1.2,2)",org.eclipse.emf.common
 .util,org.eclipse.emf.ecore,org.eclipse.emf.ecore.util,org.eclipse.virg
 o.web.dm;version="2.1.1.RELEASE",org.geppetto.core.auth;version="[0.3,1
 )",org.geppetto.core.beans;version="[0.3,1)",org.geppetto.core.common;v
 ersion="[0.3,1)",org.geppetto.core.data;version="[0.3,1)",org.geppetto.
 core.data.model;version="[0.3,1)",org.geppetto.core.datasources;version
 ="[0.3,1)",org.geppetto.core.manager;version="[0.3,1)",org.geppetto.cor
 e.model;version="[0.3,1)",org.geppetto.core.s3;version="[0.3,1)",org.ge
 ppetto.core.services.registry;version="[0.3,1)",org.geppetto.core.simul
 ation;version="[0.3,1)",org.geppetto.core.utilities;version="[0.3,1)",o
 rg.geppetto.model;version="[0.3,1)",org.geppetto.model.datasources;vers
 ion="[0.3,1)",org.geppetto.model.util;version="[0.3,1)",org.geppetto.si
 mulation;version="[0.3,1)",org.geppetto.simulation.manager;version="[0.
 3,1)",org.geppetto.simulation.visitor;version="[0.3,1)",org.osgi.framew
 ork;version="[1.7,2)",org.springframework.beans.factory.annotation;vers
 ion="[3.1,4)",org.springframework.context;version="[3.1,4)",org.springf
 ramework.context.event;version="[3.1,4)",org.springframework.core.io;ve
 rsion="[3.1,4)",org.springframework.http;version="[3.1,4)",org.springfr
 amework.http.converter;version="[3.1,4)",org.springframework.stereotype
 ;version="[3.1,4)",org.springframework.util;version="[3.1,4)",org.sprin
 gframework.web.bind.annotation;version="[3.1,4)",org.springframework.we
 b.context.support;version="[3.1,4)"
Tool: Bnd-1.50.0
Web-ContextPath: org.geppetto.frontend


It seems to me a problem maybe related to the order bundle gets loaded in, having the virgo console in the pickup folder somehow seems to ensure the correct order. Reading some of the posts on here related to similar situations I tried to copy the jackson JARs in the repository/ext folder but it didn't help.
I know newer versions of Spring will take care of this since they use Jackson 2 but that's too much of a transition right now and I'd like to find a way to get this to work.
Does anyone have suggestions? Thanks a lot in advance.

Best,
Matteo

[Updated on: Wed, 04 January 2017 12:34]

Report message to a moderator

Re: Problem with Virgo 3.6.4 + Spring 3.1.3 + Jackson 2 [message #1751097 is a reply to message #1751093] Wed, 04 January 2017 13:00 Go to previous messageGo to next message
Matteo Cantarelli is currently offline Matteo CantarelliFriend
Messages: 26
Registered: June 2012
Junior Member
To be more precise even with the virgo console in the pickup folder the first time I have the same error. From the second time on after I start the server the error disappears. Looks as if once the virgo console is loaded in the virgo work folder there is something copied that makes it so that ObjectMapper is found.

[Updated on: Wed, 04 January 2017 13:00]

Report message to a moderator

Re: Problem with Virgo 3.6.4 + Spring 3.1.3 + Jackson 2 [message #1751099 is a reply to message #1751097] Wed, 04 January 2017 13:10 Go to previous messageGo to next message
GianMaria Romanato is currently offline GianMaria RomanatoFriend
Messages: 49
Registered: November 2015
Member
Ciao Matteo,

it could be that somehow the console activates the Jackson bundle while this is not happening if the console is not present.

Could you try the following:


  1. Edit $VIRGO_HOME/repository/ext osgi.console.properties and make sure that telnet console is enabled
  2. Start Virgo with the console enabled, and test that Jackson is being used as expected
  3. type "telnet localhost 2501" to access the telnet console. If on Windows, you may want to download putty for that.
  4. From the OSGi console prompt type "ss ckson" which will list all bundles containing "ckson" in their symbolic name
  5. Once you have found the Jackson bundle note its numeric identifier, type "bundle <number>" to see the details of the Jackson bundle


Repeat steps 3-5 without the Virgo console and look for differences. For example, without the console Jackson may be installed but not resolved/started. In such case, you may want to add a dummy dependency in one of your bundles toward Jackson (e.g. import any Jackson package) or add Jackson to your plan to make sure it's started.

Hope this helps.

GianMaria.


PS: May I add Geppetto to the list of "Virgo Powered" applications on the Virgo home page?
Re: Problem with Virgo 3.6.4 + Spring 3.1.3 + Jackson 2 [message #1751110 is a reply to message #1751099] Wed, 04 January 2017 14:41 Go to previous messageGo to next message
Matteo Cantarelli is currently offline Matteo CantarelliFriend
Messages: 26
Registered: June 2012
Junior Member
Ciao GianMaria,

Thanks for this.
I've done what you suggested, I can't spot any meaningful difference myself but here are the two outputs and their diff:

https://gist.github.com/tarelli/443162edf2497e56ee42e2e32bd98f38

Of course you can list Geppetto, we have been using Virgo since the very beginning Smile

Best,
Matteo
Re: Problem with Virgo 3.6.4 + Spring 3.1.3 + Jackson 2 [message #1751118 is a reply to message #1751110] Wed, 04 January 2017 15:14 Go to previous messageGo to next message
GianMaria Romanato is currently offline GianMaria RomanatoFriend
Messages: 49
Registered: November 2015
Member
Hi Matteo,

I don't see any meaningful difference either.
I had a quick look into the console bundles looking for com.fasterxml references and for any META-INF/services file that could trigger registration of Jackson but I could not find any.

Did you try to force a dependency toward jackson? For example, by adding relevant packages to Import-Package?

Giamma.

Re: Problem with Virgo 3.6.4 + Spring 3.1.3 + Jackson 2 [message #1751129 is a reply to message #1751118] Wed, 04 January 2017 17:31 Go to previous messageGo to next message
Matteo Cantarelli is currently offline Matteo CantarelliFriend
Messages: 26
Registered: June 2012
Junior Member
I did try that but it didnt make a difference. Also even without forcing it through Apache Felix the import package is added, see above in the manifest:

Import-Package: com.fasterxml.jackson.core;version="[2.8,3)",com.fasterx
 ml.jackson.core.type;version="[2.8,3)",com.fasterxml.jackson.databind;v
 ersion="[2.8,3)",
...
Re: Problem with Virgo 3.6.4 + Spring 3.1.3 + Jackson 2 [message #1751444 is a reply to message #1751129] Tue, 10 January 2017 12:56 Go to previous message
Matteo Cantarelli is currently offline Matteo CantarelliFriend
Messages: 26
Registered: June 2012
Junior Member
Still no progress, trying to update to Virgo 3.7.M03 and bite the bullet of migrating SpringDM -> BluePrint and Spring 3.1.1 -> Spring 4.2.4
Previous Topic:External Integration of 3rd party non OSGI jars
Next Topic:Virgo 3.7.0 M02
Goto Forum:
  


Current Time: Wed Nov 14 23:30:48 GMT 2018

Powered by FUDForum. Page generated in 0.02344 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top