Reputation: 116
I created a JAX-WS Web Service and an EJB skeleton from a WSDL file by following a Tutorial in the Rational Application Developer for WebSphere 8.0.4 help.
It created an EJB project to contain my EJB code. It created an EJBEar project to build an ear file. It created a RouterWebProject to create a war file.
The RouterWebProject provides servlet information so that I can post an HTTP soap request to the servlet to be routed to my web service code in the EJB.
The EJB service code calls a class in the same EJB project that uses a ResourceBundle to read a property file with the name AppSDKExamples.properties
static {
ResourceBundle props = ResourceBundle.getBundle("AppSDKExamples", Locale.getDefault());
brokerPartnerId = props.getString("broker.partner.id");
buyPartnerId = props.getString("svc.dealer.partner.id");
sellPartnerId = props.getString("platform.partner.id");
sellPartnerId2 = props.getString("platform.partner.id2");
accountNumber = props.getString("account.number");
}
I have tried placing the AppSDKExamples.properties file everywhere I can think of but I always get a java.util.MissingResourceException.
How do I make this property file available to the EJB code?
Currently the EJB ear looks like this:
The EJB.jar looks like this:
The war file looks like this:
Any help on this would be greatly appreciated. Thanks.
Upvotes: 2
Views: 6647
Reputation: 33946
If the properties files are at the root of the EJB, then the EJB class should be able to find the properties files. If you're running with Java 2 security enabled, then you'll need to grant FilePermission; see PROFILE_HOME/config/cells/CELL/nodes/NODE/app.policy for ${webComponent} and ${ejbComponent}.
Simply placing the properties files in EAR/lib won't work because the EAR/lib/ directory is not on the classpath, only the .jar files within it are on the classpath. It might work to add Class-Path: lib/
to the EJB jar MANIFEST.MF, but directory class paths are not required by the JavaEE spec, so I do not know if they are supported by WebSphere Application Server.
Referencing the properties files directly in the MANIFEST.MF Class-Path also doesn't work because only JARs and directories are supported (see above for JavaEE caveat regarding directories).
In general, it's probably best to remove the leading slash from /lib
. It's unclear from the JavaEE platform specification whether this should refer to the lib
directory in the EAR or to a directory in the root of the machine file system.
Upvotes: 2