Discussions

EJB programming & troubleshooting: how can I load a properties file drom a sessin EJB ,in JBoss?

  1. My problem is that I MUST load a .properties file from a session bean and I cant make that from the .jar.A solution is to put it in the JNDI server ,but..
  2. Are you able to place a helper class outside the EJB.jar? If you can, then that should help. The helper class could read the properties file for your EJB.
  3. helo, i suggest you *bind* the directory path of the properties file into to an JNDI variable, and use an external class (e.g. Command type class) to lookup the path of the file from the JNDI directory and load the properties for you...
  4. <quote>
    My problem is that I MUST load a .properties file from a session bean and I cant make that from the .jar.A solution is to put it in the JNDI server ,but..
    </quote>

    Thou shall not use io in EJB (see the specs). It´s not threadsafe, not clusterable etc etc. Use JNDI & the ejb environment.
  5. Sven said:
    > Thou shall not use io in EJB (see the specs). It´s not
    > threadsafe, not clusterable etc etc. Use JNDI & the ejb
    > environment.

    But I thought you were allowed to use any class from java.util.* (including java.util.Properties)?

    - Ravi
      
  6. You are not allowed to use the io package from within EJB, however you are allowed to use the ClassLoader. What you do is put the properties file in your classpath the call this.getClass().getResourceAsStream("/my.properties"), then populate the Property object with the input stream.