[jboss-user] [JNDI/Naming/Network] - NullPointerException getting Datasource connection
cdmunoz
do-not-reply at jboss.com
Wed May 9 16:32:39 EDT 2007
Inside the same project I'm using both EJB 3.0 (with configuration in persistence.xml) and DAO with JDBC. I don't have problems accessing objects with EJB beacuse they are on a particular module, but I can't access any object with JDBC.
I got configured my oracle-xa-ds.xml as follow:
<xa-datasource>
<jndi-name>fmarketdb</jndi-name> . . . for EJB and
<xa-datasource>
<jndi-name>it</jndi-name> . . . for JDBC.
Jboss Application Server (jboss-4.0.3_SP1) inits the datasource without problems.
My jboss-web.xml:
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/it</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/it</jndi-name>
</resource-ref>
</jboss-web>
My web.xml:
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/it</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/it</jndi-name>
</resource-ref>
</jboss-web>
My Java source (jdk1.5.0_08):
protected Connection getConnection() throws Exception {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/it");
Connection conn = ds.getConnection();
conn.setAutoCommit(false);
return conn;
}
When I try to access an object through JDBC, I got the next error:
java.lang.NullPointerException at com.ceiba.corporativo.root.bo.BussinessLogicAbs.getConnection(BussinessLogicAbs.java:57)
and this because envCtx.lookup("jdbc/it") returns null and I don't understand why? Those are independent modules.
Can somebody help me please?
Does affect EJB configuration inside Jboss?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044477#4044477
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044477
More information about the jboss-user
mailing list