Announcement Announcement Module
Collapse
No announcement yet.
Spring 3.0.2 and Active MQ 5.4.1 Issues Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3.0.2 and Active MQ 5.4.1 Issues

    Not 100% sure this is the place to post this, but here it goes:

    I've had an issue for days and I can't find any information on this issue. I have searched this site the best I could and couldn't find anything that fixed my problem.

    I have a project with multiple modules in it a core, data-services, and messaging. It's a stand alone java jar that is a topic subscriber for JMS. The main class is in Core, and the data-services handles database transactions, and messaging handles listening on a spring jms container for messages, validates, and passes the data on to data-services.

    Data-services as a stand alone project works fine, builds fine, all tests works, etc. Messaging(with core) works fine without data services(with the passing off to data-services commented out of course) it connects to the active mq topic, waits, catches messages like it should and I just display them to the console to make sure I got what I wanted, etc. But when I put these three modules under the main project and build the main project through maven, which builds the projects in the following order:

    [INFO] Reactor build order:
    [INFO] NextGenSwakSubscriber
    [INFO] Hibernate Data-Services
    [INFO] JMS Messaging Services
    [INFO] Core Jar Module

    The build is fine, but when I start the app and spring starts up I get this error:

    Code:
    [cypress] - 2012-03-06 09:02:06,834 - FATAL [main] NextGenSwakSubscriber.startSpring(26) | Fatal error occored while attempting to start Spring and create beans.
    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:applicationContext-datasource.xml]
    Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:applicationContext-hibernate.xml]
    Offending resource: class path resource [applicationContext-datasource.xml]; nested exception is 
    Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx]
    Offending resource: class path resource [applicationContext-hibernate.xml]
    
            at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
            at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
            at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
            at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281)
            at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1294)
            at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
            at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
            at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
            at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:174)
            ... 30 more
    Now if I remove this dependency, it doesn't have this issue, well until it needs an activemq class in a later bean, then of course I get a classnotfound, but it looks like there is some issue with activeMQ and spring.

    <dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-all</artifactId>
    <version>5.4.1</version>
    </dependency>

    The xml it's blowing up on is:
    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:tool="http://www.springframework.org/schema/tool"
    	   xmlns:context="http://www.springframework.org/schema/context" 
    	   xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	                       spring-beans-3.0.xsd
    	                       http://www.springframework.org/schema/tx 
    	   				       spring-tx-3.0.xsd
    	   				       http://www.springframework.org/schema/tool 
    	   				       spring-tool-3.0.xsd
    	                       http://www.springframework.org/schema/context 
    	                       spring-context-3.0.xsd">
     		 
     		 
    	<tx:annotation-driven/>
    	
    	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory"/>
    	</bean>
    			
    	<import resource="classpath:applicationContext-data-services.xml" />
    </beans>
    Can anyone point me in the right direction on this? I am at a complete loss and I have deadlines rapidly approaching.

  • #2
    Here is the main pom on the parent project if that will help, atleast give an idea of the versions I am using and what frameworks:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    
    	<!-- Group and artifact information for project -->
    	<groupId><removed></groupId>
    	<artifactId>NextGenSwakSubscriber</artifactId>
    	<version>1.0</version>
    	<packaging>pom</packaging>
    	<name>NextGenSwakSubscriber</name>
    	<description>NextGenSwakSubscriber</description>
    
    	<developers>
    		<developer>
    		</developer>
    	</developers>
    
    	<build>
    		<plugins>
    			<!-- to run: mvn assembly:assembly -e -->
    			<plugin>
    				<artifactId>maven-assembly-plugin</artifactId>
    				<configuration>
    					<finalName>NextGenSwakSubscriber</finalName>
    					<outputDirectory>${stage.dir}/${label}</outputDirectory>
    					<descriptors>
    						<descriptor>src/assemble/assembly-jar-with-dependencies.xml</descriptor>
    						<descriptor>src/assemble/assembly.xml</descriptor>
    					</descriptors>
    					<archive>
    						<manifest>
    							<mainClass>com.ground.swak.NextGenSwakSubscriber</mainClass>
    						</manifest>
    					</archive>
    				</configuration>
    			</plugin>
    		</plugins>
    	</build>
    
    	<dependencies>
    		<!-- 
    			Spring
    		 -->
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-core</artifactId>
    			<version>${spring.version}</version>
    			<scope>compile</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-beans</artifactId>
    			<version>${spring.version}</version>
    			<scope>compile</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-context</artifactId>
    			<version>${spring.version}</version>
    			<scope>compile</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-test</artifactId>
    			<version>${spring.version}</version>
    			<scope>test</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-jms</artifactId>
    			<version>${spring.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-aspects</artifactId>
    			<version>${spring.version}</version>
    			<scope>compile</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-orm</artifactId>
    			<version>${spring.version}</version>
    			<scope>compile</scope>
    		</dependency>
    		
    		
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-jdbc</artifactId>
    			<version>${spring.version}</version>
    			<scope>provided</scope>
    		</dependency>
                    <dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-tx</artifactId>
    			<version>${spring.version}</version>
    			<scope>provided</scope>
    		</dependency>
    		<!-- 
    			Oracle 
    		 -->
    	 	<dependency>
    			<groupId>oracle.sql</groupId>
    			<artifactId>ojdbc14</artifactId>
    			<version>10.2.0.3.0</version>
    		</dependency>
    		<!-- 
    			Hibernate
    		 -->
    		<dependency>
      			<groupId>org.hibernate</groupId> 
      			<artifactId>hibernate-core</artifactId> 
      			<version>${hibernate.core.version}</version> 
      			<scope>compile</scope> 
    			<exclusions>
    				<exclusion>
      					<groupId>asm</groupId> 
      					<artifactId>asm</artifactId> 
      				</exclusion>
    				<exclusion>
      					<groupId>asm</groupId> 
      					<artifactId>asm-attrs</artifactId> 
      				</exclusion>
    				<exclusion>
      					<groupId>cglib</groupId> 
      					<artifactId>cglib</artifactId> 
      				</exclusion>
      			</exclusions>
      		</dependency>
      		<dependency>
      			<groupId>org.hibernate</groupId> 
      			<artifactId>hibernate-annotations</artifactId> 
      			<version>${hibernate-annotations.version}</version> 
      			<scope>compile</scope> 
      		</dependency>
      		<dependency>
      			<groupId>org.hibernate</groupId> 
      			<artifactId>hibernate-entitymanager</artifactId> 
      			<version>${hibernate-entitymanager.version}</version> 
      			<scope>compile</scope> 
      		</dependency>
    		<!-- 
    			Active MQ 
    		--> 
    		<dependency>
    			<groupId>org.apache.activemq</groupId>
    			<artifactId>activemq-all</artifactId>
    			<version>${activemq.version}</version>
    		</dependency>
    		 
    		 
    		 
    		<dependency>
    			<groupId>junit</groupId>
    			<artifactId>junit</artifactId>
    			<version>${junit.version}</version>
    			<scope>test</scope>
    		</dependency>
    		<dependency>
       			<groupId>log4j</groupId>
       			<artifactId>log4j</artifactId>
       			<version>${log4j.version}</version>
       			<scope>compile</scope>
      		</dependency>
    		<dependency>
    			<groupId>org.apache.xmlbeans</groupId>
    			<artifactId>xmlbeans</artifactId>
    			<version>${xmlbeans.version}</version>
    		</dependency>
    
    		<dependency>
    			<groupId>javax.jms</groupId>
    			<artifactId>jms</artifactId>
    			<version>1.1</version>
    		</dependency>
    		<dependency>
      			<groupId>org.hibernate</groupId> 
      			<artifactId>hibernate-annotations</artifactId> 
      			<version>${hibernate-annotations.version}</version> 
      			<scope>compile</scope> 
      		</dependency>
      		<dependency>
    			<groupId>org.aspectj</groupId>
    			<artifactId>aspectjrt</artifactId>
    			<version>${aspectj.version}</version>
    		</dependency>
    		<dependency>
      			<groupId>net.sf.ehcache</groupId> 
      			<artifactId>ehcache</artifactId> 
      			<version>${ehcache.version}</version> 
      			<scope>compile</scope> 
      		</dependency>
    	</dependencies>
    
    	<properties>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    
    		<activemq.version>5.4.1</activemq.version>
    		<aspectj.version>1.6.4</aspectj.version>
    		<ehcache.version>1.6.2</ehcache.version>
    		<junit.version>4.8.2</junit.version>
    		<log4j.version>1.2.15</log4j.version>
    		<spring.version>3.0.2.RELEASE</spring.version>
    		<spring.aspects.version>3.0.5.RELEASE</spring.aspects.version>
    		<xmlbeans.version>2.3.0</xmlbeans.version>
    		<hibernate.core.version>3.3.2.GA</hibernate.core.version> 
    		<hibernate-annotations.version>3.4.0.GA</hibernate-annotations.version>
    		<hibernate-entitymanager.version>3.4.0.GA</hibernate-entitymanager.version> 
    	</properties>
    	
    	<profiles>
    	</profiles>
    	
    	<modules>
    		<module>data-services</module>
    		<module>messaging</module>
    		<module>core-jar</module>
    	</modules>
    
    </project>

    Comment


    • #3
      I think I see what the problem might be related to. The way this project is building with maven, it's making multiple files with the same name in the META_INF folder(i.e. spring.schemas, spring.handlers, etc) It looks like these contain the schema locations and the handler locations. It looks like when spring starts, it checks for spring.handlers and spring.schemas and maps them, but it looks like it's just grabbing the first one it sees and continues on.

      Is it supposed to make multiple .schema and .handler files and spring should look through all of them? or should something be combining these into 1 file?

      Comment


      • #4
        You beat me to it .

        You are assembling your own jar (not sure why but you probably have your reasons) one of the .schemas and .handlers wins and remains. What you need to do is merge all those .schema and .handlers into a single one. Not sure how to do that but what I know is that you aren't the first with this problem and there should be at least something in this forum about it.

        Code:
        <properties>
        	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        
        	<activemq.version>5.4.1</activemq.version>
        	<aspectj.version>1.6.4</aspectj.version>
        	<ehcache.version>1.6.2</ehcache.version>
        	<junit.version>4.8.2</junit.version>
        	<log4j.version>1.2.15</log4j.version>
        	<spring.version>3.0.2.RELEASE</spring.version>
        	<spring.aspects.version>3.0.5.RELEASE</spring.aspects.version>
        	<xmlbeans.version>2.3.0</xmlbeans.version>
        	<hibernate.core.version>3.3.2.GA</hibernate.core.version> 
        	<hibernate-annotations.version>3.4.0.GA</hibernate-annotations.version>
        	<hibernate-entitymanager.version>3.4.0.GA</hibernate-entitymanager.version> 
        </properties>
        Also judging from your pom you are mixing spring versions (3.0.2 and 3.0.5 for the aspects) in general not something to recommend or to do.
        Last edited by Marten Deinum; Mar 8th, 2012, 03:43 AM.

        Comment


        • #5
          i think the problem is related to spring.schemas, spring.handlers
          Last edited by Johnssmith; Mar 22nd, 2012, 05:10 PM.

          Comment


          • #6
            Hi,

            This is a schema and handler issue, use maven shade plugin instead of assembly plugin which creates these files correctly from used spring artifcats.

            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.0</version>
            <executions>
            <execution>
            <phase>package</phase>
            <goals>
            <goal>shade</goal>
            </goals>
            <configuration>
            <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.res ource.ManifestResourceTransformer">
            <manifestEntries>
            <Main-Class><Your Main Class></Main-Class>
            </manifestEntries>
            </transformer>

            <transformer implementation="org.apache.maven.plugins.shade.res ource.AppendingTransformer">
            <resource>META-INF/spring.handlers</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.res ource.AppendingTransformer">
            <resource>META-INF/spring.schemas</resource>
            </transformer>
            </transformers>
            </configuration>
            </execution>
            </executions>
            </plugin>

            Comment


            • #7
              Hi,

              This is a schema and handler issue, use maven shade plugin instead of assembly plugin which creates these files correctly from used spring artifcats.

              <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-shade-plugin</artifactId>
              <version>2.0</version>
              <executions>
              <execution>
              <phase>package</phase>
              <goals>
              <goal>shade</goal>
              </goals>
              <configuration>
              <transformers>
              <transformer implementation="org.apache.maven.plugins.shade.res ource.ManifestResourceTransformer">
              <manifestEntries>
              <Main-Class><Your Main Class></Main-Class>
              </manifestEntries>
              </transformer>

              <transformer implementation="org.apache.maven.plugins.shade.res ource.AppendingTransformer">
              <resource>META-INF/spring.handlers</resource>
              </transformer>
              <transformer implementation="org.apache.maven.plugins.shade.res ource.AppendingTransformer">
              <resource>META-INF/spring.schemas</resource>
              </transformer>
              </transformers>
              </configuration>
              </execution>
              </executions>
              </plugin>

              Comment

              Working...
              X