Deploying java servlet code on jBoss for the first time and am having trouble with jndi/jdbc database connection. Code from long running Tomcat/Resin deployments look like: Context init = new InitialContext(); | Context ctx = (Context)init.lookup("java:comp/env"); | DataSource ds = (DataSource) ctx.lookup("jdbc/" + dbName); // dbname defined in Tomcat server.xml
With jBoss the above code gives: javax.naming.NameNotFoundException: jdbc not bound error. As per http://www.jboss.org/community/wiki/WhyDoIGetNameNotFoundException I have changed the last line to: DataSource ds = (DataSource) ctx.lookup("java:/" + dbName); // dbname defined in *-ds.xml for jBoss and this works. However, I would like to find a solution that works on both servers. I've looked through the JNDI Wiki and FAQ as suggested in the Sticky, but there's nothing obvious jumping out at me as to what I need to do. Thanks, Bob. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259007#4259007 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259007 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user