Announcement Announcement Module
Collapse
No announcement yet.
Spring JMS Namespace Handler cannot be located on Linux Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring JMS Namespace Handler cannot be located on Linux

    On Windows I am able to run my project fine but on Linux I keep receiving this error:

    Code:
    Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/jms]
    Offending resource: class path resource [com/name/name/queueconsumer/QueueConsumerContext.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:316)
    	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1416)
    	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:123)
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:197)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:172)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:158)
    	at com.name.name.queueconsumer.CPEConsumerApp.main(CPEConsumerApp.java:33)
    I am executing a jar file that has spring dependencies and others using an init script.

    Code:
    /etc/init.d/QueueConsumerService start
    Inside the init script I have the it starting the jar by
    Code:
    java -jar /usr/share/name/lib/NameQueueConsumer-1.0-SNAPSHOT.jar
    The context file is 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:util="http://www.springframework.org/schema/util"
           xmlns:jms="http://www.springframework.org/schema/jms"
           xmlns:p="http://www.springframework.org/schema/p"
           xsi:schemaLocation="
              http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.1.xsd
              http://www.springframework.org/schema/util http://www.springframework.org/schem...g-util-3.1.xsd
              http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.1.xsd">
    
        <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
    
        <bean id="propertyConfigurer"
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>file:///usr/share/name/conf/queueConsumer.properties</value> <!-- Linux Path where the file will be -->
    <!--                <value>file:///opt/Name/configuration/queueConsumer.properties</value> -->
    <!--                <value>file://C:\opt\Name\configuration\queueConsumer.properties</value>-->
                </list>
            </property>
    <!--        <property name="ignoreResourceNotFound" value="true"/>
            <property name="ignoreUnresolvablePlaceholders" value="true"/>-->
        </bean>
    
        <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
            <constructor-arg ref="messageFactory"/>
            <property name="marshaller" ref="marshaller"/>
            <property name="unmarshaller" ref="marshaller"/>
            <property name="messageSender" ref="messageSender"/>
            <property name="defaultUri" value="${com.name.name.queueconsumer.uri}"/>
        </bean>
    
        <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
            <property name="contextPath" value="com.name.dataupload.ws"/>
        </bean>
    
        <bean id="messageSender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender">
            <property name="credentials">
                <bean class="org.apache.commons.httpclient.UsernamePasswordCredentials">
                    <constructor-arg value="${com.name.name.queueconsumer.username}"/><!-- username -->
                    <constructor-arg value="${com.name.name.queueconsumer.password}"/><!-- password -->
                </bean>
            </property>
        </bean>
    
        <bean id="config" class="com.name.name.queueconsumer.Config">
            <property name="logsPropertyFile" value="${com.name.name.queueconsumer.logsPropertyFile}"/>
            <property name="maxRecordsPerCall" value="${com.name.name.queueconsumer.maxRecordsPerCall}"/>
        </bean>
    
    
        <!-- The JMS configuration settings. -->
        <bean id="connectionFactory" class="org.apache.qpid.client.AMQConnectionFactory">
            <constructor-arg index="0"
                             value="${com.name.name.queueconsumer.broker.connection}" />
        </bean>
    
        <!-- A POJO that implements the JMS message listener -->
        <bean id="messageListener" class="com.name.name.queueconsumer.CPEMessageListener">
            <constructor-arg ref="config"/>
            <constructor-arg ref="webServiceTemplate"/>
        </bean>
    
          <!-- The Spring message listener container configuration -->
        <jms:listener-container concurrency="5-10">
            <jms:listener destination="amq.direct" ref="messageListener"/>
        </jms:listener-container>
    
        <!-- A cached connection to wrap the connection -->
        <bean id="cachedConnectionFactory"
          class="org.springframework.jms.connection.CachingConnectionFactory"
          p:targetConnectionFactory-ref="connectionFactory"
          p:sessionCacheSize="10" />
    
        <!-- A destination  -->
        <bean id="destination"
          class="org.apache.qpid.client.AMQAnyDestination">
            <constructor-arg value="amq.direct" />
        </bean>
    
    </beans>

  • #2
    You need spring-jms<version>.jar (and all dependencies) on the classpath (using -cp switch or by using a manifest classpath in your jar).

    How are you running the jar on windows?

    Comment


    • #3
      Can you refer me to how to set the manifest classpath?
      Do I add it to my Maven Pom file for that project?

      I am using Netbeans to run the NameQueueConsumer jar file and I am just right clicking on the project and selecting Run.
      Last edited by ColinMc; Jun 8th, 2012, 12:05 PM.

      Comment


      • #4
        Running from an IDE is very different from running from a script or the command line; most modern IDEs will create the classpath at runtime for you.

        Google "setting the manifest classpath"

        http://docs.oracle.com/javase/tutori...r/downman.html

        Or, you can let maven build the classpath for you and use the maven exec plugin rather than running your jar directly; again, google is your friend.

        Comment

        Working...
        X