Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Servlet.service() for servlet [...] in context with path [/...] threw exception [Servlet execution threw an exception] with root cause

I am trying to set a DataSource connection; the error I actually get is java.lang.AbstractMethodError: com.mysql.jdbc.Connection.isValid(I)Z

but the title's error pops up right above.

--

I have a caffeJdbc.java servlet with this DataSource setting

Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup("java:comp/env/jdbc/caffeDB");
Connection con = dataSource.getConnection();

--

This is the project web.xml setting, with servlet mapping and resource references

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>tjdbc</servlet-name>
    <servlet-class>caffeJdbc</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>tjdbc</servlet-name>
    <url-pattern>/caffeJdbc</url-pattern>
</servlet-mapping>

<resource-ref>
    <res-ref-name>jdbc/caffeDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

--

server.xml

<GlobalNamingResources>
 <Resource name="jdbc/caffeDB" 
 global="jdbc/caffeDB"
 url="jdbc:mysql://localhost:3306/caffe"/>
</GlobalNamingResources>

--

And this is the context.xml

<Context path="/JDBCDataSource">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <ResourceLink global="jdbc/caffeDB"
        name="jdbc/caffeDB"
        type="javax.sql.DataSource">
    </ResourceLink>
</Context>

I loaded both JDBC driver and the commons-dbcp2-2.1.1 one in the lib directory and in the path

like image 873
pedro Avatar asked Dec 06 '25 20:12

pedro


1 Answers

May be the JDBC Driver you are using is outdated, Please check that, You can see here for more info.

like image 110
parlad Avatar answered Dec 08 '25 09:12

parlad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!