Quantcast
Viewing all articles
Browse latest Browse all 1091

How to use resource-env-ref in glassfish-application.xml in deployment plan

Hi there,

I've got an app structured as an ear that contains a war (and an ejb, but it doesn't seem relevant to this). I have a deployment plan with glassfish-application.xml and TheWarFile.war.glassfish-web.xml.

I'd like to set certain configuration properties for my app via JNDI. In one class in the war file, I do this:

String basePath = null;
try {
basePath = new InitialContext().lookup("java:comp/env/DownloadService/BasePath").toString();
} catch (NamingException e) {
basePath = "jndi not found";
}

In the web.xml in that war file, I do this:

DownloadService/BasePath
java.lang.String

To map the internal JNDI name to a JNDI entry configured in the Glassfish admin console, in TheWarFile.war.glassfish-web.xml I have this:

DownloadService/BasePath
MySpecificJNDIName/DownloadBasePath

That works.

What I'm wondering is, how can I configure the JNDI mapping using glassfish-application.xml instead of TheWarFile.war.glassfish-web.xml?

Do I have to change the way it's looked up to take into account the application level scoping or something?

I can't figure it out. I'd like to get rid of TheWarFile.war.glassfish-web.xml since this resource-env-ref is the only thing in it. The context-root for the web app is set in glassfish-application.xml.

Thanks!


Viewing all articles
Browse latest Browse all 1091

Trending Articles