Results 1 to 5 of 5

Thread: EJB3 interceptor cannot bootstrap context

  1. #1
    Join Date
    Jan 2007
    Location
    Paris, France
    Posts
    39

    Default EJB3 interceptor cannot bootstrap context

    Hi.
    I have a annotation-based EJB3 set up with Spring autowiring :
    Code:
    @Stateless(name = "WiringExampleFacade")
    @Remote({WiringExample.class})
    @Local({WiringExample.class}) 
    @Interceptors(SpringBeanAutowiringInterceptor.class)
    public class WiringExampleFacadeEJB implements WiringExample {
    
    	// automatically injected with a matching Spring bean
        @Autowired
        private WiringExampleImpl delegate;
    My EAR contains an EJB jar (at its root). In this jar, there is a folder called context which includes a file called beanRefContext.xml; said file contains :
    Code:
    <?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:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd">
             
         <!-- This will automatically declare several post-processors
              including the AutowiredAnnotationBeanPostProcessor -->      
         <context:annotation-config/>
         
         <import resource="classpath:businessBeans.xml" />
         
    </beans>
    If I understand things correctly, the AutoWiringInterceptor will use by default a ContextSingletonBeanFactoryLocator to retrieve the beanRefContext.xml from the classpath, so this setup should work.
    Well, it doesn't.

    Any help ?
    Last edited by sonicfab; May 9th, 2008 at 02:07 PM.
    -----------------------------------
    Fabien Coppens

    For he on honey-dew hath fed, and drunk the milk of Paradise

  2. #2
    Join Date
    Jan 2007
    Location
    Paris, France
    Posts
    39

    Default

    Ok my bad on one thing :
    from the Javadoc I gather that the ContextSingletonBeanFactory locator is looking for a beanRefContext.xml file that defines a single bean of type BeanFactory.
    So here's the modified beanRefContext.xml file :
    Code:
    <?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:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-2.5.xsd">
             
         <!-- This will automatically declare several post-processors
              including the AutowiredAnnotationBeanPostProcessor -->      
         <context:annotation-config/>
         
         <bean id="ejb-businesslayer.application.context" lazy-init="true"
    		class="org.springframework.context.support.ClassPathXmlApplicationContext">
    		<constructor-arg>
    			<list>
    				<value>businessBeans.xml</value>
    			</list>
    		</constructor-arg>
    	</bean>  
         
    </beans>
    That file is located inside the EJB jar that is included in my EAR, so it is in the classpath.
    But I am still getting the same error :

    java.lang.RuntimeException: org.springframework.beans.factory.access.Bootstrap Exception: Unable to return specified BeanFactory instance: factory key [null], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No unique bean of type [org.springframework.beans.factory.BeanFactory] is defined: expected single bean but found 0
    at org.jboss.ejb3.interceptor.LifecycleInterceptorHan dler.postConstruct(LifecycleInterceptorHandler.jav a:113)
    at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJ BContainer.java:619)
    at org.jboss.ejb3.AbstractPool.create(AbstractPool.ja va:131)
    at org.jboss.ejb3.InfinitePool.get(InfinitePool.java: 49)
    at org.jboss.ejb3.ThreadlocalPool.create(ThreadlocalP ool.java:50)
    at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool .java:90)
    at org.jboss.ejb3.stateless.StatelessInstanceIntercep tor.invoke(StatelessInstanceInterceptor.java:54)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
    at org.jboss.aspects.security.AuthenticationIntercept or.invoke(AuthenticationInterceptor.java:77)
    at org.jboss.ejb3.security.Ejb3AuthenticationIntercep tor.invoke(Ejb3AuthenticationInterceptor.java:110)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
    at org.jboss.ejb3.ENCPropagationInterceptor.invoke(EN CPropagationInterceptor.java:46)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
    at org.jboss.ejb3.asynchronous.AsynchronousIntercepto r.invoke(AsynchronousInterceptor.java:106)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
    at org.jboss.ejb3.stateless.StatelessContainer.dynami cInvoke(StatelessContainer.java:304)
    at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:10 6)
    at org.jboss.aspects.remoting.AOPRemotingInvocationHa ndler.invoke(AOPRemotingInvocationHandler.java:82)
    at org.jboss.remoting.ServerInvoker.invoke(ServerInvo ker.java:769)
    at org.jboss.remoting.transport.socket.ServerThread.p rocessInvocation(ServerThread.java:573)
    at org.jboss.remoting.transport.socket.ServerThread.d orun(ServerThread.java:373)
    at org.jboss.remoting.transport.socket.ServerThread.r un(ServerThread.java:166)
    Caused by: org.springframework.beans.factory.access.Bootstrap Exception: Unable to return specified BeanFactory instance: factory key [null], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No unique bean of type [org.springframework.beans.factory.BeanFactory] is defined: expected single bean but found 0
    -----------------------------------
    Fabien Coppens

    For he on honey-dew hath fed, and drunk the milk of Paradise

  3. #3
    Join Date
    Jan 2007
    Location
    Paris, France
    Posts
    39

    Default

    OK, MY BAD ! (again)
    The ContextSingletonBeanFactoryLocator is looking for resource classpath*:beanRefContext.xml, so the beanRefContext.xml file has to be in the classpath as the name says. I had it in a /context folder which wasn't seen by the classpath*.
    Works now !
    -----------------------------------
    Fabien Coppens

    For he on honey-dew hath fed, and drunk the milk of Paradise

  4. #4
    Join Date
    Jul 2008
    Posts
    2

    Default Share businessBeans.xml

    Hi, could you please share your businessBeans.xml.
    I finally can get rid of the annoying [classpath*:beanRefContext.xml] errors, but after that I can make my EJB autowired a simple test bean.
    The root exception is:
    org.springframework.beans.factory.BeanCreationExce ption:
    Autowiring of fields/methods failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption:
    Could not autowire field: private test.TestBean test.RegionServiceBean.testBean;
    nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException:
    No unique bean of type [test.TestBean] is defined:
    Unsatisfied dependency of type [class test.TestBean]:
    expected at least 1 matching bean

    So I think there is a problem with my businessBeans.xml definition.
    Thanks in advance.

  5. #5
    Join Date
    Jul 2009
    Location
    Bogota, Colombia
    Posts
    6

    Default

    Basically all you have to do is to restart JBoss. Once you have deployed your jar file containing your EJBs JBoss does not reloads the classpath for your application, so if you restart your JBoss server it will read all the files contained on the root of your .jar file. So just put your refBeanContext.xml file on the root, deploy your new jar file, restart the server and you should be done.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •