Announcement Announcement Module
Collapse
No announcement yet.
Reading Context from File Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading Context from File

    Hello,

    I have an EJB that uses a beanRefContext and an ejb-jar environment entry to load the context. The context is loaded from the classpath.

    Now I want to load the context from the file path (especially from JBOSS/server/default/conf directory). This is because I have some properties that are specific for test and production environment and I do not want to have an ear file for each environment.

    I tried with an FileSystemXmlApplicationContext, but I cannot specify a System property. Beside this, the FileSystemXmlApplicationContext is always relative to the startup of the JVM. As I do not know where the VM is startet, I cannot specify a PathPattern to match (e.g. **/zustellclientContext.xml).

    Any ideas?
    Rene

    beanRefFactory.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="zustellclientService" lazy-init="false" class="org.springframework.context.support.ClassPa thXmlApplicationContext">
    <constructor-arg>
    <value>zustellclientContext.xml</value>
    </constructor-arg>
    </bean>
    </beans>


    META-INF/ejb-jar.xml:
    ...
    <env-entry>
    <env-entry-name>ejb/BeanFactoryPath</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value><![CDATA[zustellclientContext.xml]]></env-entry-value>
    </env-entry>
    ...

  • #2
    I believe that you don't have to pack things into your ear to be able to load it via ClassPathXmlApplicationContext. For example you could try to pack your environment dependent stuff in a separate jar and put it in server/lib. (Never tried it really, but it should work)

    Comment


    • #3
      If you don't pack your application into an EAR the EJB jars are not on the path by default. At least this was the case in Weblogic 8.1.

      Comment


      • #4
        Yes, but we are not talking about ejbs, we are talking about a couple of xml files.

        Comment


        • #5
          You can extend the Class-Path manifest entry of your EJB-jar to contain "." (without the quotes). Then you have to make sure, the directory which has to contain your configuration is defined in the classpath of the VM.
          I got this work on WebLogic.

          Regards,
          Andreas

          Comment

          Working...
          X