mysql - org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' -
i working on web based project using spring ,hybernate +jpa .i trying configure jta transactions atomkios backend mysql. not able setup application work mysql. web server tomcat 5.5.i trying cal jndi configured datasource .. here code
persistence.xml:
<persistence-unit name="exhub" transaction-type="jta"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <jta-data-source>java:comp/env/jdbc/exampleweb</jta-data-source> <mapping-file>meta-inf/orm.xml</mapping-file> <class>com.evolvus.common.model.talogin</class> <class>com.evolvus.common.model.tauser</class> ----------------- ----------------- <properties> <property name="hibernate.transaction.manager_lookup_class" value="com.atomikos.icatch.jta.hibernate3.transactionmanagerlookup"/> </ properties> </persistence-unit> </persistence>
orm.xml:
<description>evolvus solutions</description> <package>com.evolvus.common.model</package> <entity class="com.evolvus.common.model.tauser" name="tauser"> <table name="ta_user" /> <attributes> <id name="userid"> <column name="user_id"/> <generated-value strategy="table" /> </id> <basic name="username"> <column name="user_name" length="50" /> </basic> </attributes> </entity> --------------- -------------- --------------- </entity-mappings>
config.xml:
<beans: bean id="sessionfactory" class="org.springframework.orm.hibernate3.localsessionfactorybean"> <beans: property name="usetransactionawaredatasource" value="true" /> <beans: property name="hibernateproperties"> <beans: props> <beans: prop key="hibernate.dialect">${database.target}</beans:prop> <beans: prop key="hibernate.connection.isolation">3</beans:prop> <beans: prop key="hibernate.current_session_context_class">jta</beans:prop> <beans: prop key="hibernate.transaction.factory_class">com.atomikos.icatch.jta.hibernate3.atomikosjtatransactionfactory </beans: prop> <beans: prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.transactionmanagerlookup </beans: prop> <beans: prop key="hibernate.connection.release_mode">on_close</beans: prop> <beans: prop key="hibernate.show_sql">false</beans: prop> </beans: props> </beans: property> </beans: bean> <beans: bean id="jpatemplate" class="org.springframework.orm.jpa.jpatemplate"> <beans: property name="entitymanagerfactory"> <beans: ref bean="entitymanagerfactory" /> </beans: property> </beans: bean> <beans: bean id="entitymanagerfactory" class="org.springframework.orm.jpa.localcontainerentitymanagerfactorybean"> <beans: property name="persistenceunitname" value="payhub" /> <beans: property name="jpavendoradapter"> <beans:bean class="org.springframework.orm.jpa.vendor.hibernatejpavendoradapter"> <beans: property name="generateddl" value="false" /> <beans: property name="showsql" value="true" /> <beans: property name="databaseplatform" value="${database.target}" /> </beans: bean> </beans: property> <beans: property name="persistencexmllocation"> <beans: value>classpath:meta-inf/persistence.xml</beans:value> </beans: property> </beans: bean> </beans: beans>
and configured jndi in tomcat 5.5
apache software foundation\tomcat 5.5\conf.xml:
<resource name="jdbc/exampleweb" type="javax.sql.datasource" maxactive="4" maxidle="2" username="root" maxwait="5000" validationquery="select=1" driverclassname="com.mysql.jdbc.driver" password="roopt" url="jdbc\:mysql\://localhost\:3306/welcomehub"/> , application\web.xml <resource-ref> <description>paymentsdatabase</description> <res-ref-name>jdbc/exampleweb</res-ref-name> <res-type>javax.sql.datasource</res-type> <res-auth>container</res-auth> <res-sharing-scope>shareable</res-sharing-scope> </resource-ref>
my server staring fine when trying access db data getting following error in web browser
org.springframework.jdbc.cannotgetjdbcconnectionexception: not jdbc connection; nested exception org.apache.tomcat.dbcp.dbcp.sqlnestedexception: cannot create jdbc driver of class '' connect url 'null' org.springframework.jdbc.datasource.datasourceutils.getconnection(datasourceutils.java:82)
help me
i think application not finding mysql connector jar file or url misconfigured.
try following
- put mysql connector jar file under tomcat/common/lib gets picked before webapp classes.
change context.xml have resource below.
<resource name="jdbc/exampleweb" auth="container" type="javax.sql.datasource" maxactive="100" maxidle="30" username="root" maxwait="10000" driverclassname="com.mysql.jdbc.driver" password="roopt" url="jdbc:mysql://localhost:3306/welcomehub"/>
Comments
Post a Comment