java - Tomcat maven plugin: Unable to find jdbc -


by using tomcat7-maven-plugin launch spring web application needs connect mysql database. however, when attempting error "unable find jdbc".

error creating bean name 'datasource' defined in servletcontext resource [/web-inf/applicationcontext.xml]: invocation of init method failed; nested exception javax.naming.namenotfoundexception: n ame [jdbc/contentdatasource] not bound in context. unable find [jdbc]. 

my pom file includes.

     <plugin>         <groupid>org.apache.tomcat.maven</groupid>         <artifactid>tomcat7-maven-plugin</artifactid>         <version>2.2</version>         <configuration>             <port>9001</port>             <path>/webapp</path>             <serverxml>./src/main/tomcat/config/server.xml</serverxml>             <contextfile>./src/main/tomcat/config/context.xml</contextfile>         </configuration>         <dependencies>             <dependency>                 <groupid>mysql</groupid>                 <artifactid>mysql-connector-java</artifactid>                 <type>jar</type>                 <version>5.0.8</version>             </dependency>         </dependencies>     </plugin> 

context.xml file:

<?xml version='1.0' encoding='utf-8'?> <context>     <resourcelink global="jdbc/contentdatasource" name="jdbc/contentdatasource" type="javax.sql.datasource"/> </context> 

server.xml includes:

<globalnamingresources>     <resource name="jdbc/contentdatasource"               auth="container"               type="javax.sql.datasource"               driverclassname="org.gjt.mm.mysql.driver"               url="jdbc:mysql://database.lan/databasename"               username="root"               password="pass" /> </globalnamingresources> 

web.xml includes @ end:

    <resource-ref>         <res-ref-name>jdbc/contentdatasource</res-ref-name>         <res-type>javax.sql.datasource</res-type>         <res-auth>container</res-auth>     </resource-ref> </web-app> 

web-inf/applicationcontext.xml includes @ beginning:

<beans>     <bean id="datasource" class="org.springframework.jndi.jndiobjectfactorybean">         <property name="jndiname" value="java:comp/env/jdbc/contentdatasource" />         <property name="resourceref" value="true" />     </bean>      <bean id="transactionmanager" class="org.springframework.jdbc.datasource.datasourcetransactionmanager">         <property name="datasource">             <ref local="datasource" />         </property>     </bean> 

why jdbc not recognized?


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -