This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes JBoss JSTL Datasource issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JBoss JSTL Datasource issue" Watch "JBoss JSTL Datasource issue" New topic
Author

JBoss JSTL Datasource issue

MK Shikarpuri
Greenhorn

Joined: Jan 21, 2004
Posts: 9
JBoss version: jboss-4.2.1.GA

Hello,
I have configured my Oracle datasource successfully and it works but when I extract data using Connection Pool. But when I try to use the same datasource for a JSTL <sql:setDataSource> tag, I get the following error:

org.apache.jasper.JasperException: An exception occurred processing JSP page /showAirCrafts.jsp at line 9

7: <sql:setDataSource var="ds" dataSource="java:/jdbc/oracleDS"/>
8:
9: <sql:query dataSource="${ds}" var="date" sql="SELECT sysdate FROM DUAL"/>

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:518)
...

root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "No suitable driver"


*************** oracle-ds.xml ************

<local-tx-datasource>
<jndi-name>jdbc/oracleDS</jndi-name>
<connection-url>
jdbcracle:thin:@xxx.xxx.xx.xxx:1521:f35test
</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>xxxxxx</user-name>
xxxxxxx
...
</local-tx-datasource>

************************************

***********DBConnection.java******(THIS WORKS)
...
javax.sql.DataSource ds = (javax.sql.DataSource) initialContext
.lookup("java:comp/env/jdbc/oracleDS");
...
************************************

*******************jboss-web.xml*********
...
<resource-ref>
<res-ref-name>jdbc/pmaDS</res-ref-name>
<jndi-name>java:/jdbc/pmaDS</jndi-name>
</resource-ref>
...
***************************************

****************web.xml*****************
...
<resource-ref>
Oracle Connection
<res-ref-name>jdbc/oracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
************************************

**************JSP (THIS DOESN'T WORK)*****
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
...
<sql:setDataSource var="ds" dataSource="java:/jdbc/oracleDS"/>

<sql:query dataSource="${ds}" var="date" sql="SELECT sysdate FROM DUAL"/>
...
*****************************************


I am new to JSTL. Any help would be appreciated.

Thank you
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9953
    
161

root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "No suitable driver"


Can you post the entire exception stacktrace? Also, where have you placed the jar file containing the database driver?


[My Blog] [JavaRanch Journal]
MK Shikarpuri
Greenhorn

Joined: Jan 21, 2004
Posts: 9
Got it working. Had to remove the "var" variable from the <sql:setDatasource> tag

<sql:setDataSource dataSource="java:/jdbc/oracleDS"/>
 
 
subject: JBoss JSTL Datasource issue
 
Similar Threads
Problem with look up JNDI on JBOSS
how to connect different datasources using multiple datasource using ENC
Could not create connection !!!!
Define DataSource in META-INF/context.xml ?
JBoss 3.2 and MySQL - Could not dereference DataSource object