I have a maven web application that has a dependency on an EJB project.
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>soar-ejb</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
In the EJB project there I've added an env-entry
in the ejb-jar.xml
as such:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee"
version = "3.1"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
<enterprise-beans>
<session>
<env-entry>
<description>Config file</description>
<env-entry-name>configFileLocation</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>dropbox-config.properties</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
</ejb-jar>
I've tested the EJB project, using arquillian, and I am able to inject this value using @Resource
as such:
@Resource(name = "configFileLocation")
private String configFile;
Now, when I build the .war with the ejb dependency, I get a .war with my EJB project as a .jar inside WEB-INF\lib
. Within this EJB project (i.e. inside the .jar) the ejb-jar.xml
file is in the proper META-INF
directory.
BUT now, when I deploy to the server the @Resource
injection never works. The String
is always null
. According to what I have read I have the ejb-jar.xml
in the correct location, both within the EJB project and within the .war that maven produces.
Would someone have an idea of what I've configured incorrectly?
Thanks!
EDIT:
Modified the session element to
<session>
<description>An EJB that loads configuration from a file</description>
<display-name>ConfigurationProducer</display-name>
<ejb-name>ConfigurationProducer</ejb-name>
<ejb-class>com.trf.util.DropboxConfigFileProducer</ejb-class>
<session-type>Stateless</session-type>
<env-entry>
<description>Location of the config file</description>
<env-entry-name>configFileLocation</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>dropbox-config.properties</env-entry-value>
</env-entry>
</session>