lundi 28 mai 2018

Tomcat can not find current representation of target

I have a problem with my simple web app. I have a project named books. enter image description here

It is visible in tomcat and deployed succesfuly. I have following project structure in eclipse: enter image description here

I need to use datasource, so I have books.xml in {tomcat9}/conf/Catalina/localhost/books.xml as my context file with following content:

<Context docBase="E:\eclipse_workspace\Books\WebContent\WEB-INF\classes">

  <Resource name="jdbc/dbname" auth="Container" 
            type="javax.sql.DataSource"
            description="Books Database" 
            driverClassName="org.apache.derby.jdbc.ClientDriver"
            url="jdbc:derby://localhost:1527/dbname"
            username="admin"
            password="password"
            maxActive="20" /> 
</Context>

There is content of my web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
        http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="WebApp_ID" version="3.1">
    <display-name>Books Management</display-name>

    <servlet>
        <display-name>Books Controller</display-name>
        <servlet-name>BookServlet</servlet-name>
        <servlet-class>BookServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>BookServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

And this is what I get trying to test my app:

enter image description here

Any ideas what may be wrong? The clue is when I had incorrect context file (db.xml instead of books.xml) I had NullPointerException when getting datasource. Now When name is correct, it doesn't even give an error.




Aucun commentaire:

Enregistrer un commentaire