Hi,
I was integrating existing Struts2 + Hibernate + MySql application into stax. I used to integrate hibernate and mysql thru jdbc connection string, but same is not possible in stax.
I used below configuration and run using 'stax run' in my workstation. Please let me know how to resolve this issue
webapp/WEB-INF/stax-web.xml
< resource name="jdbc/sgurusam_test" auth="Container" type="javax.sql.DataSource" >
< param name="username" value="sgurusam" /> < param name="password" value="sgurusam" /> < param name="url" value="jdbc:stax://sgurusam_test" /> </ resource >
webapp/WEB-INF/web.xml
< resource-ref>
< res-ref-name>jdbc/sgurusam_test</ res-ref-name>
< res-type>javax.sql.DataSource</ res-type>
< res-auth>Container</ res-auth>
</ resource-ref>
webapp/WEB-INF/classes/hibernate-cfg.xml
< hibernate-configuration>
< session-factory name="default">
< property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</ property>
< property name="connection.datasource">java:comp/env/jdbc/sgurusam_test</ property>
< property name="hibernate.show_sql">true
< property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</ property>
< property name="connection.pool_size">10</ property>
< property name="connection.autoReconnect">true</ property>
< property name="connection.autoReconnectForPools"> true </ property>
< property name="connection.is-connection-validation-required">true</ property>
< property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</ property>
< property name="hbm2ddl.auto">update</ property>
</ session-factory>
</ hibernate-configuration>
Exception:
Cannot create JDBC driver of class '' for connect URL 'null'
java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
at c.hibernate.HibernateUtil.(HibernateUtil.java:65)
at com.marketinnova.InitServlet.init(InitServlet.java:39)
Thanks
siva
You need to be a member of Stax Developer Community to add comments!
Join Stax Developer Community