Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper [message #1048350] Wed, 24 April 2013 10:44 Go to next message
Pedro Mendoza is currently offline Pedro MendozaFriend
Messages: 5
Registered: April 2013
Junior Member
Hello,

While trying to deploy a Spring MVC web app into Virgo I am getting the following exception that seems to be Jackson related, I have seen some older threads describing a similar issues due to version missmatch between the available Jackson bundles and the Spring Web bundles but it does not seems to be the case for me (see versions below)

I am using ...

OSGi Runtime: Apache Tomcat/7.0.35 on Eclipse Virgo 3.6.1.RELEASE
Virtual Machine: 1.6.0_29 - Java HotSpot(TM) 64-Bit Server VM 20.4-b02 (Sun Microsystems Inc.)
Operating System: Windows 7 6.1 (amd64)

I have downloaded (from SpringSource EBR) and successfully installed using Virgo Console Deployer the com.springsource.org.codehaus.jackson bundles (core and mapper) v1.4.3

Any ideas?

Thanks in advance!,
Pedro

log file:
...
[2013-04-24 12:18:37.117] ERROR start-signalling-9 org.springframework.web.context.ContextLoader Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.view.ContentNegotiatingViewResolver#0' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Cannot create inner bean 'org.springframework.web.servlet.view.json.MappingJacksonJsonView#5d5dbc89' of type [org.springframework.web.servlet.view.json.MappingJacksonJsonView] while setting bean property 'defaultViews' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.view.json.MappingJacksonJsonView#5d5dbc89' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.servlet.view.json.MappingJacksonJsonView]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:125)
at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:109)
at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:122)
at org.eclipse.virgo.kernel.install.artifact.internal.StandardArtifactStateMonitor.onStarted(StandardArtifactStateMonitor.java:271)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStartSucceeded(AbstractInstallArtifact.java:319)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.access$0(AbstractInstallArtifact.java:316)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact$StateMonitorSignal.signalSuccessfulCompletion(AbstractInstallArtifact.java:252)
at org.eclipse.virgo.nano.core.internal.BundleStartTracker$1.run(BundleStartTracker.java:140)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.view.json.MappingJacksonJsonView#5d5dbc89' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.servlet.view.json.MappingJacksonJsonView]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/codehaus/jackson/map/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:270)
... 34 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.servlet.view.json.MappingJacksonJsonView]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:76)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
... 38 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
at org.springframework.web.servlet.view.json.MappingJacksonJsonView.<init>(MappingJacksonJsonView.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 40 common frames omitted
...

manifest.mf:
Manifest-Version: 1.0
Export-Package: com.pbs.gmap.authentication;uses:="
org.springframework.beans.factory.annotation
,org.springframework.security.access.expression
,org.springframework.security.authentication
,org.springframework.security.core
,org.springframework.security.web
,org.springframework.security.web.access.expression"
,com.pbs.gmap.controller;uses:="
com.google.gson
,com.pbs.gmap.pojo
,com.pbs.gmap.util
,javax.servlet.http
,org.springframework.beans.factory.annotation
,org.springframework.stereotype
,org.springframework.ui
,org.springframework.validation
,org.springframework.web.bind.annotation
,org.springframework.web.client,org.springframework.web.servlet"
,com.pbs.gmap.pojo;uses:="
javax.persistence"
,com.pbs.gmap.service;uses:="
com.pbs.gmap.pojo"
,com.pbs.gmap.util;uses:="
com.pbs.gmap.pojo
,org.springframework.beans
,org.springframework.beans.factory.config
,org.springframework.stereotype"
Tool: Bundlor 1.1.2.RELEASE
Import-Package: com.google.gson
,javax.persistence
,javax.servlet,javax.servlet.http
,org.apache.commons.logging
,org.apache.log4j
,org.springframework.security.access.expression
,org.springframework.security.authentication
,org.springframework.security.core
,org.springframework.security.core.authority
,org.springframework.security.core.context
,org.springframework.security.web
,org.springframework.security.web.access.expression
,org.springframework.security.config
,org.springframework.security.web.authentication
,org.codehaus.jackson.map
Import-Library: org.springframework.spring;version="[3.0.0,3.2.0)"
Bundle-SymbolicName: com.pbs.telenor.adminwebapp
Bundle-Version: 1.0.0
Bundle-Name: AdminWebApp
Bundle-Classpath: .,WEB-INF/classes
Web-ContextPath: AdminServices

web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app ...>
<display-name>PB Maps</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>

<!-- <context-param> <param-name>contextConfigLocation</param-name> <param-value>
/WEB-INF/spring-servlet.xml </param-value> </context-param> <listener> <listener-class>
org.springframework.web.context.ContextLoaderListener </listener-class> </listener> -->

<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<!--
<context-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>
-->

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-servlet.xml,
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>



<!-- <servlet> <servlet-name>jersey-serlvet</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param> <param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.mkyong.rest</param-value> </init-param> <init-param> <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value> </init-param> <load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping> <servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern> </servlet-mapping> -->
<!--
<session-config>
<session-timeout>15</session-timeout>
</session-config>
-->

</web-app>

mvc spring context:
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>

<!-- Auto scan the components -->
<bean id="applicationURL" class="com.pbs.gmap.util.ServicesURLProvider">
<constructor-arg
value="${application.url}:${application.port}/${application.deployedApplicationName}" />
</bean>

<bean id="restTemplate" class="org.springframework.web.client.RestTemplate" />
<bean id="gson" class="com.google.gson.Gson" ></bean>
<mvc:annotation-driven />
<context:annotation-config />
<aop:aspectj-autoproxy />

<context:component-scan base-package="com.pbs.gmap" />
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html" />
<entry key="json" value="application/json" />
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean
class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
<property name="prefixJson" value="true" />
</bean>
</list>
</property>
</bean>

<bean id="propertyConfigurer" class="com.pbs.gmap.util.PropertyConfigurer">
<property name="locations">
<list>
<value>classpath:environment.properties</value>
<value>classpath:configuration.properties</value>
</list>
</property>
</bean>

</beans>
Re: java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper [message #1058250 is a reply to message #1048350] Mon, 13 May 2013 11:00 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
http://wiki.eclipse.org/Virgo/FAQ#How_can_I_diagnose_class_loading_problems.3F
Re: java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper [message #1058713 is a reply to message #1058250] Tue, 14 May 2013 18:28 Go to previous messageGo to next message
Pedro Mendoza is currently offline Pedro MendozaFriend
Messages: 5
Registered: April 2013
Junior Member
Hi Glyn,

Thank you for the pointer, really useful tools

I have been trying to reproduce/test the issue (producing JSON content using a Spring MVC app) in a simpler (trivial) app and I am still getting a NoClassDefFoundError for one of the Jackson classes

The first error in the log says ...

[2013-05-14 19:08:37.834] ERROR start-signalling-4 org.springframework.web.servlet.DispatcherServlet Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageAdapter' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Cannot create inner bean 'util:list#322885a2' of type [org.springframework.beans.factory.config.ListFactoryBean] while setting bean property 'messageConverters'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'util:list#322885a2': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonProcessingException

So I tried following Hristos' suggestion and everything seems to be okay in terms of class (org.codehaus.jackson.JsonProcessingException) being exposed and reachable from consumer bundle (com.pbs.telenor.springmvc1), see Virgo console results below ...

export

osgi> clexport org.codehaus.jackson.JsonProcessingException

Bundles exporting [org.codehaus.jackson.JsonProcessingException]:
156 com.springsource.org.codehaus.jackson

load test

osgi> clload org.codehaus.jackson.JsonProcessingException 158

Successfully loaded [org.codehaus.jackson.JsonProcessingException] using class l
oader from:
158 com.pbs.telenor.springmvc1
[provided by 156 com.springsource.org.codehaus.jackson]


package export/import

osgi> vsh:packages examine org.codehaus.jackson 1.4.3

Exporter: com.springsource.org.codehaus.jackson 1.4.3 [156]

Attributes:
None

Directives:
uses:
org.codehaus.jackson.annotate, org.codehaus.jackson.io,
org.codehaus.jackson.type, org.codehaus.jackson.util
x-equinox-ee:
-1
x-internal:
false

Importer(s):
com.springsource.org.codehaus.jackson.mapper 1.4.3 [157]
Import-Package attributes:
bundle-version:
0.0.0
version:
[1.4.3,1.4.3]
Import-Package directives:
resolution:
static
com.pbs.telenor.springmvc1 1.0.0 [158]
Import-Package attributes:
bundle-version:
0.0.0
version:
0.0.0
Import-Package directives:
resolution:
static

The "trivial" Spring MVC manifest looks like ...

Manifest-Version: 1.0
Export-Package: com.pbs.telenor.springmvc1;uses:="org.springframework.stereotype,
org.springframework.ui,org.springframework.web.bind.annotation"
Tool: Bundlor 1.1.2.RELEASE
Import-Package: com.pbs.telenor.nameprovider
,org.apache.log4j
,org.slf4j
,org.apache.taglibs.standard.tlv
,org.apache.taglibs.standard.tei
,org.eclipse.virgo.web.dm
,org.codehaus.jackson
Import-Library: org.springframework.spring;version="[3.0.0,3.2.0)"
Bundle-SymbolicName: com.pbs.telenor.springmvc1
Bundle-Version: 1.0.0
Bundle-Name: springmvc1
Bundle-Classpath: .,WEB-INF/classes
Web-ContextPath: springmvc1


And the Spring MVC context file is as follows ...

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns=...>

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="com.pbs.telenor.springmvc1" />

<beans:bean id="messageAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<beans:property name="messageConverters">
<util:list>
<!-- Support JSON -->
<beans:bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
</util:list>
</beans:property>
</beans:bean>
</beans:beans>

I continue to try to dig out but if you have any other clue, will be much appreciated

Thanks!,
Pedro
Re: java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper [message #1058744 is a reply to message #1058713] Tue, 14 May 2013 20:05 Go to previous messageGo to next message
Pedro Mendoza is currently offline Pedro MendozaFriend
Messages: 5
Registered: April 2013
Junior Member
Hi All,

Now fixed following Maarten's advise to drop Jackson bundles into repository/usr instead of manually installing using AdminConsole

Looks like the relative order of Jackson bundles and Spring Web makes the difference?

See http://www.eclipse.org/forums/index.php/mv/msg/487375/1058737/#msg_1058737

Thanks!
Re: java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper [message #1058813 is a reply to message #1058744] Wed, 15 May 2013 08:38 Go to previous message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Glad you are sorted.
Previous Topic:How to tell virgo to deploy my configurations first with eclipse tooling?
Next Topic:virgo server cannot start
Goto Forum:
  


Current Time: Fri Nov 28 12:46:02 GMT 2014

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

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