• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Spring JMS configuraiton

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking at another project from Spring In Action Volume 4 by Craig Walls. In chapter 17 there is a simple jms project that sets up a
sender and a Message Listener. This is a Gradle project. The build.gradle file is



The project has a main class:


The jms configuration file (messaging.xml) is:



When I build the jar file and execute it, I get the following exception:



I looked at the following ActiveMQ page, which seems to address this, but could not resolve the issue ActiveMQ XML Reference
Would appreciate help to resolve this.
 
Ranch Hand
Posts: 729
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What the mentioned documentation is trying to convey are the following.
[1]

documentation wrote:If you are using XBean to parse the XML configurations, the XML validation is optional so you do not need to specify the XML Schema Locations.


which is your case (as you include the xbean dependency in the gradle build. Now, if you look at the left column, you will see the it starts documenting from xbean 4.1 upward. Yours is specifying 3.7... which means if you want to use properly that documentation, you need to change to at least 4.1. _But_, that is not enough, as you are using the namespace http://activemq.apache.org/schema/core, and you look at the right column for the namespace for a match up, you would therefore have to change the xbean version to at least 5.1 or up. After that, the application would begin in good shape.

[2] The second thing is that if you run the sample in an IDE Eclipse as shown in the gradle build, then you need to do one thing more. As you are using a called "generic" xsd without the version number attached, the documentation says...

documentation wrote:Your IDE won't be able to fetch this XSD, you'll have to manually associate a specific release; however it does mean that you won't have to upgrade your XML config file with each ActiveMQ release; as it will resolve this XSD using the bundled XSD inside the activemq-core.jar.


What it actually means is that you have to associate an actual version number within the IDE, Eclipse say. To "associate", you click out the Eclipse's tab Window>Preferences and on the left panel you'll see XML, under which XML Catalog, then on the right panel User Specified Entries to start adding specific xsd and the corresonding namespace...
 
Mike Tabak
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

which is your case (as you include the xbean dependency in the gradle build. Now, if you look at the left column, you will see the it starts documenting from xbean 4.1 upward. Yours is specifying 3.7... which means if you want to use properly that documentation, you need to change to at least 4.1. _But_, that is not enough, as you are using the namespace http://activemq.apache.org/schema/core, and you look at the right column for the namespace for a match up, you would therefore have to change the xbean version to at least 5.1 or up. After that, the application would begin in good shape.



Thanks much. The latest version I can find of xbean-spring is 4.3 (Maven Central). It is dated May 2015. I tried using it for giggles and had the same error.

It is interesting to note that I have an earlier project I did which performed some basic sending and receiving of JMS text and object messages. I looked at the configuration of that project. It is an Eclipse Maven project. The JMS config file in that project is



Notice it does not call out a specific version of the activemq-core.xsd like the Gradle project. This project uses ActiveMQ 5.8. The pom contains xbean-spring-3.7.jar. This appears to be a similar configuration to the Gradle project and the Eclipse project runs fine. Also note for the Eclipse project I did not have to do anything special to Eclipse for that project.
 
g tsuji
Ranch Hand
Posts: 729
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would advance that start by scripting a definitive and explicit version of activemq-core schema xsd to test the project, do you think not? After that in place, maybe take some advantage of flexibility provisioned by xbean. As to the need of associating the generic schema with a fixed version in Eclipse IDE, you could look into your existing project experience to see if an association had ever been made or not because that kind of operation, being separated from the coding itself, may easily be forgotten after the project had been shelved for a good while. In the meantime, I will try to google a page on this specific manoeuvring so that you have a more detail rundown of it and the description of the need of it.
 
g tsuji
Ranch Hand
Posts: 729
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look of this page (dated 2009, caution on a fast changing area understood).
http://www.bigsoft.co.uk/blog/index.php/2009/02/01/invalid-activemq-schema-name-space
 
Mike Tabak
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

g tsuji wrote:I would advance that start by scripting a definitive and explicit version of activemq-core schema xsd to test the project, do you think not?....



I'm not sure what you mean by this?
 
g tsuji
Ranch Hand
Posts: 729
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike Tabak wrote:

g tsuji wrote:
I would advance that start by scripting a definitive and explicit version of activemq-core schema xsd to test the project, do you think not?....


I'm not sure what you mean by this?


Have you actually read the mentioned documentation?
http://activemq.apache.org/xml-reference.html

Does the second paragraph of it mean anything to you?

documentation wrote:
You can refer to a specific version of the XSD in your XML as follows

 
Mike Tabak
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I read the documentation, though I find it confusing. I am using ActiveMQ 5.7, accordingly:



I used this with http://activemq.apache.org/schema/core/activemq-core-5.7.0 for version 5.7. This results in the following exception:

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 7 in XML document from class path resource [META-INF/spring/messaging.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://activemq.apache.org/schema/core/activemq-core-4.1.2.xsd; lineNumber: 7; columnNumber: 55; TargetNamespace.1: Expecting namespace 'http://activemq.apache.org/schema/core', but the target namespace of the schema document is 'http://activemq.org/config/1.0'.

Which is confusing as the exception references activemq.apache.org/schema/core/activemq-core-4.1.2.xsd. I find the following confusing:

" Expecting namespace 'http://activemq.apache.org/schema/core', but the target namespace of the schema document is 'http://activemq.org/config/1.0'."

I'm not sure what this is saying, is it saying the file has "http://..../schema/core", but should have "http://..../config/1.0? or vice versa? At any rate, changing to http://..../config/1.0 results in a similar exception, only with the expected and target namespaces reversed. Something else here is missing.
 
g tsuji
Ranch Hand
Posts: 729
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A decision on the version to use is not a local design decision, it has global impact on the coding. It has an impact on the namespace to use in particular. In any case, the message.xml is not coming from no where. You could have it copy from somewhere if not writing it up yourself. From the source, what is the message.xml? show it and it should be using a legacy version not matching your new decision on the version. The error is relatively clear, to be fair. If you have not much of an idea of what namespace and validation are about, it may sound "confusing". That's normal. So show your message.xml.
 
Mike Tabak
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The original messaging.xml is



This produces the exception:

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://activemq.apache.org/schema/core]
Offending resource: class path resource [META-INF/spring/messaging.xml]
...
at spittr.JMSMain.main(JMSMain.java:9)

When I change to use explicit version of schema (5.7.0):



I still get the above exception. Note this is not the exception I reported earlier, it is the same exception in both cases, so at some point, something different
happened the last time I tested, I'm not sure what. But I retested both versions of messaging.xml this time.
 
g tsuji
Ranch Hand
Posts: 729
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you include the spring-core in your build? I do not see it on the surface of it.
 
Mike Tabak
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The spring-core is the in compile dependencies and on the classpath when I run. I think there is something more fundamentally wrong with this project. I removed all dependency on the amq namespace by declaring the queue, topic and connection factory beans directly as follows:



I then removed the declaration of the amq namespace from messaging.xml. I ran this and got the following exception:

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 [META-INF/spring/messaging.xml]

I suspect this problem isn't a jms or amq namespace declaration problem, but something more fundamental, but I'm not sure what. I then went and added the amq namespace to my older JMS project and added a queue as a test, here is what that XML config file looks like:



That project will start up without any exceptions. I compared the dependencies between the two projects and aside from the older project containing jars for webmvc and spring security (it is a web project), I can't see anything significant such as an obviously missing dependency. I'm kind of stumped at this point. I've posted this problem to the books webiste, and sent the author a tweet on this problem, but no response so far.
 
Mike Tabak
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to get this project to run with the following XML configuration file



and the following jars on the classpath
activemq-all-5.7.0.jar
activemq-core-5.7.0.jar
activemq-spring-5.7.0.jar
commons-logging-1.2.jar
spring-aop-4.0.7.RELEASE.jar
spring-beans-4.0.7.RELEASE.jar
spring-context-4.0.7.RELEASE.jar
spring-core-4.0.7.RELEASE.jar
spring-expression-4.0.7.RELEASE.jar
spring-jms-4.0.7.RELEASE.jar
spring-tx-4.0.7.RELEASE.jar
xbean-spring-3.7.jar
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!