Announcement Announcement Module
Collapse
No announcement yet.
Shared BeanFactory between EJB's in Websphere 5.0? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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..

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

    Comment


    • #3
      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..

      Comment


      • #4
        Re: Shared BeanFactory between EJB's in Websphere 5.0?

        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()

        Comment


        • #5
          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.

          Comment

          Working...
          X