WebSphere Application Server - How to Map Resource Environment Variables In WAS 6?

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Application Server > August 2006 > How to Map Resource Environment Variables In WAS 6?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to Map Resource Environment Variables In WAS 6?
Athar Shiraz

2006-08-17, 1:21 pm

Ok I have an application with a deployment descriptor containing some environment variables:
<env-entry>
<env-entry-name>DB2Region</env-entry-name>
<env-entry-value>TECH</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>DB2ID</env-entry-name>
<env-entry-value>db2</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>DB2Password</env-entry-name>
<env-entry-value>enter</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>LDAPLookupID</env-entry-name>
<env-entry-value>user</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>LDAPLookupPassword</env-entry-name>
<env-entry-value>pwd</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>

Now I would like the application to be able to use these variables by doing a direct context.lookup("DB2Region");

If you get my drift.

How would I define them in WAS 6? Is there a document on this?

I went to the Resources->Resource environment providers and then I went about creating the provider and then inside the provider I created the Referenceable (with class and name java.lang.String) and then I created the Resource env entries (using the re
ferencable though the resource env entry does not have a value it has a custom properties which I dutifully used) I could not access the property DB2Region. Then I even went and added another custom property to the Resource Environment Provider and I sti
ll get a nullPointerException. Apparently it has either found the resource entry and has returned null or it has not found the resource entry at all. Here are the errors I am getting :

[8/17/06 10:41:58:906 EDT] 00000038 ServletWrappe E SRVE0100E: Did not realize init() exception thrown by servlet EHSControllerServlet: java.lang.NullPointerException
at org.navyfcu.hrimaging.ehs.EHSSQLGenerator.<init>(EHSSQLGenerator.java:28)
at org.navyfcu.hrimaging.ehs.servlets.EHSControllerServlet._populateTypeList(EHSControllerServlet.java:362)
at org.navyfcu.hrimaging.ehs.servlets.EHSControllerServlet.init(EHSControllerServlet.java:308)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:275)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3003)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1958)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:88)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

[8/17/06 10:41:58:906 EDT] 00000038 WebApp E SRVE0026E: [Servlet Error]-[EHSControllerServlet]: java.lang.NullPointerException
at org.navyfcu.hrimaging.ehs.EHSSQLGenerator.<init>(EHSSQLGenerator.java:28)
at org.navyfcu.hrimaging.ehs.servlets.EHSControllerServlet._populateTypeList(EHSControllerServlet.java:362)
at org.navyfcu.hrimaging.ehs.servlets.EHSControllerServlet.init(EHSControllerServlet.java:308)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:275)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3003)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1958)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:88)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

[8/17/06 10:41:58:906 EDT] 00000038 SystemErr R PROBLEM getting datasource in BenefitsListener
[8/17/06 10:41:58:906 EDT] 00000038 SystemErr R javax.naming.NameNotFoundException: Context: 41001-2019rNode01Cell/nodes/41001-2019rNode01/servers/server1, name: DB2Region: First component in name DB2Region not found. Root exception is org.omg.CosNam
ing.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl. do_resolve_complete_info(WsnOptimizedNam
ingImpl.java:543)
at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase. resolve_complete_info(WsnOptimizedNaming
ImplBase.java:2213)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:4043)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1746)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1707)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1412)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1290)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:145)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
at org.navyfcu.hrimaging.ehs.servlets.EHSControllerServlet.init(EHSControllerServlet.java:290)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:275)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3003)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1958)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:88)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
---- Begin backtrace for Nested Throwables
org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl. do_resolve_complete_info(WsnOptimizedNam
ingImpl.java:543)
at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase. resolve_complete_info(WsnOptimizedNaming
ImplBase.java:2213)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:4043)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1746)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1707)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1412)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1290)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:145)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
at org.navyfcu.hrimaging.ehs.servlets.EHSControllerServlet.init(EHSControllerServlet.java:290)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:275)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3003)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1958)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:88)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

--

By the way the last error is due to my attempt to add a resource environment entry even into the Environment->Naming->Name Space Binding section. So I have been trying this all morning. Help would be appreciated.


Mark Lewis

2006-08-18, 1:37 pm

Athar Shiraz wrote:
> Ok I have an application with a deployment descriptor containing some environment variables:
> <env-entry>
> <env-entry-name>DB2Region</env-entry-name>
> <env-entry-value>TECH</env-entry-value>
> <env-entry-type>java.lang.String</env-entry-type>
> </env-entry>

[...snip...]
> Now I would like the application to be able to use these variables by doing a direct context.lookup("DB2Region");
>
> If you get my drift.
>
> How would I define them in WAS 6? Is there a document on this?

[...snip...]

I think the problem is that you are looking your environment entries up
as global JNDI entries:

ctx.lookup("DB2Region");

Environment entries are defined in the component environment
("java:comp/env") namespace, so you should be looking up your resource
there:

ctx.lookup("java:comp/env/DB2Region");

Thanks,

Mark.
Athar Shiraz

2006-08-24, 1:44 pm

> Athar Shiraz wrote:
> descriptor containing some environment variables:
> [...snip...]
> these variables by doing a direct
> context.lookup("DB2Region");
> document on this?
> [...snip...]
>
> I think the problem is that you are looking your
> environment entries up
> as global JNDI entries:
>
> ctx.lookup("DB2Region");
>
> Environment entries are defined in the component
> environment
> ("java:comp/env") namespace, so you should be looking
> up your resource
> there:
>
> ctx.lookup("java:comp/env/DB2Region");
>
> Thanks,
>
> Mark.


I tried both methods ... ended up removing the environment variable entry altogether and putting it as a constant in a constant file ...


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com