Announcement Announcement Module
Collapse
No announcement yet.
integration problem with hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • integration problem with hibernate

    Hello everyone. I am trying integration hibernate to a spring app, i have readed in internet that you nead to replace the hibernate configuration file by a bean representing the sessionfactory. I tried to do so but i have a 503 error page everytime. Here is the applicationContext.xml:
    Code:
     
    <?xml version="1.0" encoding="UTF-8"?>
     
    <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:aop="http://www.springframework.org/schema/aop"
             xmlns:tx="http://www.springframework.org/schema/tx"
             xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
               http://www.springframework.org/schema/aop
               http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
               http://www.springframework.org/schema/tx
               http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
     
        <!-- the parent application context definition for the springapp application -->
     
        <bean id="productManager" class="springapp.service.SimpleProductManager">
            <property name="productDao" ref="productDao"/>
        </bean>
     
        <bean id="productDao" class="springapp.repository.JdbcProductDao">
            <property name="dataSource" ref="dataSource"/>
        </bean>
    <!--
        <bean id="productDao" class="springapp.repository.p2">
        </bean>
    -->
        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="${jdbc.driverClassName}"/>
            <property name="url" value="${jdbc.url}"/>
            <property name="username" value="${jdbc.username}"/>
            <property name="password" value="${jdbc.password}"/>
        </bean>
     
        <bean id="propertyConfigurer"
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:jdbc.properties</value>
                </list>
            </property>
        </bean>
     
        <bean id="transactionManager"
              class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource"/>
        </bean>
     
        <bean id="exampleSessionFactory"
           class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
         <property name="dataSource">
             <ref local="dataSource"/>
         </property>
         <property name="mappingLocations">
             <list>
                 <value>
                     classpath:Product.hbm.xml
                 </value>
             </list>
         </property>
     
        </bean>
     
    </beans>
    the error come from the bean exampleSessionFactory because evry time i remove it everything works fine but i cant use hibernate.

  • #2
    1) You are using a wrong transaction manager for hibernate
    2) Post the stacktrace

    Don't crosspost!!!!

    Comment


    • #3
      Sorry for the crosspost i didn't mean to do it.
      Yes your right i used a bad transaction manager i corrected it but i have a new problem i have the following error :No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here. to correct this error i documented myself and i found that i have to use TransactionProxyFactoryBean and that's what i did but i still have the problem here is my context file:
      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:p="http://www.springframework.org/schema/p"
             xmlns:aop="http://www.springframework.org/schema/aop"
             xmlns:tx="http://www.springframework.org/schema/tx"
             xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
          
          <!--bean id="propertyConfigurer"
                class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
                p:location="/WEB-INF/jdbc.properties" />
          
          <bean id="dataSource"
                class="org.springframework.jdbc.datasource.DriverManagerDataSource"
                p:driverClassName="${jdbc.driverClassName}"
                p:url="${jdbc.url}"
                p:username="${jdbc.username}"
                p:password="${jdbc.password}" /-->
          
          <!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
          <bean id="implementationProduit" class="akatsuki.domain.service.implProduit">
              <property name="productDao" ref="produitDaoHibernate"/>
          </bean>
      
          <bean id="produitDaoHibernate" class="akatsuki.domain.repositry.impl.ProduitDaoHibernate">
              <property name="sessionFactory" ref="SessionFactory"/>
          </bean>
      
          <bean id="traitement" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
              <property name="transactionManager" ref="TransactionManager"/>
              <property name="target" ref="produitDaoHibernate"/>
              <property name="transactionAttributes">
                  <props>
                      <prop key="insert*">PROPAGATION_REQUIRED</prop>
                      <prop key="update*">PROPAGATION_REQUIRED</prop>
                      <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
                  </props>
              </property>
          </bean>
      
          <bean id="SessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
              <property name="hibernateProperties">
                  <props>
                      <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
                      <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/cmd</prop>
                      <prop key="hibernate.connection.username">root</prop>
                      <prop key="hibernate.connection.password"></prop>
                      <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                  </props>
              </property>
          </bean>
      
          <bean id="TransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
              <property name="sessionFactory"><ref local="SessionFactory"/></property>
          </bean>
      
      
      
      
      
      
      
      </beans>
      and here is the target bean :
      Code:
      /*
       *
       * To change this template, choose Tools | Templates
       * and open the template in the editor.
       */
      
      package akatsuki.domain.repositry.impl;
      import akatsuki.domain.model.Produit;
      import akatsuki.domain.repositry.ProductDao;
      import java.io.FileWriter;
      import java.util.ArrayList;
      import java.util.Iterator;
      import java.util.List;
      import org.hibernate.Query;
      import org.hibernate.Session;
      import org.hibernate.SessionFactory;
      /**
       *
       * @author hamza
       */
      public class ProduitDaoHibernate implements ProductDao{
          private SessionFactory sessionFactory;
          public List<Produit> getProduits() {
              List<Produit>lst;
              lst=new ArrayList<Produit>();
              /*Produit p = new Produit();
              p.setId(11);
              p.setNom("Giggs");
              lst.add(p);*/
              Session session = sessionFactory.getCurrentSession();
              Query req = session.createQuery("select id,nom from Produit");
              FileWriter fw=null;
              try{
              fw = new FileWriter("D:\\n.txt");
              fw.write("l");
              fw.flush();
              fw.close();
              }catch(Exception e){
      
              }
              int i=0;
              for(Iterator it = req.iterate();it.hasNext();){
                  Produit p = new Produit();
                  Object[]ligne=(Object[])it.next();
                  p.setId(Integer.parseInt(ligne[0].toString()));
                  p.setNom(String.valueOf(ligne[1]));
                  lst.add(p);
                  try{
                  fw.write(String.valueOf(i));
                  fw.flush();
                  fw.close();
                  }
                  catch(Exception e){
      
                  }
              }
      
              return lst;
          }
      
          public void setSessionFactory(SessionFactory sessionFactory) {
              this.sessionFactory = sessionFactory;
          }
          
      
      }
      Correct im if i'am wrong the TransactionProxyFactoryBean serves to wrap a bean so that he can use transaction methods taht's why i specified in the target bean my dao bean. and for the transactionattributes when i do something like that insert* it means every sql statement who begin with insert to be propageted and everything else * to be read-only?

      Comment


      • #4
        I suggest the spring reference guide, especially the part about transactions. Next to that you don't have to use a TransactionalProxyFactoryBean anymore there are better ways.

        Comment


        • #5
          I'am reading the reference guide but still i want to know where the error is.It will help me a lot.

          Comment


          • #6
            Can be a couple of issues.

            1) You aren't using the proxied instance
            2) You aren't using an ApplicationContext but a BeanFactory
            3) Your undertanding of the transactional rules is wrong (it matched METHOD names it has nothing to do with sql).

            Comment


            • #7
              your right for third point that's why i questioned you about it it's the name of the method that must begin with insert.but for the two other point's i dont understand you. specially for the first one you say that i dont use the proxied bean wich is produitDaoHibernate. Im using it(at least that's what i think) when i am affecting it to my service layer bean(implementationProduit). Sorry if this question are too noob but i am an asp.net developper and im stuck with an existing spring project where i have to integrate hibernate to it, so i had to learn spring and hibernate from scratch.
              Last edited by united4life; Sep 27th, 2009, 04:42 PM.

              Comment


              • #8
                I suggest you take a look at the sample project.

                Comment


                • #9
                  can you tell me what do you mean by I'm not using the proxied bean. Because the source is at work and I don't have it with me I can only use it when I'm in work so to win some time could you clarify this point. Normally when in my dao I call the getCurrentSession() Spring must create a new session because normally if my config is correct my Dao bean should be wrapped by the transactionProxyBean but it's not so when you say I'm not using the proxied bean it makes sense with the error. So please could you clarify this point. I've read the petClinic example and I have understand it but I still didn't found the solution.

                  Comment


                  • #10
                    I've read the petClinic example and I have understand it but I still didn't found the solution.
                    If you did you would have the solution .

                    Only declaring a TransactionProxyFactoryBean doesn't do anything you have to use that instead of the actual dao. That is also the reason that it isn't recommended anymore because it is verbose and quite easy to forget to use it instead of the unproxied class. (I suggest chapter 6 and proxy based aop of that chapter).

                    Either replace it with the easier and more powerful aop:config and tx:advice (again check the reference guide) or make your actual dao an anonymous inner class declaration of the TPFB.

                    Code:
                    <bean id="produitDaoHibernate" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
                    	<property name="transactionManager" ref="TransactionManager"/>
                    	<property name="target">
                    		<bean class="akatsuki.domain.repositry.impl.ProduitDaoHibernate">
                    			<property name="sessionFactory" ref="SessionFactory"/>
                    		</bean>
                    	</property>
                    	<property name="transactionAttributes">
                    		<props>
                    			<prop key="insert*">PROPAGATION_REQUIRED</prop>
                    			<prop key="update*">PROPAGATION_REQUIRED</prop>
                    			<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
                    		</props>
                    	</property>
                    </bean>

                    Comment


                    • #11
                      I can't test this right now but it seems that it can be the solution.
                      In the same time I was seraching for another solution and I found about the interceptors coupled with the ProxyFactoryBean(I think it's that what you mean by powerful aop config)
                      here is a good source about the subject:
                      Code:
                       
                      
                      <?xml version="1.0" encoding="UTF-8"?>
                      
                      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
                      
                       
                      
                      <beans>    
                      
                      <!--                            HIBERNATE                               -->
                      
                          <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                      
                              <property name="mappingResources">
                      
                                  <list>
                      
                                      <value>fr/gestentrep2/utilisateurs/pojos/Utilisateur.hbm.xml</value>
                      
                                      <value>fr/gestentrep2/voitures/pojos/Voiture.hbm.xml</value>
                      
                                  </list>
                      
                              </property>        
                      
                              <property name="hibernateProperties">
                      
                                  <props>
                      
                              <prop key="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</prop>
                      
                              <prop key="hibernate.connection.url">jdbc:mysql://localhost/gestentrep2</prop>
                      
                              <prop key="hibernate.connection.username">root</prop>
                      
                              <prop key="hibernate.connection.password"></prop>
                      
                              <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                      
                              <prop key="hibernate.show_sql">true</prop>
                      
                              <!--  <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>-->
                      
                              <prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
                      
                              <prop key="hibernate.hbm2ddl.auto">update</prop>
                      
                                      <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
                      
                                  </props>
                      
                              </property>        
                      
                          </bean>
                      
                       
                      
                          <bean id="myTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                      
                              <property name="sessionFactory"><ref local="mySessionFactory"/></property>
                      
                          </bean>
                      
                      <!--                            /HIBERNATE                               -->
                      
                       
                      
                       
                      
                      <!--                        MODE TRANSACTIONNEL                          -->
                      
                          <bean id="myUserTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
                      
                              <property name="transactionManager" ref="myTransactionManager"/>
                      
                              <property name="transactionAttributeSource">
                      
                                  <value>fr.gestentrep2.utilisateurs.services.ISpringUserService.*=PROPAGATION_REQUIRED</value>
                      
                              </property>
                      
                          </bean>
                      
                          
                      
                          <bean id="mySpringUserServicesImpl" class="fr.gestentrep2.utilisateurs.services.spring.SpringUserServicesImpl">
                      
                              <property name="serviceDAO" ref="myHibernateUserService"/>
                      
                          </bean>
                      
                       
                      
                          <bean id="myUserService" class="org.springframework.aop.framework.ProxyFactoryBean">
                      
                              <property name="proxyInterfaces">
                      
                                  <value>fr.gestentrep2.utilisateurs.services.ISpringUserService</value>
                      
                              </property>
                      
                              <property name="interceptorNames">
                      
                                  <list>
                      
                                      <value>myUserTransactionInterceptor</value>
                      
                                      <value>mySpringUserServicesImpl</value>
                      
                                  </list>
                      
                              </property>
                      
                          </bean>
                      
                      <!--                        /MODE TRANSACTIONNEL                          -->
                      
                          
                      
                          
                      
                          <bean id="myHibernateUserService" class="fr.gestentrep2.utilisateurs.services.hibernate.HibernateUserServiceImpl">
                      
                              <property name="sessionFactory"><ref local="mySessionFactory"/></property>        
                      
                          </bean>
                      
                          
                      
                      </beans>
                      i didn't understant one thing it's the transactionAttributeSource attribute.And also if i leave current config and i made my dao bean an inner to the TransactionProxyBean will it be still visible for the service bean and finnaly what it's more logical to prxify the beans of the service layer or the one of persistance layer i think it's best if it's the service ones.And also thank you for your help.

                      Comment


                      • #12
                        In the same time I was seraching for another solution and I found about the interceptors coupled with the ProxyFactoryBean(I think it's that what you mean by powerful aop config)
                        No that wasn't what I meant with powerful aop config... I meant this.

                        Code:
                        <<?xml version="1.0" encoding="UTF-8"?>
                        <beans xmlns="http://www.springframework.org/schema/beans"
                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                             xmlns:aop="http://www.springframework.org/schema/aop"
                             xmlns:tx="http://www.springframework.org/schema/tx"
                             xsi:schemaLocation="
                             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">  
                        
                        <!--                            HIBERNATE                               -->
                        
                            <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                                <property name="mappingResources">
                                    <list>
                                        <value>fr/gestentrep2/utilisateurs/pojos/Utilisateur.hbm.xml</value>
                                        <value>fr/gestentrep2/voitures/pojos/Voiture.hbm.xml</value>
                                    </list>
                                </property>        
                                <property name="hibernateProperties">
                                    <props>
                        				<prop key="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</prop>
                        				<prop key="hibernate.connection.url">jdbc:mysql://localhost/gestentrep2</prop>
                        				<prop key="hibernate.connection.username">root</prop>
                        				<prop key="hibernate.connection.password"></prop>
                        				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                        				<prop key="hibernate.show_sql">true</prop>
                        				<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
                        				<prop key="hibernate.hbm2ddl.auto">update</prop>
                                        <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
                                    </props>
                                </property>        
                            </bean>
                        
                         
                        
                            <bean id="myTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                                <property name="sessionFactory" ref="mySessionFactory"/>
                            </bean>
                        
                        <!--                            /HIBERNATE                               -->
                         
                        
                        <!--                        MODE TRANSACTIONNEL                          -->
                        
                        	<tx:advice id="txAdvice" transaction-manager="myTransactionManager">
                        		<tx:attributes>
                        			<!-- all methods starting with 'get' are read-only -->
                        			<tx:method name="get*" read-only="true"/>
                        			<!-- other methods use the default transaction settings (see below) -->
                        		</tx:attributes>
                        			<tx:method name="*"/>
                        	</tx:advice>
                        
                        	<aop:config>
                        		<!-- Intercept every public method call in ServicesImpl classes in the services (and sub) package -->
                        		<aop:pointcut id="serviceMethod" expression="execution(* fr.gestentrep2.utilisateurs.services.*.*ServicesImpl.*(..))" />
                        		<!-- Apply transactions for every serviceMethod -->
                        		<aop:advisor pointcut-ref="serviceMethod" advice-ref="txAdvice" />
                        	</aop:config>
                        
                          
                        <!--                        /MODE TRANSACTIONNEL                          -->
                        
                            <bean id="mySpringUserServicesImpl" class="fr.gestentrep2.utilisateurs.services.spring.SpringUserServicesImpl">
                                <property name="serviceDAO" ref="myHibernateUserService"/>
                        	</bean>
                        
                            <bean id="myHibernateUserService" class="fr.gestentrep2.utilisateurs.services.hibernate.HibernateUserServiceImpl">
                                <property name="sessionFactory" ref="mySessionFactory"/>
                            </bean>  
                        
                        </beans>
                        i didn't understant one thing it's the transactionAttributeSource attribute.And also if i leave current config and i made my dao bean an inner to the TransactionProxyBean will it be still visible for the service bean and finnaly what it's more logical to prxify the beans of the service layer or the one of persistance layer i think it's best if it's the service ones.And also thank you for your help.
                        As I already mentioned a couple of times read the reference guide that explains all of that. Especially read chapter 6 (especially 6.6) as that explains proxy based AOP and how to use it.

                        Comment


                        • #13
                          I changed my approch and i decided to use transaction with aop and advices but i have a new problem i have a 503 error.here is my context:
                          Code:
                          <?xml version="1.0" encoding="UTF-8"?>
                          <beans xmlns="http://www.springframework.org/schema/beans"
                                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                 xmlns:p="http://www.springframework.org/schema/p"
                                 xmlns:aop="http://www.springframework.org/schema/aop"
                                 xmlns:tx="http://www.springframework.org/schema/tx"
                                 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                                 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                                 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
                          
                              <!--bean id="propertyConfigurer"
                                    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
                                    p:location="/WEB-INF/jdbc.properties" />
                          
                              <bean id="dataSource"
                                    class="org.springframework.jdbc.datasource.DriverManagerDataSource"
                                    p:driverClassName="${jdbc.driverClassName}"
                                    p:url="${jdbc.url}"
                                    p:username="${jdbc.username}"
                                    p:password="${jdbc.password}" /-->
                          
                              <!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
                              <bean id="implementationProduit" class="akatsuki.domain.service.implProduit">
                                  <property name="productDao" ref="produitDaoHibernate"/>
                              </bean>
                          
                              <bean id="produitDaoHibernate" class="akatsuki.domain.repositryimpl.ProduitDaoHibernate" >
                                  <property name="sessionFactory" ref="SessionFactory"/>
                              </bean>
                          
                          
                              <bean id="SessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                                  <property name="hibernateProperties">
                                      <props>
                                          <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
                                          <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/achat</prop>
                                          <prop key="hibernate.connection.username">root</prop>
                                          <prop key="hibernate.connection.password">bankai</prop>
                                          <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                                      </props>
                                  </property>
                          
                              </bean>
                          
                          
                              <bean id="TransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                                  <property name="sessionFactory"><ref local="SessionFactory"/></property>
                              </bean>
                          
                              <tx:advice id="adviceCRUD" transaction-manager="TransactionManager">
                                  <tx:attributes>
                                      <tx:method name="*" propagation="REQUIRED"/>
                                  </tx:attributes>
                              </tx:advice>
                          
                              <aop:config>
                                  <aop:pointcut id="pointCutProduit" expression="execution(* akatsuki.domain.service.*(..))"/>
                                  <aop:advisor advice-ref="adviceCRUD" pointcut-ref="pointCutProduit"/>
                              </aop:config>
                          
                          </beans>
                          Code:
                          INFO: Created virtual server server
                          INFO: Created virtual server __asadmin
                          INFO: Started bundle org.glassfish.deployment.dol [8]
                          INFO: Started bundle org.glassfish.web.web-core [123]
                          INFO: Dual registration of jndi stream handler: factory already defined
                          INFO: Unknown loader 106.0 class org.apache.felix.framework.searchpolicy.ContentClassLoader
                          INFO: Started bundle org.glassfish.web.jstl-connector [112]
                          INFO: Started bundle org.glassfish.web.jsf-connector [118]
                          INFO: Using com.sun.enterprise.transaction.JavaEETransactionManagerSimplifiedDelegate as the delegate
                          INFO: Started bundle org.glassfish.connectors.work-management [34]
                          INFO: Started bundle org.glassfish.common.glassfish-ee-api [46]
                          INFO: Started bundle org.glassfish.connectors.connectors-internal-api [104]
                          INFO: policy.loading
                          INFO: Started bundle org.glassfish.web.war-util [114]
                          INFO: Started bundle org.glassfish.security.websecurity [108]
                          INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@1b14530 class org.glassfish.internal.api.DelegatingClassLoader
                          INFO: PWC1412: WebModule[/WebApplication1] ServletContext.log():Initializing Spring root WebApplicationContext
                          INFO: Root WebApplicationContext: initialization started
                          INFO: Refreshing [email protected]13c66d8: display name [Root WebApplicationContext]; startup date [Tue Sep 29 02:26:24 CEST 2009]; root of context hierarchy
                          INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
                          GRAVE: Context initialization failed
                          org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
                                  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:385)
                                  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:313)
                                  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
                                  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
                                  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:158)
                                  at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
                                  at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
                                  at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:97)
                                  at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:411)
                                  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:338)
                                  at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:251)
                                  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190)
                                  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
                                  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4623)
                                  at org.apache.catalina.core.StandardContext.start(StandardContext.java:5323)
                                  at com.sun.enterprise.web.WebModule.start(WebModule.java:456)
                                  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:922)
                                  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:906)
                                  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
                                  at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2205)
                                  at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1890)
                                  at com.sun.enterprise.web.WebApplication.start(WebApplication.java:85)
                                  at com.sun.enterprise.v3.server.ApplicationLifecycle.start(ApplicationLifecycle.java:560)
                                  at com.sun.enterprise.v3.server.ApplicationLifecycle.start(ApplicationLifecycle.java:547)
                                  at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:189)
                                  at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:260)
                                  at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:97)
                                  at com.sun.enterprise.v3.server.ApplicationLoaderInjector.postConstruct(ApplicationLoaderInjector.java:61)
                                  at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:150)
                                  at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:90)
                                  at java.security.AccessController.doPrivileged(Native Method)
                                  at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:87)
                                  at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
                                  at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
                                  at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
                                  at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
                                  at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:203)
                                  at com.sun.enterprise.v3.server.AppServerStartup$1.run(AppServerStartup.java:116)
                          Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
                                  at java.lang.Class.forName0(Native Method)
                                  at java.lang.Class.forName(Class.java:169)
                                  at org.springframework.aop.config.ConfigBeanDefinitionParser.class$(ConfigBeanDefinitionParser.java:209)
                                  at org.springframework.aop.config.ConfigBeanDefinitionParser.createPointcutDefinition(ConfigBeanDefinitionParser.java:535)
                                  at org.springframework.aop.config.ConfigBeanDefinitionParser.parsePointcut(ConfigBeanDefinitionParser.java:472)
                                  at org.springframework.aop.config.ConfigBeanDefinitionParser.parse(ConfigBeanDefinitionParser.java:143)
                                  at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
                          when i remove the aop:config tag i dont have the 503 error.
                          Last edited by united4life; Sep 28th, 2009, 08:38 PM.

                          Comment


                          • #14
                            I found where the error was i was missing aspectjweaver.jer so I just downloaded it and put it on the lib directory of my projects and it worked like a charm.I also found two other ways using the annotions and also one simplier way is by using i high level approch with getHibernateTemplate.And also thank you Marten for your help.

                            Comment


                            • #15
                              for the benefits of the community... i think it will helps a lot..

                              please allow us to see the whole running configuration and classes...

                              Comment

                              Working...
                              X