View Full Version : Custom context class [com.springsource.server.web.dm.ServerOsgiBundleXml WebApplicatio
cmoulliard
Dec 8th, 2008, 09:14 AM
Hi,
When I deploy my WAR in Spring DM 1.2.0-m2, I receive the following error :
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E org.springframework.context.ApplicationContextExce ption: Custom context class [com.springsource.server.web.dm.ServerOsgiBundleXml WebApplicationContext] is not of type [org.springframework.web.context.ConfigurableWebApp licationContext]
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:232)
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:189)
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3843)
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4342)
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:791)
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:771)
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:525)
[2008-12-08 15:55:07.322] async-delivery-thread-1 System.err E at com.springsource.server.servlet.tomcat.TomcatServl etContainer.addContext(TomcatServletContainer.java :948)
Here is my web.xml config file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Camel Mail Example</display-name>
<description>Camel Mail sample application</description>
<context-param>
<param-name>contextClass</param-name>
<param-value>com.springsource.server.web.dm.ServerOsgiBundleXml WebApplicationContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:camel-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/webservices/*</url-pattern>
</servlet-mapping>
</web-app>
and MANIFEST file
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Camel RerportIncident WAR
Bundle-SymbolicName: org.camel.example.reportincident.web
Bundle-Version: 1.0.0
Import-Package: org.apache.camel.example.reportincident.domain,
org.apache.camel.example.reportincident
Import-Bundle: org.apache.camel.example.reportincident.domain,
org.apache.camel.example.reportincident.service
How can I solve this ?
KR,
Charles Moulliard
SOA Architect
Andy Wilkinson
Dec 9th, 2008, 08:01 AM
It should be possible to deploy a standard WAR file to dm Server without having to have anything dm Server specific in your web.xml: e.g., there should be no need to specify a custom context class.
Have you tried deploying your WAR without specifying the dm Server type as a custom context class in your web.xml?
cmoulliard
Dec 9th, 2008, 08:22 AM
Hi,
Do you mean "removing the following lines from my web.xml file"
<context-param>
<param-name>contextClass</param-name>
<param-value>com.springsource.server.web.dm.ServerOsgiBun dleXmlWebApplicationContext</param-value>
</context-param>
?
By the way, I have tested my WAR without this context-param but I have the following error :
[2008-12-08 15:47:40.088] async-delivery-thread-1 catalina].[localhost].[/reportincident.web-1.0-SNAPSHOT].unknown E Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'reportIncidentEndpoint': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Required 'bundleContext' property was not set.
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1337)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:221)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:729)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:381)
at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:189)
at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:525)
at com.springsource.server.servlet.tomcat.TomcatServl etContainer.addContext(TomcatServletContainer.java :948)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.osgi.service.importer.support. internal.aop.ServiceInvoker.doInvoke(ServiceInvoke r.java:64)
at org.springframework.osgi.service.importer.support. internal.aop.ServiceInvoker.invoke(ServiceInvoker. java:78)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.osgi.service.importer.support. LocalBundleContextAdvice.invoke(LocalBundleContext Advice.java:59)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy43.addContext(Unknown Source)
at com.springsource.server.web.core.WebModulePersonal ity.deploy(WebModulePersonality.java:391)
at com.springsource.server.deployer.core.module.Abstr actModule.deploy(AbstractModule.java:235)
at com.springsource.server.deployer.core.module.Stand ardModule.onStarted(StandardModule.java:572)
at com.springsource.server.deployer.core.module.Deplo yerBundleListener$2$1.run(DeployerBundleListener.j ava:148)
at com.springsource.server.concurrent.core.ExecutorSe rviceDelegate$StatisticsGatheringRunnable.run(Exec utorServiceDelegate.java:137)
at com.springsource.server.concurrent.core.ServerThre adPoolExecutor$1.run(ServerThreadPoolExecutor.java :145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
KR,
Charles
Andy Wilkinson
Dec 9th, 2008, 08:35 AM
Hi,
Do you mean "removing the following lines from my web.xml file"
<context-param>
<param-name>contextClass</param-name>
<param-value>com.springsource.server.web.dm.ServerOsgiBun dleXmlWebApplicationContext</param-value>
</context-param>
?
Sorry, I should have been clearer. Yes, that's what I meant.
By the way, I have tested my WAR without this context-param but I have the following error :
[2008-12-08 15:47:40.088] async-delivery-thread-1 catalina].[localhost].[/reportincident.web-1.0-SNAPSHOT].unknown E Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'reportIncidentEndpoint': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Required 'bundleContext' property was not set.
Aah, ok. I'd guess from that, that you're using Spring DM in your camel-context.xml file. Is that the case? Could you post your camel-context.xml file to help narrow things down?
cmoulliard
Dec 9th, 2008, 08:54 AM
Here is the Camel (Spring) xml file :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd
http://activemq.apache.org/camel/schema/cxfEndpoint http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<!-- reference to the OSGI service -->
<osgi:reference id="reportIncidentEndpoint" interface="org.apache.camel.example.reportincident.ReportInci dentService"/>
<!-- implementation of the webservice -->
<cxf:cxfEndpoint id="reportIncident" address="/incident" wsdlURL="/WEB-INF/wsdl/report_incident.xml"
serviceClass="#reportIncidentEndpoint"
endpointName="s:ReportIncidentPort"
serviceName="s:ReportIncidentService"
xmlns:s="http://reportincident.example.camel.apache.org"
/>
<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<package>org.apache.camel.example.reportincident</package>
<jmxAgent id="agent" createConnector="true"/>
</camelContext>
</beans>
KR,
Charles
Andy Wilkinson
Dec 9th, 2008, 09:26 AM
Thanks. I think I know what the problem is now.
I can see from your application context that you're using a Spring DM, and that you're importing a service from the OSGi service registry. This means that your WAR is, in fact, a shared services WAR (http://static.springsource.com/projects/dm-server/1.0.x/programmer-guide/html/ch04.html#architecture-shared-services-war).
In a shared services WAR file, it's correct to have the custom context class specified as support for shared services WARs is dm Server-specific. This means that you should have the following in your web.xml:
<context-param>
<param-name>contextClass</param-name>
<param-value>com.springsource.server.web.dm.ServerOsgiBundleXml WebApplicationContext</param-value>
</context-param>
So, we need to step back a bit and look at the original error that stated:
Custom context class [com.springsource.server.web.dm.ServerOsgiBundleXml WebApplicationContext] is not of type [org.springframework.web.context.ConfigurableWebApp licationContext]
This message is rather telling as ServerOsgiBundleXmlWebApplicationContext does implement the ConfigurableWebApplicationContext interface. For Spring to believe that it does not indicates that the class space being used by Spring is not consistent with the class space being used by your application, i.e. there are two different ConfigurableWebApplicationContext classes.
Looking at your MANIFEST.MF that you posted above, I can see that you're not importing Spring into your shared services WAR so, I presume, you've packaged it in WEB-INF/lib? This will mean that your application is using one copy of the Spring, and the dm Server is using another copy. Rather than packaging Spring in WEB-INF/lib, you should import it into your shared services WAR by updating your WAR's manifest. The easiest way to do this is to use the Import-Library manifest header. E.g.:
Import-Library: org.springframework.spring;version="[2.5.5,3.0.0)"
Hopefully making this change should resolve your problem.
You may be interesting in the formtags sample application (http://dist.springsource.com/release/SAMPL/formtags-1.4.0.RELEASE.zip), which provides an example of shared services WAR.
cmoulliard
Dec 9th, 2008, 09:40 AM
You are right. I have packaged the Spring jarsin my WAR. I will remove them, add the import-library syntax in the MANIFEST file and re-deploy.
Many thanks for your verbose reply and the quality of your explanation.
KR,
Charles Moulliard
cmoulliard
Dec 9th, 2008, 09:50 AM
Great, it works.
I have another error but this is not at all related to Spring DM.
By the way, if you are interested, you can have a look to my tutorial on Camel + Spring DM (first part published). I'm currently working on the second :
- http://cwiki.apache.org/confluence/display/CAMEL/tutorials
- http://cwiki.apache.org/confluence/display/CAMEL/tutorial-osgi-camel-part1
KR,
Charles Moulliard
SOA Architect
cmoulliard
Dec 10th, 2008, 07:32 AM
Hi,
I have a new error reported by the BundleDelegatingClassLoader. This looks strange for me because the class mentioned is part of Spring DM Serevr/Tomcat.
What is the reason of this error and how can I avoid it ?
System.err E INFO: JMX Connector thread started and listening at: service:jmx:rmi:///jndi/rmi://dell-charles:1099/jmxrmi/camel
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E 10-déc.-2008 12:44:39 org.apache.camel.management.DefaultInstrumentation Agent$1 run
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E ATTENTION: Could not start JMXConnector thread.
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E java.io.IOException: Cannot bind to URL [rmi://dell-charles:1099/jmxrmi/camel]: javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory not found from bundle [org.camel.example.reportincident.web]]
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E at javax.management.remote.rmi.RMIConnectorServer.new IOException(RMIConnectorServer.java:804)
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E at javax.management.remote.rmi.RMIConnectorServer.sta rt(RMIConnectorServer.java:417)
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E at org.apache.camel.management.DefaultInstrumentation Agent$1.run(DefaultInstrumentationAgent.java:344)
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory not found from bundle [org.camel.example.reportincident.web]]
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:657)
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:288)
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E at javax.naming.InitialContext.init(InitialContext.ja va:223)
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E at javax.naming.InitialContext.<init>(InitialContext.java:197)
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E at javax.management.remote.rmi.RMIConnectorServer.bin d(RMIConnectorServer.java:619)
[2008-12-10 12:44:39.328] arles:1099/jmxrmi/camel] System.err E at javax.management.remote.rmi.RMIConnectorServer.sta rt(RMIConnectorServer.java:412)
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E ... 1 more
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E Caused by: java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory not found from bundle [org.camel.example.reportincident.web]
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E at org.springframework.osgi.util.BundleDelegatingClas sLoader.findClass(BundleDelegatingClassLoader.java :103)
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E at org.springframework.osgi.util.BundleDelegatingClas sLoader.loadClass(BundleDelegatingClassLoader.java :156)
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E at java.lang.Class.forName0(Native Method)
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E at java.lang.Class.forName(Class.java:247)
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E at com.sun.naming.internal.VersionHelper12.loadClass( VersionHelper12.java:46)
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:654)
[2008-12-10 12:44:39.343] arles:1099/jmxrmi/camel] System.err E ... 6 more
KR,
Charles Moulliard
SOA Architect
Andy Wilkinson
Dec 10th, 2008, 08:03 AM
Hi Charles,
My guess is that you're missing an import for org.apache.naming.java package in the manifest of your org.camel.example.reportincident.web bundle.
- Andy.
cmoulliard
Dec 10th, 2008, 08:48 AM
You are right. I forget to add in the manifest file the following line : import-bundle: com.springsource.org.apache.catalina.
everything is ok now
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.