Starting WebConsole .war in embedded Jetty.. JNDI config?

Hi there,

I'm getting started using ActiveMQ, have searched this list and googled but
I'm going in circles.  My environment is a Jetty embedded server, running my
main web app which starts ActiveMQ via jndi.properties.  Now I am trying to
run the web console, which I'm doing by including the
activemq-web-console-5.5.0.war as a WebAppContext.  So, I have a single VM
running Jetty and the two web apps, mine and the webconsole war.

Java VM -> Jetty embedded
  -> WebAppContext (myapp.war)
  -> WebAppContext (activemq-web-console-5.5.0.war)

The main web app, with the embedded ActiveMQ, works fine.  I have followed
http://activemq.apache.org/jndi-support.html which went smoothly, the jndi
file says:

===============
java.naming.factory.initial =
org.apache.activemq.jndi.ActiveMQInitialContextFactory

java.naming.provider.url = vm://myapp

connectionFactoryNames = connectionFactory

queue.testqueue = myapp.testqueue
=================

This jndi.properties is in the root of my main app .war, so it's not visible
to the webconsole.war webapp.

So all my Java code is pure JMS with no ActiveMQ specifics.  Nice.  The main
web app can start the queue, publish messages and consumers consume them.

Now, adding the webconsole.war to Jetty, I am having trouble because I'm a
JNDI newbie.  I have read http://activemq.apache.org/web-console.html but am
not sure which bits of instructions to follow.  The "Starting the Web
Console in a seperate VM/in a Web-Container" seems good, except it's not in
a separate VM, it's in the same VM.

I've tried setting the following VM arguments:
-Dwebconsole.type=jndi
-Dwebconsole.jms.url=vm://myapp

However the webconsole war fails init:

     [java] WARNING: Failed startup of context
o.e.j.w.WebAppContext{/webconsole,file:/tmp/jetty-0.0.0.0-8080-activemq-web-console-5.5.0.war-_webconsole-any-/webapp/},/downloads/activemq-web-console-5.5.0.war
     [java] org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionPool' defined in ServletContext resource
[/WEB-INF/webconsole-jndi.xml]: Cannot resolve reference to bean
'connectionFactory' while setting bean property 'connectionFactory'; nested
exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'connectionFactory' defined in ServletContext
resource [/WEB-INF/webconsole-jndi.xml]: Instantiation of bean failed;
nested exception is
org.springframework.beans.factory.BeanDefinitionStoreException: Factory
method [public javax.jms.ConnectionFactory
org.apache.activemq.web.config.JNDIConfiguration.getConnectionFactory()]
threw exception; nested exception is java.lang.IllegalArgumentException:
Neither a ConnectionFactory nor a JMS-url were specified
     [java]     at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)

That exception, "IllegalArgumentException: Neither a ConnectionFactory nor a
JMS-url were specified", is confusing, because I'm expecting the
webconsole.type=jndi to cause it to look everything up via JNDI.  I've a
feeling the exception message is misleading.  I found a reference to the
exception in source code:

http://activemq.2283324.n4.nabble.com/svn-commit-r751656-in-activemq-trunk-activemq-web-console-src-main-resources-activemq-web-console-sr-td2395670.html

It seems to be thrown inside makeConnectionFactory(jmsUrl, jmsUser,
jmsPassword) but I've a strong feeling I've simply mis-configured the system
properties that webconsole uses.

I would guess that trying to use a tcp:// url instead of vm:// would not
help, as the exception says a required configuration property is missing,
not that a connection couldn't be made.

Just running the webconsole.war in the same Jetty setup, with no -D system
properties set, starts fine, and I can view the web gui and see no queues
naturally because it's running its own broker.  I'm stuck with connecting it
to the vm:// broker running in my main app via the correct system
properties.

Any clues? :)
Nick

--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Starting-WebConsole-war-in-embedded-Jetty-and-vm-broker-JNDI-config-tp3548843p3548843.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to