Announcement Announcement Module
Collapse
No announcement yet.
JBoss and ContextSingletonBeanFactoryLocator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JBoss and ContextSingletonBeanFactoryLocator

    Hi All,

    I'm trying to get an SLSB running in JBoss with a bean factory retrieved via the ContextSingletonBeanFactoryLocator. The Spring classes aren't able to locate the beanRefFactory.xml file. My EAR layout is as follows:

    Code:
    app.ear
      |-app-lib.jar (contains refBeanFactory.xml)
      |-spring.jar
      |-app-ejb.jar (contains AppBean)
      |-app.war
      |-... remaining util jars
    The manifest file of app-ejb.jar has app-lib.jar in it's Class-Path. AppBean is as follows:

    Code:
    public class AppBean extends AbstractStatelessSessionBean implements
            MailboxManager {
    
        private MailboxManager mailboxManager;
        
        protected void onEjbCreate() throws CreateException {
            mailboxManager = (MailboxManager) getBeanFactory().getBean("mailboxManager");
        }
    
        public void deliverMessage(MessageEnvelope envelope)
                throws MailboxException, MailboxAuthorizationException {
            mailboxManager.deliverMessage(envelope);
        }
        
        public void setSessionContext(SessionContext sessionContext) {
            super.setSessionContext(sessionContext);                setBeanFactoryLocator(ContextSingletonBeanFactoryLocator.getInstance());
            setBeanFactoryLocatorKey(ServicesConstants.PRIMARY_CONTEXT_ID);
        }
    }
    beanRefFactory.xml is:

    Code:
    <beans>
    	<bean id="com.app" lazy-init="true"
    		class="org.springframework.context.support.ClassPathXmlApplicationContext">
    		<constructor-arg>
    			<value>com/app/server/mailbox/applicationContext.xml</value>
    		</constructor-arg>
    	</bean>
    </beans>
    When I hit the web and trigger a message to the SLSB through the SimpleRemoteStatelessSessionProxyFactory, the ContextSingletonBeanFactoryLocator fires up with the default bean factory search path:

    Code:
    2005-01-27 17&#58;36&#58;31,516 DEBUG &#91;org.springframework.beans.factory.access.SingletonBeanFactoryLocator&#93; ContextSingletonBeanFactoryLocator.getInstance&#40;&#41;&#58; instances.hashCode=0, instances=&#123;&#125;
    2005-01-27 17&#58;36&#58;31,516 DEBUG &#91;org.springframework.beans.factory.access.SingletonBeanFactoryLocator&#93; Factory group with resource name &#91;classpath*&#58;beanRefContext.xml&#93; requested. Creating new instance.
    but a few lines down, I get this error:

    Code:
    2005-01-27 17&#58;36&#58;31,526 ERROR &#91;org.jboss.ejb.plugins.LogInterceptor&#93; EJBException in method&#58; public abstract void com.app.ejb.MailboxManagerRemote.deliverMessage&#40;com.app.MessageEnvelope&#41; throws com.app.server.mailbox.MailboxException,com.app.server.mailbox.MailboxAuthorizationException,java.rmi.RemoteException, causedBy&#58;
    
    org.springframework.beans.FatalBeanException&#58; Unable to return specified BeanFactory instance&#58; factory key &#91;com.app&#93;, from group with resource name &#91;classpath*&#58;beanRefContext.xml&#93;; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException&#58; No bean named 'com.app' is defined&#58; org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans &#91;&#93;; root of BeanFactory hierarchy
    I've tried to load the resource (using getClassLoader().getResource() ) outside of Spring and found that the classloader for a class such as MailboxException (which is in app-lib.jar) will find beanRefContext.xml whereas AppBean's classloader (AppBean is in app-ejb.jar) will not. Has anyone encountered this problem before?

  • #2
    Found the problem:

    ContextSingletonBeanFactoryLocator looks for beanRefContext.xml

    We now return to your regularly scheduled programming.

    Comment

    Working...
    X