Results 1 to 5 of 5

Thread: Shared BeanFactory between EJB's in Websphere 5.0?

  1. #1
    Join Date
    Apr 2005
    Location
    United Kingdom
    Posts
    6

    Default Shared BeanFactory between EJB's in Websphere 5.0?

    Hi.
    I am trying to get a common BeanFactory instance between 4 EJB:s (1ssb and 3 mdb:s) in Websphere 5.0.
    I have had my exact same configuration working in JBoss, but for some reason, I am not able to achieve the same effect in WAS, because each EJB will create its own hierarchy of beans.
    My aim is to have shared instances of a few objects between these EJB's.

    At the moment, I my code looks like this:
    public void onEjbCreate() {
    BeanFactory factory = null;
    BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator
    .getInstance("META-INF/spring-context.xml");
    BeanFactoryReference ref = locator.useBeanFactory("context");
    factory = ref.getFactory();
    dispatcher = (MessageDispatcher) factory.getBean("responseDispatcher");
    }

    I have also tried using SingletonBeanFactoryLocator with no effect.

    the spring-context.xml looks like this (excluding header-stuff):
    <beans>
    <bean id="context" class="org.springframework.context.support.ClassPa thXmlApplicationContext">
    <constructor-arg>
    <list>
    <value>META-INF/esb.xml</value>
    <value>META-INF/esb.xml</value>
    </list>
    </constructor-arg>
    </bean>
    </beans>

    The esb.xml in turn contains bean-configurations for all the beans that I want to access.

    Any help with this would be grately appreciated, as I have been banging my head against the wall quite a while at the moment..
    Regards
    Wille Faler
    Infonatural ltd
    www.infonatural.com

  2. #2
    Join Date
    Apr 2005
    Posts
    1

    Default

    May be you can package these EJB-JARs within one application's EAR.

  3. #3
    Join Date
    Apr 2005
    Location
    United Kingdom
    Posts
    6

    Default Perhaps a solution

    "May be you can package these EJB-JARs within one application's EAR."

    They are all within one EAR and even one EJB-JAR, but Websphere seems to have a paranoid level of classloader-isolation with one classloader PER EJB!
    Classloader isolation is somewhat configurable, but not in this respect.

    However, I think I might have have found a way:
    Binding the shared resources as remote objects with RMI which I bootstrap in a Servlet. This at least works for me on JBoss, but I will have to wait until monday at work to confirm it on WAS.
    It should work, just as long as Websphere doesn't have some strange rules/limitations on RMI binding..
    Regards
    Wille Faler
    Infonatural ltd
    www.infonatural.com

  4. #4
    Join Date
    Apr 2005
    Location
    Philippines
    Posts
    35

    Default Re: Shared BeanFactory between EJB's in Websphere 5.0?

    Quote Originally Posted by wfaler
    At the moment, I my code looks like this:
    public void onEjbCreate() {
    BeanFactory factory = null;
    BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator
    .getInstance("META-INF/spring-context.xml");
    BeanFactoryReference ref = locator.useBeanFactory("context");
    factory = ref.getFactory();
    dispatcher = (MessageDispatcher) factory.getBean("responseDispatcher");
    }

    Trying putting your codes that initialize the BeanFactoryLocator inside the setSessionContext() for SessionBeans and setMessageDrivenContext for MDBs instead of inside onEjbCreate()

  5. #5
    Join Date
    Apr 2005
    Location
    United Kingdom
    Posts
    6

    Default Thanks

    Haven't tried the latter suggestion, maybe I'll try it later on during a cleanup round, however, the RMI route did work, so I am going with that for now.
    Regards
    Wille Faler
    Infonatural ltd
    www.infonatural.com

Similar Threads

  1. Replies: 9
    Last Post: Jan 9th, 2012, 04:48 PM
  2. Replies: 4
    Last Post: Oct 5th, 2005, 11:04 AM
  3. Odd behaviour when injecting TransactionTemplate
    By damon311 in forum Container
    Replies: 3
    Last Post: Jul 23rd, 2005, 11:21 AM
  4. Replies: 6
    Last Post: May 25th, 2005, 01:56 AM
  5. DefaultAdvisorAutoProxyCreator skipping beans
    By youngm in forum Container
    Replies: 6
    Last Post: Apr 12th, 2005, 04:29 PM

Posting Permissions

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