Announcement Announcement Module
Collapse
No announcement yet.
Can't find beanRefFactory.xml in EJB jar Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't find beanRefFactory.xml in EJB jar

    I am using the following code to load my object from an EJB (not using Spring's EJB classes):

    Code:
      public void setBeanContextName(String ctxName)
      {
        beanContextName = ctxName;
      }
    
      public String getBeanContextName()
      {
          return beanContextName;
      }
    
      public Object getBean(String bean)
      {
        BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance();
        BeanFactoryReference bf = bfl.useBeanFactory(beanContextName);
        return bf.getFactory().getBean(bean);
      }
    It is bean called during ejbCreate()

    I have my beanRefFactory in the root directory of my EJB jar. The contents is as follows:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
     <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
     <beans>
       <bean id="my.beans"
             class="org.springframework.context.support.ClassPathXmlApplicationContext">
         <constructor-arg>
           <list>
             <value>springCommon.xml</value>
             <value>META-INF/springContext.xml</value>
           </list>
         </constructor-arg>
       </bean>
     </beans>
    I get the following exception:
    org.springframework.beans.FatalBeanException: Unable to find resource for specified definition. Group resource name [classpath*:beanRefFactory.xml], factory key [my.beans]

    As far as I can tell this exception means beanRefFactory.xml wasn't found in the path. Isn't the root of an EJB jar implicitly put in the classpath when calling code from inside the EJB?

  • #2
    In case people need a little more detail:

    I'm running Weblogic 8.1. My EJB jar is directly deployed to the server, its not in an EAR. The EJB is not on the system classpath, just depoyed at runtime. I have 3 config files in the EJB jar:

    beanRefFactory.xml
    springCommon.xml
    META-INF/springContext.xml

    I've tried moving beanRefFactory.xml to a location outside the EJB to a place on the classpath. But then springCommon.xml can't be found.

    Comment


    • #3
      As far as I can tell from research on this forum and the internet Weblogic does not implicitly place a loaded EJB jar into the classpath in its own classloader. An EJB classloader loads the classes explicitly, and reads the files in META-INF explicitly as well.

      I believe the two options I have are:
      - Create an EAR.
      - Add "./" to the system classpath so that a jar can find resources in itself.

      Comment

      Working...
      X