Using Maven to Deploy on Embedded Tomcat with a Datasource -


I have a multi module Moven Web Application, which uses Hibernate.

I use tomato: Everything has been working fine so far to run the run target on Maven's embedded tomeet server.

But now I have to switch from a clear JDBC configuration to the data source in Hibernate. I did the following:

  • changed hibernate.properties

  hibernate.connection.driver_class = oracle.jdbc. OracleDriver hibernate.connection.url = JDBC: somejdbcurl hibernate.connection.username = AUSER hibernate.connection.password = aPassword  

the
  hibernate.connection. datasource = java: comp / env / JDBC / DataSourceName  
  • web.xml I
  & lt Added; Resource Ref & gt; & Lt; Race-referee-name & gt; JDBC / DataSourceName & lt; / Race-referee-name & gt; & Lt; Race Type & gt; Javax.sql.DataSource & lt; / Race Type & gt; & Lt; Race writing & gt; Container & lt; / Writing the race & gt; & Lt; / Resources Ref & gt;  
  • added context.xml alongside web.xml with the following content:
 < Code> & lt; Context & gt; & Lt; Resource name = "JDBC / DataSourceName" authentication = "container" type = "javax.sql.DataSource" username = "AUSER" password = "aPassword" driverClassName = "oracle.jdbc.OracleDriver" url = "JDBC: somejdbcurl" Adiktmaktiv = "2" maximize = "2" /> & Lt; / Context & gt;  

This does not work, which is expected, because I did not find any way to provide jar file, which included the Oracle jdbc driver. I expect a ClassNotFound exception or something similar, but instead I got a

  org.hibernate.exception.GenericJDBCException: Can not open connection  

Due to the original reason in the stack:

  Due to: org.apache.tomcat.dbcp.dbcp.SQLNestedException: 'Connect URL' for class' JDBC driver can not be created Qiuo questions are:  
  • Why do not Tomcat know that I want to use it oracle driver?
  • How do I tell Tomcat? Jar file that contains the driver?

    You must add JDBC driver inside plug-in declaration:

      & lt; Plugin & gt; & Lt; Group & gt; Org.codehaus.mojo & lt; / Group & gt; & Lt; ArtifactId & gt; Badge-Maven-plugin & lt; / ArtifactId> & Lt; Version & gt; 1.0 & lt; / Edition & gt; & Lt; Configuration & gt; ... & lt; / Configuration & gt; & Lt; Dependency & gt; & Lt; Dependency & gt; & Lt; Group & gt; ... & lt; / Group & gt; & Lt; ArtifactId & gt; ... & lt; / ArtifactId> & Lt; Version & gt; ... & lt; / Edition & gt; & Lt; / Dependencies & gt; & Lt; / Dependencies & gt; & Lt; / Plugin & gt;  

    By the way, its default value is src / main / webapp / META-INF / context.xml .


Comments