11 Replies Latest reply: Nov 20, 2009 4:46 PM by Ivan Yuan RSS

Unabled to return specified bean factory in web application

Ivan Yuan Newbie

Hi,

I am using jboss JBoss 4.2.2GA release, and want to deploy some common spring beans and make them available to all other web services or EJBs within same jboss environment.

It seems that jboss spring deployer is a good choice. I downloaded deployer version 2, then created some simple test. The MySrpingBean.spring can be deployed on jboss properly proved by the following lines in jboss log:
Bean factory [MySpringBean] binded to local JNDI

And I also saw the following information from jboss jmx-console JNDI view:

MySpringBean
org.jboss.spring.factory.NamedXmlApplicationContext


Basically, all above indicated my spring has been deployed and registered into local JDNI.

However, when I created a simple web application to retrieve it. I got the following exception:

org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [mainApplicationContext], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mainApplicationContext' is defined

at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:410)

at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:341)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:195)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)

at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)

at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)

at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)

at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)

at org.jboss.web.WebModule.startModule(WebModule.java:83)

at org.jboss.web.WebModule.startService(WebModule.java:61)

at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)

at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)

at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)

at $Proxy0.start(Unknown Source)

at org.jboss.system.ServiceController.start(ServiceController.java:417)

at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)

at $Proxy45.start(Unknown Source)

at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)

at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)

at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)

at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)

at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)

at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)

at $Proxy46.start(Unknown Source)

at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)

at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)

at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)

at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)

at $Proxy9.deploy(Unknown Source)

at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)

at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)

at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)

at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)

at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)

at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)

at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)


There is no detailed information about how to retrieve the deployed bean from web service. Not sure where I did wrong. Here is how I did.

