I am working in WSAD 5.1.1 and DB2 8
I have an EAR with one WAR and two EJB JARS.
I am testing in the WASD Test Environment.
I have a connection factory class that gets a reference to my datasource from the initial context. Initially a direct JNDI lookup was being preformed. This allowed the application to work but resulted in everybodys favorite informational message that the resourse referece could not be found and the defaults are being used. I have been trying to get rid of that message by performing an indrect lookup. Here is what I did:
1. Opened up the WAR deployment descriptor in WSAD
2. Selected the Resource tab on the References page
3. Pressed 'Add' and entered the following:
3.1 Name => test
3.2 Type => javax.sql.DataSource
3.3 Authentication => Container
3.4 Connection Management => Default
3.5 Isolation Level => TRANSACTION_NONE
3.6 JNDI Name => jdbc/MktgCycleXAPool
This resulted in the following updated to web.xml
[b]web.xml from WAR[/b]
I updated the connection factory class to get the java:comp/env subcontext and then perform a lookup of the new reference name 'test'
Hashtable env = new Hashtable();
ctx = new InitialContext(env);
ctx2 = (Context)ctx.lookup("java:comp/env");
ds = (DataSource) ctx2.lookup("test");
This connection pool is also flagged as a CMP pool.
Below is the message from the console log at start up. From what I can tell, it looks like the resource reference is not making it into the context. Did I miss something?
[b]Server start up log[/b]
EJBContainerI E WSVR0062E: Unable to start EJB, Marketing#ejb_mkt.jar#SuppressionBO: javax.naming.NameNotFoundException: Name "test" not found in context "java:comp/env".
Thanks in advance.
Pinned topic resource-ref in web.xml not being loaded into InitialContext
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2010-12-07T16:21:06Z at 2010-12-07T16:21:06Z by pandeybrijesh
SystemAdmin 110000D4XK4447 Posts
Re: resource-ref in web.xml not being loaded into InitialContext2005-07-13T21:22:45ZThis is the accepted answer. This is the accepted answer.I have found out what the problem is. The connection factory class lives inside one of the EJB Jars. It does not have easy access to the resource references in the WAR. What I needed to do was set up a resource reference for each ejb. This is very similar to setting up ejb local references when one ejb references another.
pandeybrijesh 270003RCVU1 Post
Re: resource-ref in web.xml not being loaded into InitialContext2010-12-07T16:21:06ZThis is the accepted answer. This is the accepted answer.
- SystemAdmin 110000D4XK
in case of ejb, we should to make connection in server side in application deployment decriptor file.
so we can easly get lookup JNDI and get the parameter.
we can also use service locator class.