Stax Developer Community

Developer Community

siva

Web Application with Struts2 + Hibernate + MySql

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

Views: 122

Tags: hibernate, mysql, stax

Comment

You need to be a member of Stax Developer Community to add comments!

Join Stax Developer Community

andre m Comment by andre m on August 4, 2010 at 5:24am
sorry xml missing again... basically my question is did you make sure you have the full:
< stax-web-app xmlns="http://www.stax.net/xml/webapp/1" >
< app-id & gt MY_APP_ID </ app-id & gt
< resource name="" ...... >
yada yada....
andre m Comment by andre m on August 4, 2010 at 5:20am
oops... the full xml wasn't included there... will try again:




myapp

application.environment prod





andre m Comment by andre m on August 4, 2010 at 5:18am
Hi,
only new to stax myself but have been resolving issues with DS etc...

Do you have a fully expanded stax-web.xml file? e.g.



myapp

application.environment prod

Quick Links

Send Feedback

If you have any questions or feedback about Stax, please drop us a note.

© 2012   Created by Spike Washburn.

Badges  |  Report an Issue  |  Terms of Service