• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to configure Datasource in JBOSS

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am getting "datasource not bound" exception.Please help me to solve this.I have given the following details:

My datasource connection name is OracleDS.I have put that xml in server/default/deploy folder as oracle-ds.xml and classes12.jar folder.

In web.xml,i have included the following:

<resource-ref>
<description>DB Connection</description>
<res-ref-name>OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

In jboss-web.xml,
<jboss-web>
<resource-ref>
<res-ref-name>OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/OracleDS</jndi-name>
</resource-ref>
</jboss-web>

I have put the spring jars and jar files in the lib folder of WEB-INF

In a jsp file when i try to access like this
<%
String sql = "select * from emp";

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ResultSetMetaData rsm = null;
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"jnp://localhost:1099");

Context ctx = new InitialContext(env);
DataSource datasource= (DataSource) ctx.lookup("java:/OracleDS");
Connection con=datasource.getConnection();
stmt = conn.createStatement( );
rs = stmt.executeQuery(sql);
rsm = rs.getMetaData( );
int colCount = rsm.getColumnCount( );

%>
I am getting error as follows,
javax.naming.NameNotFoundException: OracleDS not bound
org.jnp.server.NamingServer.getBinding(NamingServe r.java:491)
org.jnp.server.NamingServer.getBinding(NamingServe r.java:499)
org.jnp.server.NamingServer.getObject(NamingServer .java:505)
org.jnp.server.NamingServer.lookup(NamingServer.ja va:278)
org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:610)
org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:572)
javax.naming.InitialContext.lookup(InitialContext. java:347)
org.apache.jsp.one_jsp._jspService(org.apache.jsp. one_jsp:66)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)


Please help me to solve this..........
 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, looks like this didn't land in the right forum. Moving it over to the JBoss forum...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic