Announcement Announcement Module
Collapse
No announcement yet.
spring-aop libs sems to have problem in spring 2.5 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring-aop libs sems to have problem in spring 2.5

    well this is my problem

    if I add this line

    PHP Code:
    <context:component-scan base-package="classpath:com.transporte.service" /> 
    to mi applicationContext I get this error


    PHP Code:
    INFOInitializing Spring root WebApplicationContext
    25
    /01/2008 15:52:50 org.apache.catalina.core.StandardContext listenerStart
    GRAVE
    Excepción enviando evento inicializado de contexto a instancia de escuchador de clase org.springframework.web.context.ContextLoaderListener
    org
    .springframework.beans.factory.BeanDefinitionStoreExceptionUnexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]; nested exception is java.lang.NoSuchMethodErrororg.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Ljava/lang/Object;)V
        at org
    .springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:405)
        
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:327)

    ..... 

    The problems seems to be in spring-aop.I read somewhere that this happend trought a change in the signature of registerAutoProxyCreatorIfNecessary() [of type Element rather than an Object]

    How do I solve this problem , is there a nigthy build that has resolved it already.

    thanks

    I am using spring 2.5, hibernate 3.2, tomcat 6.0.13 and mysql 5.03

  • #2
    I'm having exactly the same issue. The interesting piece though is that by changing the environment and the version of commons-logging I use, the error disappears.

    I suspect it might have to do with Classloading issues.

    I have some daos using JPA, used by some services that are finally consumed by a gui layer developed with the Echo2 library. Very typical scenario.

    Using commons-logging 1.1, I'm able to run my unit tests using my application context from inside Eclipse. However, if I run the same error described before:
    (org.springframework.aop.config.AopNamespaceUtils. registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Ljava/lang/ObjectV)

    I suspected the error had something to do with Logging because when the error happens, the following message is displayed:
    log4j:WARN No appenders could be found for logger (org.springframework.util.ClassUtils).
    log4j:WARN Please initialize the log4j system properly.

    When I start Tomcat with the full application, I get the same error. However, if I start Jetty, it works.

    Anyone faced this too? I can only suspect classpath/classloading issues. How come it runs inside Eclipse as JUnit tests and not outside?

    Important: when I switch to commons-logging 1.1.1, it stops working everywhere.

    I know it sounds crazy.

    Andre

    Comment


    • #3
      To provide more information, here is my 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:tx="http://www.springframework.org/schema/tx"
      	xmlns:context="http://www.springframework.org/schema/context"
      	xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-2.5.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
      
      	<bean id="dataSource"
      		class="com.mchange.v2.c3p0.ComboPooledDataSource"
      		destroy-method="close">
      		<property name="driverClass">
      			<value>org.apache.derby.jdbc.EmbeddedDriver</value>
      		</property>
      		<property name="jdbcUrl">
      			<value>jdbc:derby:rotatingAds;create=true;</value>
      		</property>
      		<property name="properties">
      			<props>
      				<prop key="c3p0.acquire_increment">5</prop>
      				<prop key="c3p0.idle_test_period">100</prop>
      				<prop key="c3p0.max_size">100</prop>
      				<prop key="c3p0.max_statements">0</prop>
      				<prop key="c3p0.min_size">10</prop>
      			</props>
      		</property>
      	</bean>
      
      	<bean id="entityManagerFactory"
      		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      		<property name="dataSource" ref="dataSource"/>
      		<property name="jpaVendorAdapter">
      			<bean
      				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
      				<property name="showSql" value="false" />
      				<property name="generateDdl" value="true" />
      				<property name="databasePlatform"
      					value="org.hibernate.dialect.DerbyDialect" />
      			</bean>
      		</property>
      	</bean>
      
      
      	<bean id="transactionManager"
      		class="org.springframework.orm.jpa.JpaTransactionManager" >
      		<property name="entityManagerFactory" ref="entityManagerFactory"/>
      	</bean>
      
      	<!-- Indicates transaction management is Annotation based and must be handled by the previously declared transaction Manager. -->
      	<tx:annotation-driven transaction-manager="transactionManager" />
      
      	<bean
      		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
      
       	<context:component-scan base-package="com.mycia.tst.rotatingAds.business, com.mycia.tst.rotatingAds.datalayer"/>
       	
      </beans>
      I am using Spring 2.5.1, Maven 2.0.7, Tomcat 6.0.14, Jetty 6 and JUnit 4.

      Comment


      • #4
        thanks you, you open my eyes, thats was my problem, I was using myeclipse libs. Now I am using only the libraries from spring framework 2.5 with dependencies.
        This config works fine for wath I am using:

        antlr-2.7.6.jar
        asm-2.2.3.jar
        asm-commons-2.2.3.jar
        aspectjrt.jar
        aspectjweaver.jar
        cglib-nodep-2.1_3.jar
        commons-collections.jar
        commons-logging.jar
        dir.txt
        dom4j-1.6.1.jar
        hibernate3.jar
        jta.jar
        log4j-1.2.14.jar
        mysql-connector-java-5.0.5-bin.jar
        spring.jar

        Comment


        • #5
          Unfortunately, not for me.

          To make matters worse, I just switched back to spring 2.5. Now, everything works under Eclipse JUnit runner, outside Eclipse with Jetty, outside Eclipse with maven 2 (surefire) test (JUnit 4).

          But not under Tomcat 6.0.13. Under tomcat, the error remains the same.

          This is what I'm using:
          Code:
          antlr-2.7.6.jar
          aopalliance-1.0.jar
          asm-1.5.3.jar
          asm-attrs-1.5.3.jar
          backport-util-concurrent-3.0.jar
          c3p0-0.9.1.2.jar
          cglib-2.1_3.jar
          commons-beanutils-1.7.0.jar
          commons-beanutils-core-1.7.0.jar
          commons-betwixt-0.7.jar
          commons-collections-3.2.jar
          commons-digester-1.6.jar
          commons-fileupload-1.1.jar
          commons-io-1.1.jar, commons-lang-2.1.jar
          commons-logging-1.0.2.jar 
          concurrent-1.3.4.jar
          derby-10.3.2.1.jar
          derbyclient-10.3.2.1.jar
          dom4j-1.6.1.jar
          echo2_Extras_App-0.3.jar
          echo2_Extras_WebContainer-0.3.jar
          echo2_FileTransfer_App-2.1.0.beta5.jar, echo2_FileTransfer_WebContainer-2.1.0.beta5.jar, echo2_WebContainer-2.1.0.rc2.jar
          echo2_WebRender-2.1.0.rc2.jar, echopointng-2.1.0.rc5.jar, 
          ehcache-1.3.0.jar
          geronimo-spec-jta-1.0.1B-rc4.jar
          hibernate-3.2.5.ga.jar, 
          hibernate-annotations-3.3.0.ga.jar, hibernate-commons-annotations-3.0.0.ga.jar, hibernate-entitymanager-3.3.1.ga.jar, 
          hibernate-validator-3.0.0.ga.jar, 
          javassist-3.3.ga.jar, 
          jboss-common-core-2.0.4.GA.jar, 
          jsr107cache-1.0.jar, 
          jstl-1.1.2.jar, 
          log4j-1.2.14.jar, 
          persistence-api-1.0.jar, 
          spring-aop-2.5.jar, 
          spring-beans-2.5.jar, 
          spring-context-2.5.jar, 
          spring-core-2.5.jar, 
          spring-dao-2.0.7.jar, 
          spring-jdbc-2.5.jar, 
          spring-orm-2.5.jar, 
          spring-remoting-2.0.7.jar, 
          spring-support-2.0.7.jar, 
          spring-tx-2.5.jar, 
          spring-web-2.0.7.jar, 
          standard-1.0.5.jar, 
          xercesImpl-2.6.2.jar, 
          xml-apis-1.0.b2.jar
          That's so frustrating.

          Comment


          • #6
            And another thing: I'm no longer using anything from context. No more context:component-scan. This is my new 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:tx="http://www.springframework.org/schema/tx"
            	xmlns:context="http://www.springframework.org/schema/context"
            	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">
            
            	<bean id="dataSource"
            		class="com.mchange.v2.c3p0.ComboPooledDataSource"
            		destroy-method="close">
            		<property name="driverClass">
            			<value>org.apache.derby.jdbc.EmbeddedDriver</value>
            		</property>
            		<property name="jdbcUrl">
            			<value>jdbc:derby:rotatingAds;create=true;</value>
            		</property>
            		<property name="properties">
            			<props>
            				<prop key="c3p0.acquire_increment">5</prop>
            				<prop key="c3p0.idle_test_period">100</prop>
            				<prop key="c3p0.max_size">100</prop>
            				<prop key="c3p0.max_statements">0</prop>
            				<prop key="c3p0.min_size">10</prop>
            			</props>
            		</property>
            	</bean>
            
            	<bean id="entityManagerFactory"
            		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            		<property name="dataSource" ref="dataSource"/>
            		<property name="jpaVendorAdapter">
            			<bean
            				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            				<property name="showSql" value="false" />
            				<property name="generateDdl" value="true" />
            				<property name="databasePlatform"
            					value="org.hibernate.dialect.DerbyDialect" />
            			</bean>
            		</property>
            	</bean>
            
            
            	<bean id="transactionManager"
            		class="org.springframework.orm.jpa.JpaTransactionManager" >
            		<property name="entityManagerFactory" ref="entityManagerFactory"/>
            	</bean>
            
            	<!-- Indicates transaction management is Annotation based and must be handled by the previously declared transaction Manager. -->
            	<tx:annotation-driven transaction-manager="transactionManager" />
            
            	<bean
            		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
            
            	
            	<bean id="phoneDao" class="com.mycia.tst.rotatingAds.datalayer.imp.PhoneDaoImpl"/>
            	<bean id="userDao" class="com.mycia.tst.rotatingAds.datalayer.imp.UserDaoImpl"/>
            	<bean id="databaseVersionDao" class="com.mycia.tst.rotatingAds.datalayer.imp.DatabaseVersionDaoImpl"/>
            
            	<bean id="phoneServices" class="com.mycia.tst.rotatingAds.business.imp.PhoneServicesImpl">
            		<property name="phoneDao" ref="phoneDao"/>
            	</bean>
            
            	<bean id="userServices" class="com.mycia.tst.rotatingAds.business.imp.UserServicesImpl">
            		<property name="userDao" ref="userDao"/>
            	</bean>
            
            	
             	<!-- The following bean is here to make sure the database is populated correctly -->
              	<bean class="com.mycia.tst.rotatingAds.business.imp.DatabaseInitializer" init-method="checkAndPopulateDataBase" >
              		<property name="userServices" ref="userServices"/>
              		<property name="databaseVersionDao" ref="databaseVersionDao"/>
              	</bean>
            </beans>

            Comment


            • #7
              After long hours, I figured out what the error was...

              I was loading both spring-dao-2.0.7.jar and spring-tx-2.5.jar.

              For some reason, the most recent maven distribution of spring moved packages org.springframework.dao and org.springframework.transaction to spring-tx-2.5.jar. Previously they were on spring-dao-2.0.7.jar.

              Not realizing that, I included both in the pom.xml - without paying attention to the actual content.

              Hence the issues; depending on the classloader used and the order the jars were loaded, sometimes the 2.0.7 version of org.springframework.transaction.config.AnnotationD rivenBeanDefinitionParser was picked instead of the 2.5 version - and they were linked against different versions of org.springframework.aop.config.AopNamespaceUtils.r egisterAutoProxyCreatorIfNecessary.
              Last edited by Andre Aragao; Jan 26th, 2008, 12:20 AM.

              Comment


              • #8
                I really recommend you to use only them libraries from the spring distribution, they are checked, maven doesn't work propery yet:

                http://sourceforge.net/project/showf...ease_id=565295

                If you don't know witch libraries you need remove them all and start adding from one to one when you deploy its throws a method not found exception , just find the name of the jar associated to the class in the inet and take it from the spring libs

                Comment


                • #9
                  Hi Andre,

                  We have the similar setup as you except I don't have problems with those two jar's you've specified in my maven I include the following. However their scope is defined as <scope>provided</scope> meaning that they will be in tomcat's lib dir. I have all of this in the tomcat lib dir.

                  Code:
                  acegi-security-1.0.5.jar
                  acegi-security-tiger-1.0.5.jar
                  annotations-api.jar
                  antlr-2.7.6.jar
                  aopalliance-1.0.jar
                  asm-1.5.3.jar
                  asm-attrs-1.5.3.jar
                  aspectjrt-1.5.3.jar
                  aspectjweaver-1.5.3.jar
                  casclient-2.1.1.jar
                  catalina-ant.jar
                  catalina-ha.jar
                  catalina-tribes.jar
                  catalina.jar
                  cglib-2.1_3.jar
                  commons-codec-1.3.jar
                  commons-collections-3.2.jar
                  commons-dbcp-1.2.jar
                  commons-lang-2.1.jar
                  commons-logging-1.1.jar
                  commons-pool-1.2.jar
                  concurrent-1.3.4.jar
                  dom4j-1.6.1.jar
                  ehcache-1.3.0.jar
                  el-api.jar
                  hibernate-3.2.5.ga.jar
                  hibernate-annotations-3.2.1.ga.jar
                  hibernate-commons-annotations-3.0.0.ga.jar
                  hibernate-entitymanager-3.2.1.ga.jar
                  hibernate-validator-3.0.0.ga.jar
                  itext-1.3.jar
                  jasper-el.jar
                  jasper-jdt.jar
                  jasper.jar
                  javassist-3.3.ga.jar
                  jboss-archive-browsing-5.0.0alpha-200607201-119.jar
                  jstl-1.1.2.jar
                  jta-1.0.1B.jar
                  jxl-2.6.3.jar
                  libs.tar
                  log4j-1.2.9.jar
                  mysql-connector-java-5.1.5-bin.jar
                  oro-2.0.8.jar
                  persistence-api-1.0.jar
                  poi-3.0.2-FINAL.jar
                  servlet-api.jar
                  spring-2.5.jar
                  spring-aop-2.5.jar
                  spring-beans-2.5.jar
                  spring-context-2.5.jar
                  spring-context-support-2.5.jar
                  spring-core-2.5.jar
                  spring-dao-2.0.7.jar
                  spring-hibernate3-2.0.7.jar
                  spring-jdbc-2.0.7.jar
                  spring-jpa-2.0.7.jar
                  spring-remoting-1.2.9.jar
                  spring-support-1.2.9.jar
                  spring-web-2.5.jar
                  spring-webmvc-2.5.jar
                  velocity-1.5.jar
                  xercesImpl-2.8.1.jar
                  xml-apis-1.0.b2.jar
                  I get the exact same error when deployed to tomcat with the exact same applicationContext.xml.

                  Code:
                  Caused by: java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Ljava/lang/Object;)V
                  The only weird thing is if I was to change the scope and remove it so that all the lib is packaged in with the war and deploy that it works fine? So I figured it had something to do with what was in my lib so did a fresh install of tomcat did a deploy with all the wars worked fine. Then I moved all the libraries from the WEB-INF/lib into the tomcat folder and all the sudden got the exact same error again. This really BOGGLES my mind.

                  Any thoughts?

                  Cheers,
                  Nathan.

                  Comment

                  Working...
                  X