Reputation: 13
I have this error and I do not understand why nor how to solve it. What is DataSource?
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: `jdbc/db1' is an unknown DataSource at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:909) at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:838) at org.apache.jsp.reservas.general.general.modificarshuttle_jsp._jspService(modificarshuttle_jsp.java:407) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
Upvotes: 1
Views: 494
Reputation: 11
I am not quiet sure about Jetty 9 server. I faced the same issue in Jetty 10 server, and later made it working by enabling jetty plus module.
Upvotes: 1
Reputation: 36
Perhaps you need to config the jetty.xml file when you start the jetty .
The parameters are these :
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<New id="z" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/db1</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">org.postgresql.Driver</Set>
<Set name="defaultAutoCommit">false</Set>
<Set name="url">jdbc:postgresql://ipaddress:port/database?loglevel=0</Set>
<Set name="username">user</Set>
<Set name="password">password</Set>
</New>
</Arg>
</New>
You may read the documentation about jetty :
<!-- =============================================================== -->
<!-- Configure the Jetty Server -->
<!-- -->
<!-- Documentation of this file format can be found at: -->
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax -->
<!-- -->
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
<!-- and can be mixed in. For example: -->
<!-- java -jar start.jar etc/jetty-ssl.xml -->
<!-- -->
<!-- See start.ini file for the default configuraton files -->
<!-- =============================================================== -->
Upvotes: 0
Reputation: 97
i think you have aquery like this
<sql:query var="var" dataSource="jdbc/db1">SELECT * FROM table_name
in your jsp file ,so you should define your datasource (connection of your database) in web.xml like this
<resource-ref>
<description>My DataSource Reference</description>
<res-ref-name>jdbc/DSTest</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
`
and define your database connection(name,url,and driver ) in your context.xml under META-INF folder
<New id="db1" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/db1</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://localhost:3306/databasename</Set>
<Set name="User">user</Set>
<Set name="Password">pass</Set>
</New>
</Arg>
</New>
this is taken from Datesource example
Upvotes: 1