Announcement Announcement Module
Collapse
No announcement yet.
Error using shared application context in EJB under Weblogic 8.1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error using shared application context in EJB under Weblogic 8.1

    Hi,

    I'm using 1.2.6 with WebLogic 8.1SP4 (on WinXP for what it's worth)

    I'm converting my simple web-app that uses Spring very happily into a j2ee app with an EJB module (containing some MDBs) and a WAR module.

    There's a common business logic layer which the 2 modules share - what I want is to have one global application context which dictates how the business objects are wired up and then the EJB and WAR modules just make use of that.

    So from some searching of these forums and google it's been suggested that in my MDB (extending AbstractMessageDrivenBean) I just do this:

    Code:
    	
    public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext) throws EJBException
    {
      super.setMessageDrivenContext(messageDrivenContext);
    
      setBeanFactoryLocator(DefaultLocatorFactory.getInstance());
      setBeanFactoryLocatorKey("applicationContext-main");
    }
    Then have a beanRefContext.xml in the APP-INF/classes of the ear which contains this:

    Code:
     <bean name="applicationContext-main" class="org.springframework.context.support.ClassPathXmlApplicationContext">
       <constructor-arg>
       <list>
        <value>applicationContext-db.xml</value>
        <value>applicationContext-jdbc.xml</value>
        <value>applicationContext-jms.xml</value>
       </list>
      </constructor-arg>
     </bean>
    The problem I have is that when I run my app I get an exception when a message is received:

    BeanFactory not initialized - call 'refresh' before accessing beans via the context: org.springframework.context.support.ClassPathXmlAp plicationContext

    I'm totally stumped - from what I've dug up what I'm doing above is as suggested in numerous places. Is there some magic bootstrapping step I'm missing or something?

    many thanks

    James

  • #2
    I've worked this out by downloading the Spring source and stepping in.

    There was a typo in one of my applicationContext-xxx.xml files which resulted in a ClassNotFoundException being thrown during the initializeDefinition call inside SingletonBeanFactoryLocator.useBeanFactory.

    Unfortunately WebLogic doesn't seem to log out this exception in any way, so the cause of the error later isn't easily seen.

    Though I guess it's also arguable that SBFL shouldn't try to continue using the BeanFactory if it knows that the initialiseDefinition call failed.

    Anyway, all working now. Thanks for all your help

    Comment

    Working...
    X