Results 1 to 8 of 8

Thread: Spring with MySql.

  1. #1
    Join Date
    Aug 2004
    Posts
    5

    Default Spring with MySql.

    Hello,

    I am facing problem configuring the transaction manager for Mysql. Following is the configuration I have made in my spring config file.
    ===================
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName">
    <value>org.gjt.mm.mysql.Driver</value>
    </property>
    <property name="url">

    <value>jdbc:mysql://server:3306/test</value>

    </property>
    <property name="username">
    <value>testuser</value>
    </property>
    <property name="password">
    <value></value>
    </property>
    <property name="maxActive">
    <value>50</value>
    </property>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource">
    <ref local="dataSource"/>
    </property>
    <property name="mappingResources">
    <list>
    <value>../conf/Provider.hbm.xml</value>
    <value>../conf/Role.hbm.xml</value>
    <value>../conf/Schedule.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.M ySQLDialect</prop>
    <prop key="hibernate.show_sql">false</prop>
    <prop key="hibernate.use_outer_join">true</prop>
    <!-- <prop key="hibernate.cglib.use_reflection_optimizer">tru e</prop> -->
    <!-- <prop key="hibernate.default_schema">mysql</prop> -->
    <prop key="hibernate.max_fetch_depth">1</prop>
    <prop key="hibernate.jdbc.batch_size">0</prop>
    </props>
    </property>
    </bean>

    ====================

    I have several other services configured in the config file but they are working fine. At the startup I am calling preInstantiateSingletons() on the factory instance. This function call is giving me an error like:

    ===================
    ----- Root Cause -----
    java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.ja va:1647)
    at java.lang.Class.getDeclaredMethods(Class.java:1131 )
    at java.beans.Introspector$1.run(Introspector.java:11 26)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.beans.Introspector.getPublicDeclaredMethods(I ntrospector.java:1124)
    at java.beans.Introspector.getTargetMethodInfo(Intros pector.java:989)
    at java.beans.Introspector.getBeanInfo(Introspector.j ava:370)
    at java.beans.Introspector.getBeanInfo(Introspector.j ava:144)
    at org.springframework.beans.CachedIntrospectionResul ts.<init>(CachedIntrospectionResults.java:85)
    at org.springframework.beans.CachedIntrospectionResul ts.forClass(CachedIntrospectionResults.java:62)
    at org.springframework.beans.BeanWrapperImpl.setWrapp edInstance(BeanWrapperImpl.java:190)
    at org.springframework.beans.BeanWrapperImpl.<init>(B eanWrapperImpl.java:168)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:184)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:159)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:172)
    at com.imc.hfehr.util.StartupManager.init(StartupMana ger.java:102)
    at org.apache.struts.action.ActionServlet.initModuleP lugIns(ActionServlet.java:1158)
    at org.apache.struts.action.ActionServlet.init(Action Servlet.java:473)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:211)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1029)
    at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:862)
    at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4013)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4357)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:789)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:478)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:480)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:2313)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:556)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:284)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:422)

    ===================

    Can anybody help me out with this ??

    Thanx in advance,


    Nitin

  2. #2

    Default

    This exception "java.lang.NoClassDefFoundError: javax/transaction/TransactionManager" usually indicates that you need jta.jar in your classpath. Do you have it?

  3. #3
    Join Date
    Aug 2004
    Posts
    5

    Default

    Yes you are right buddy. It was missing. I added it to my lib folder and in my project classpath.

    Thanx for the help

    Nitin.

  4. #4
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    <value>org.gjt.mm.mysql.Driver</value>
    Note too just for info that this driver is very old now. The com.mysql driver should really be used. See http://www.mysql.com/products/connector/j/
    Darren Davison.
    Public Key: 0xE855B3EA

  5. #5
    Join Date
    Aug 2004
    Location
    Germany, Magdeburg
    Posts
    279

    Default

    This driver is not old. It is provided by all new connector releases. It is just the name used before the connector-api was adopted by mysql AB. But anyways you are right. Using the com.mysql class is more readable but you can use both classes anyways. Doesn't matter, just a question of style.

  6. #6
    Join Date
    Aug 2004
    Posts
    1,110

    Default

    You are correct, the org.gjt.mm.mysql.Driver is now just a wrapper extending com.mysql.jdbc.Driver so either way you are using the same driver - just different names.

  7. #7
    Join Date
    Aug 2004
    Posts
    5

    Default

    Thanks guys,

    I have another question running on my mind. I am using the service "org.springframework.orm.hibernate.HibernateTransa ctionManager" and passing the "org.springframework.orm.hibernate.LocalSessionFac toryBean" reference. This transaction manager belongs to the Spring framework. But the exception said that jta.jar was missing which has the actual javax.transaction.TransactionManager. Is it that Spring Framework has tried to add a layer of additional services over the core jta api to support the list of features that the framework has. What are the services that are related to the Transactions.

  8. #8
    Join Date
    Aug 2004
    Posts
    109

    Default

    Quote Originally Posted by nitz_tech
    Thanks guys,

    I have another question running on my mind. I am using the service "org.springframework.orm.hibernate.HibernateTransa ctionManager" and passing the "org.springframework.orm.hibernate.LocalSessionFac toryBean" reference. This transaction manager belongs to the Spring framework. But the exception said that jta.jar was missing which has the actual javax.transaction.TransactionManager. Is it that Spring Framework has tried to add a layer of additional services over the core jta api to support the list of features that the framework has. What are the services that are related to the Transactions.
    Hibernate requires that jar to be on classpath, so it probably has very little to do with Spring.
    Thanks,
    Alex.

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Replies: 5
    Last Post: Aug 9th, 2008, 05:30 AM
  3. Spring, JDBC and MySQL
    By rlynn in forum Data
    Replies: 4
    Last Post: Aug 19th, 2005, 07:42 AM
  4. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •