If I had to guess I would say you're having a class loader issue because the same class is reachable via two different classes. This can be a common problem in a  container (like Tomcat) if the class is on both the container's class path and bundled in a web application. Containers have different rules (and sometimes configuration options) related to class loader isolation for web applications because the specification is a little ambiguous in some areas.

I'd check which JARs you have in the class path and see how o.s.c.i.Resource is getting resolved by two different loaders.

-mike


 | Mike Pilone | Software Architect, Distribution | mpilone@npr.org | o: 202-513-2679  m: 703-969-7493


From: Saikat Kanjilal <sxk1969@hotmail.com>
Reply-To: "users@activemq.apache.org" <users@activemq.apache.org>
Date: Wednesday, September 12, 2012 2:00 PM
To: "users@activemq.apache.org" <users@activemq.apache.org>
Subject: RE: Newbie to activemq


So I was able to get past the issue below by just trying to get the local install for jndi with tomcat working.  However I am now seeing the following issue in the tomcat stack trace:

Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(Lorg/springframework/core/io/Resource;)V" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/apache/activemq/xbean/XBeanBrokerFactory$1, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, org/apache/xbean/spring/context/ResourceXmlApplicationContext, have different Class objects for the type org/springframework/core/io/Resource used in the signature


Does this mean that the version of xbean-spring is incorrect, has anyone run into this before?

Regards

From: sxk1969@hotmail.com
To: users@activemq.apache.org
Subject: RE: Newbie to activemq
Date: Tue, 11 Sep 2012 08:29:25 -0700
I will increase the logging level in spring and see what I can find, also I have no idea whether the initial context factory class is visible or not, I guess I'd like to understand why it wouldn't be visible or figure out how this visibility is reconciled, is this something where spring cannot see tomcat's environment, pardon my ignorance on this, I'll be reading docs on JNDI setup in Tomcat as well as spring docs, it would be great if someone who already has this setup working could help give a pointer.  Could this be an issue where I need to copy the individual activemq jar files to the tomcat/lib directory instead of the activemq-all-versionnumber.jar, see this thread (http://mail-archives.apache.org/mod_mbox/activemq-users/200807.mbox/%3C18611643.post@talk.nabble.com%3E)?
Also to provide more details around my setup:
Wikis referenced: (http://www.tomcatexpert.com/blog/2010/12/16/integrating-activemq-tomcat-using-local-jndi,http://icodingclub.blogspot.com/2011/09/spring-jms-with-embeded-activemq-in.html)Tomcat version: 6.0.35spring version: 3.0.5activemq version: 5.6.0maven (not that this matters but I'll put this here anyway): 2.2.1Use Case: Consumer running on same JVM as producer, consumer needs to read off the queue and make an http call to update a cache, producer needs to read from a relational db and populate/update the queue
Regards
> Date: Tue, 11 Sep 2012 10:52:01 +0100
> Subject: Re: Newbie to activemq
> From: gary.tully@gmail.com
> To: users@activemq.apache.org
>
> see if you can increase the logging level for spring. It may just be a
> class loading issue trying to resolve the initial context factory.
> Are you certain that the activemq initial context factory class is
> visible to your spring context?
>
>
> On 11 September 2012 07:51, Saikat Kanjilal <sxk1969@hotmail.com> wrote:
> >
> > Yes I saw that link already, however we are using spring in our infrastructure and unfortunately changing to Camel is currently not an option for me.  I feel like I am pretty close , just need to figure out whether this is a tomcat jndi issue or a spring issue, the error message is not really clear :)
> >
> >> From: claus.ibsen@gmail.com
> >> Date: Tue, 11 Sep 2012 08:47:23 +0200
> >> Subject: Re: Newbie to activemq
> >> To: users@activemq.apache.org
> >>
> >> Hi
> >>
> >> If you use Camel to communicate with JMS / ActiveMQ, then we have an
> >> example how to embed AMQ + Camel in Tomcat (eg a WAR app). You can
> >> take a look at this:
> >> http://camel.apache.org/activemq-camel-tomcat.html
> >>
> >>
> >>
> >> On Tue, Sep 11, 2012 at 8:44 AM, Saikat Kanjilal <sxk1969@hotmail.com> wrote:
> >> >
> >> > Hello all,I'm new to activemq but not to java and spring and I would much appreciate some help, I am trying to get activemq running with spring and in embedded mode with Tomcat version 6.    I have followed the following wikis (http://www.tomcatexpert.com/blog/2010/12/16/integrating-activemq-tomcat-using-local-jndi,http://icodingclub.blogspot.com/2011/09/spring-jms-with-embeded-activemq-in.html) and gone through each of the steps, however in both cases I end up with the following stack trace:
> >> > org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory': Invocation of init method failed; nested exception is javax.naming.NamingException: Cannot create resource instance
> >> >
> >> > It seems like either my JNDI setup is not correct in tomcat or there is some other spring issue.   Also note that I am trying to get the consumer and the producer to run on the same jvm.
> >> > I am running active mq version 5.6.0 with spring 3.0.5.
> >> >
> >> > Looking forward to your help.
> >> > Regards
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> FuseSource
> >> Email: cibsen@fusesource.com
> >> Web: http://fusesource.com
> >> Twitter: davsclaus, fusenews
> >> Blog: http://davsclaus.com
> >> Author of Camel in Action: http://www.manning.com/ibsen
> >
>
>
>
> --
> http://fusesource.com
> http://blog.garytully.com