2
votes

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:

  • lib/AppSDKExamples.properties
  • lib/AppSDKExamples_en_US.properties
  • lib/other jar files
  • META-INF/MANIFEST.MF (this does not contain a class path I can't figure out how to set it.)
  • EJB.jar
  • WebProject.war

The EJB.jar looks like this:

  • com/activant/web/services/examples/class files that look for the property file
  • com/activant/web/services/iaptest/class files for the web service
  • META-INF/MANIFEST.MF (this has the AppSDKExamples.properties and AppSDKExamples_en_US.properties in the classpath)
  • AppSDKExamples.properties
  • AppSDKExamples_en_US.properties

The war file looks like this:

  • lib contains same jar files as the EJB.jar files has
  • META-INF (Class-Path: /lib EJB.jar)
  • WEB-INF/classes this folder contains both the propertie files.
  • WEB-INF/lib this folder contains both the properties files.
  • WEB-INF/ibm-web-bnd.xml
  • WEB-INF/ibm-web-ext.xml
  • WEB-INF/web.xml

Any help on this would be greatly appreciated. Thanks.

1

1 Answers

2
votes

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.