Results 1 to 2 of 2

Thread: JBoss and ContextSingletonBeanFactoryLocator

  1. #1
    Join Date
    Jan 2005
    Location
    Toronto, ON
    Posts
    8

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Toronto, ON
    Posts
    8

    Default

    Found the problem:

    ContextSingletonBeanFactoryLocator looks for beanRefContext.xml

    We now return to your regularly scheduled programming.

Similar Threads

  1. Replies: 1
    Last Post: Oct 2nd, 2005, 07:10 PM
  2. Replies: 2
    Last Post: Sep 28th, 2005, 11:12 PM
  3. JBoss SSO + Acegi issue
    By jhazen in forum Security
    Replies: 3
    Last Post: Sep 8th, 2005, 06:33 AM
  4. Replies: 4
    Last Post: May 13th, 2005, 07:49 AM
  5. Replies: 1
    Last Post: Dec 17th, 2004, 06:18 AM

Posting Permissions

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