my web.xml file is as below:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


 <context-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>classpath*:*.xml</param-value>
 </context-param>

 <context-param>
 <param-name>parentContextKey</param-name>
 <param-value>mainApplicationContext</param-value>
 </context-param>
 <listener>
 <listener-class>
 org.springframework.web.context.ContextLoaderListener
 </listener-class>
 </listener>
 <servlet>
 <display-name>JAX-RS REST Servlet</display-name>
 <servlet-name>JAX-RS REST Servlet</servlet-name>
 <servlet-class>
 org.apache.cxf.transport.servlet.CXFServlet
 </servlet-class>
 <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
 <servlet-name>JAX-RS REST Servlet</servlet-name>
 <url-pattern>/services/*</url-pattern>
 </servlet-mapping>
 <welcome-file-list>
 <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app>


And my spring context in web application is as below:
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:jaxrs="http://cxf.apache.org/jaxrs"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:jee="http://www.springframework.org/schema/jee"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
 http://cxf.apache.org/jaxrs
 http://cxf.apache.org/schemas/jaxrs.xsd
 http://www.springframework.org/schema/aop
 http://www.springframework.org/schema/aop/spring-aop.xsd
 http://www.springframework.org/schema/jee
 http://www.springframework.org/schema/jee/spring-jee-2.0.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" />
 <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>

 <!-- retrieve spring factory MySpringBean from JNDI and it is referenced in my web.xml file -->
 <jee:jndi-lookup id="mainApplicationContext" jndi-name="MySpringBean"/>

<!-- mySrpingBean is the bean reference name defined in the deployed spring context -->
<bean id="testAdapter" class="com.iseemedia.test.common.TestAdapter">
 <property name="myBean" ref="mySpringBean"/>

 <bean id="testWebService"
class="com.iseemedia.test.webservice.TestWS">
 <property name="adapter" ref="testAdapter"/>
 </bean>

 <jaxrs:server id="testWSEndpoint" address="/">
 <jaxrs:serviceBeans>
 <ref bean="testWebService"/>
 </jaxrs:serviceBeans>
 </jaxrs:server>
</beans>


I'm struggling on this problem for a while. Can you please take? Any suggestion or advice will be really appreciated.

Thank you in advance!




  • 1. Re: Unabled to return specified bean factory in web applicat
    Ales Justin Master

    My first guess would be that you're using jndi-lookup wrong.
    Dunno otherwise why it would call your mainAppContext a bean here:


    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mainApplicationContext' is defined


  • 2. Re: Unabled to return specified bean factory in web applicat
    Ivan Yuan Newbie

    Thank you so much for the quick reply.

    I have same feeling about JDNI lookup. But what is the correct way to retrieve it?

    Is there any example of retrieving deployed bean from web app?


    Thanks,
    Ivan

  • 3. Re: Unabled to return specified bean factory in web applicat
    Marius Bogoevici Expert

    Hi Ivan,

    Try creating an xml called beanRefContext.xml and place it on the classpath - eg. inside WEB-INF/classes - you need that for the ContextSingletonBeanFactoryLocator.

    Place your
    <jee:jndi-lookup id="mainApplicationContext" jndi-name="MySpringBean"/>
    element inside that xml and remove it from the web context definition.

    BTW - using classpath*:*.xml may not be such a good idea, since the XmlWebApplicationContext will try to use any xml on the classpath as a Spring definition (at the very least, try to create a pattern that is somehow unique to your application). For example, in this case it will load beanRefContext.xml too (which is completely useless, albeit inoffensive).

    Cheers,
    Marius




  • 4. Re: Unabled to return specified bean factory in web applicat
    Ivan Yuan Newbie

    Marius,

    Thank you so much. With the changes as you suggested, I am moving forward one more step further, but still got the following exception.

    [CODE]
    2009-11-19 20:15:58,943 INFO [STDOUT] 20:15:58,943 ERROR [ContextLoader] Context initialization failed

    org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [mainApplicationContext], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'mainApplicationContext' must be of type [org.springframework.beans.factory.BeanFactory], but was actually of type [org.jboss.spring.factory.NamedXmlApplicationContext]

    at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:410)

    at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:341)

    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:195)

    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)

    [/CODE]

    The bean factory retrieved from JNDI is not the expected type. As I mentioned in the original request, the binded bean in JNDI by spring deployer is
    [CODE]
    MySpringBean
    org.jboss.spring.factory.NamedXmlApplicationContext
    [/CODE]

    Why the spring deployed put NamedXmlApplicationContext into JNDI instead of Spring Bean factory? Did I do something wrong? Or there is any special configuration needed in my jboss-spring.xml (the spring context file of my spring archive)?

    Thanks,
    Ivan

  • 5. Re: Unabled to return specified bean factory in web applicat
    Marius Bogoevici Expert

    OK, so we solved the parent application context lookup problem.

    The next one is a classloader problem: org.springframework.beans.factory.BeanFactory is an interface and org.jboss.spring.factory.NamedXmlApplicationContext implements it, but I suspect you also have Spring bundled inside your war and that confuses the classloader.

    One thing I would try would be to remove the spring jars from both the deployer and the war and put them in your /lib folder (e.g. default/lib or whatever). Thus, both the deployer and your web application will use the same version of the classes (in the CL sense).

    Hope that helps,
    Marius

  • 6. Re: Unabled to return specified bean factory in web applicat
    Ivan Yuan Newbie

    Marius,

    Yes, it is the class-loader version problem. I put all spring jars into default/lib, but still run into exceptions. Here are what I did.

    The spring deployer contained the following jars:

    jboss-spring-jdk5.jar
    spring-aop.jar
    spring-beans.jar
    spring-context.jar
    spring-core.jar
    


    And I moved spring-*.jar files (except jboss-spring-jdk5.jar) to default/lib, and also removed all spring jar files away from my web application archive test-spring-web-service.war. I got the following exception during deploying my test web application:
    [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/test-spring-web-service]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    
    java.lang.NoSuchMethodError: org.springframework.core.CollectionFactory.createConcurrentMapIfPossible(I)Ljava/util/Map;
    
     at org.springframework.web.context.ContextLoader.<clinit>(ContextLoader.java:153)
    
     at org.springframework.web.context.ContextLoaderListener.createContextLoader(ContextLoaderListener.java:53)
    
     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:44)
    
     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
    
     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
    


    I am using CXF in my web service, and thought it might be spring version was too lower, then I replaced the spring jars in default/lib with spring 2.5.5 version. Then I got the following exception during deploying my spring archive:
    META-INF/jboss-spring.xml]; nested exception is java.lang.NoSuchMethodError: org.jboss.spring.factory.NamedXmlBeanDefinitionReader.createReaderContext(Lorg/springframework/core/io/Resource;)Lorg/springframework/beans/factory/support/ReaderContext;; - nested throwable: (org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [jar:file:/C:/jboss-4.2.2.GA/server/default/tmp/deploy/tmp5661233983148309170MySpringBean.spring!/META-INF/jboss-spring.xml]; nested exception is java.lang.NoSuchMethodError: org.jboss.spring.factory.NamedXmlBeanDefinitionReader.createReaderContext(Lorg/springframework/core/io/Resource;)Lorg/springframework/beans/factory/support/ReaderContext;)
    
     at org.jboss.spring.deployment.SpringDeployer.create(SpringDeployer.java:120)
    
     at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
    
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
    
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    
     at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
    
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    
     at java.lang.reflect.Method.invoke(Method.java:585)
    
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    
     at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    


    Based on my tests, it seems that the spring deployer (2.x) only work with certain versions (older versions) of spring. I need to use spring 2.5.5. How can I solve the exceptions? Which version of spring deployer should I use?

    Thanks a lot!
    Ivan Yuan

  • 7. Re: Unabled to return specified bean factory in web applicat
    Ivan Yuan Newbie

    Hi Marius,

    I did more testing. The problem is becoming more specific.

    I tried both spring deployer release 2 and release 3.
    It contains

    jboss-spring-jdk5.jar
    spring-aop.jar
    spring-beans.jar
    spring-context.jar
    spring-core.jar
    


    I am not clear which version of the spring framework come along with depoyer (say version 3). After I replaced spring jars in default/lib with them, it is okay to deploy my spring archive. However it doesn't work with spring-web.jar, which come from spring framework package. It seems the the spring-web.jar (from spring framework) and other spring jar files (from deployer) are incompatible. Can you please tell me which spring-web.jar work well with spring jar files (along with spring deployer release 3)?

    I also replaced spring jar files with spring framework 2.5.5 or 2.0.8 or 1.0.8, it turns out the spring deployer couldn't find DefaultXmlBeanDefinitionParser.
    java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/DefaultXmlBeanDefinitionParser
    


    Yes, DefaultXmlBeanDefinitionParser doesn't exist in any of above spring frameworks. It seems that the spring jar files in the deployer are customized somehow. Can you verify that as well? How can I solve this incompatible problem?


    Thanks,



  • 8. Re: Unabled to return specified bean factory in web applicat
    Marius Bogoevici Expert

    Ivan,

    For 4.2 you need to use the 2.x version of the deployer (version 3.x works with AS5).
    Also, it seems like you are using a relatively old version of the deployer (that's what causes the NoClassDefFoundError).
    Please make sure that you're using latest deployer (2.1) , which is to be found here:

    http://sourceforge.net/projects/jboss/files/JBoss-Spring%20Integration/Spring%20Deployer%202.1/

    Depending on what version of Spring you're currently using, you can get the 2.5 or 2.0.8 version of the deployer, but I would recommend the 2.5 version (just for the sake of having a newer version of Spring).

    I don't know exactly what version of Spring is bundled in the 2.5 distribution (I think it is 2.5.5), but it should be safe to replace the bundled jars with later versions - like 2.5.6. In any case, make sure that you're using the same version of spring-web.jar in the webapp as the rest of the jars (otherwise you'll end up with NoSuchMethodError and cohorts).

    BTW, out of curiosity, could you post the stacktrace with java.lang.NoClassDefFoundError?

    Marius

  • 9. Re: Unabled to return specified bean factory in web applicat
    Ivan Yuan Newbie

    Marius,

    Here is the stacktrace. Please take a look while I am trying to sync up versions as you advised.

    Thanks,


    2009-11-20 15:52:44,238 ERROR [org.jboss.deployment.MainDeployer] Could not create deployment: file:/C:/jboss-4.2.2.GA/server/default/deploy/MySpringBean.spring
    
    java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/DefaultXmlBeanDefinitionParser
    
     at java.lang.ClassLoader.defineClass1(Native Method)
    
     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    
     at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    
     at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    
     at java.security.AccessController.doPrivileged(Native Method)
    
     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    
     at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:682)
    
     at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:662)
    
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    
     at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:200)
    
     at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
    
     at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
    
     at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:527)
    
     at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
    
     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    
     at org.jboss.spring.factory.NamedXmlBeanDefinitionReader.<init>(NamedXmlBeanDefinitionReader.java:45)
    
     at org.jboss.spring.factory.NamedXmlApplicationContext.loadBeanDefinitions(NamedXmlApplicationContext.java:64)
    
     at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
    
     at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
    
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
    
     at org.jboss.spring.factory.NamedXmlApplicationContext.<init>(NamedXmlApplicationContext.java:58)
    
     at org.jboss.spring.factory.NamedXmlApplicationContext.<init>(NamedXmlApplicationContext.java:48)
    
     at org.jboss.spring.factory.ApplicationContextLoaderImpl.createBeanFactory(ApplicationContextLoaderImpl.java:36)
    
     at org.jboss.spring.factory.AbstractBeanFactoryLoader.create(AbstractBeanFactoryLoader.java:85)
    
     at org.jboss.spring.deployment.SpringDeployer.create(SpringDeployer.java:116)
    
     at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
    
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
    
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    
     at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
    
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    
     at java.lang.reflect.Method.invoke(Method.java:585)
    
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    
     at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    
     at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    
     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    
     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    
     at $Proxy9.deploy(Unknown Source)
    
     at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
    
     at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
    
     at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
    
     at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
    
     at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    
     at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    
     at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    
     at java.lang.reflect.Method.invoke(Method.java:585)
    
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    
     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    
     at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    
     at $Proxy0.start(Unknown Source)
    
     at org.jboss.system.ServiceController.start(ServiceController.java:417)
    
     at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    
     at java.lang.reflect.Method.invoke(Method.java:585)
    
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    
     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    
     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    
     at $Proxy4.start(Unknown Source)
    
     at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
    
     at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
    
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    
     at java.lang.reflect.Method.invoke(Method.java:585)
    
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    
     at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    
     at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    
     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    
     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    
     at $Proxy5.deploy(Unknown Source)
    
     at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
    
     at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
    
     at org.jboss.Main.boot(Main.java:200)
    
     at org.jboss.Main$1.run(Main.java:508)
    
     at java.lang.Thread.run(Thread.java:595)
    


  • 10. Re: Unabled to return specified bean factory in web applicat
    Marius Bogoevici Expert

    OK, thanks for posting the stacktrace. It seems indeed like you have an old version of the deployer.
    In the newer versions, DefaultBeanDefinitionDocumentReader is used instead of DefaultXmlBeanDefinitionParser.

  • 11. Re: Unabled to return specified bean factory in web applicat
    Ivan Yuan Newbie

    Hi Marius,

    Finally it works! I just replaced the deployer with jboss-spring-jdk5-2.5.jar. It works now. Thank you so so much!

    I have few other questions for you:

    1. With this spring deployer, can the jboss-spring.xml in the spring archive file take the tokens from a properties file in default/conf? It sounds abviously. But just want to make sure.

    2. If I have two spring archive files, say FATHER.spring and MOTHER.spring, from a CHILD.war, is it possible for the CHILD to inherit spring beans from both FATHER and MOTHER? Can web context factory have two parents? If the spring deployer can merge two factories into one, say PARENT, then CHILD can easily take beans from PARENT (i.e. both of FATHER and MOTHER), not sure if this is the behavior of the current spring deployer. If not, it would be a very useful feature.

    This morning, I installed JBoss 5.1.0-CR1 and Spring deployer (3.2) from SNOWDROP distribution. I tried my spring archive and web service war. I got the following exception. It seems that, for deployer 2.5 (with JBOSS 4.x) and 3.2 (with JBOSS 5.x), spring archives have different structure. The way to retrieve spring bean in web service seems to be different too.

    Thank you so much for helping me on this. Have a nice weekend!

    Ivan
    ------------
    Below is the stacktrace of JBOSS 5.1.0-CR1

    2009-11-20 15:44:22,797 ERROR [org.apache.catalina.core.StandardContext] (main) Context [/test-spring-web-service] startup failed due to previous errors
    
    java.lang.RuntimeException: mapped-name is required for org.apache.cxf.buslifecycle.CXFBusLifeCycleManager/bus of deployment test-spring-web-service.war
    
     at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXmlResourceEnvRefs(WebResourceHandler.java:287)
    
     at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXml(WebResourceHandler.java:325)
    
     at org.jboss.web.tomcat.service.TomcatInjectionContainer.processMetadata(TomcatInjectionContainer.java:550)
    
     at org.jboss.web.tomcat.service.WebCtxLoader.start(WebCtxLoader.java:158)
    
     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4272)
    
     at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
    
     at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
    
     at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
    
     at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
    
     at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
    
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    
     at java.lang.reflect.Method.invoke(Method.java:585)
    
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
    
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
    
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    
     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
    
     at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
    
     at $Proxy38.start(Unknown Source)
    
     at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
    
     at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
    
     at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
    
     at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
    
     at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
    
     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    
     at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
    
     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
    
     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    
     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
    
     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    
     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    
     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    
     at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
    
     at org.jboss.system.ServiceController.start(ServiceController.java:460)
    
     at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
    
     at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
    
     at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
    
     at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
    
     at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
    
     at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
    
     at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
    
     at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
    
     at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
    
     at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
    
     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    
     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
    
     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    
     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
    
     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    
     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    
     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    
     at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
    
     at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
    
     at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
    
     at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
    
     at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
    
     at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
    
     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    
     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
    
     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    
     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
    
     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    
     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    
     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    
     at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
    
     at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
    
     at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
    
     at org.jboss.Main.boot(Main.java:216)
    
     at org.jboss.Main$1.run(Main.java:546)
    
     at java.lang.Thread.run(Thread.java:595)