Antonello
Importing a package does not imply sub-packages, so it could be as
simple as adding an import for:
org.apache.activemq.jndi
Another area you often trip over with factory classloaders in libraries
is use of getContextClassloader() calls low down in the call stack.
Standard workaround for this is in relevant sections of your code where
threads get created/initialise to process requests is to set the context
classloader e.g.
Thread.currentThread().setContextClassLoader(
this.getClass().getClassLoader());
OSGi is great, but you do stumble on a few class loading issues when
getting started - hang in there.
Regards
-- Rob Walker
On 26/09/2011 1:28 PM, Antonello CalabrĂ² wrote:
Hi all,
I am a newbie in OSGi development, so I hope this will be Yet Another Dumb
Question :)
I am trying to convert a java application to an OSGi Bundle using Eclipse
and running it on apache felix-framework 3.2.2
I translated the main class that contains information about the startup in
an Activator class using the OSGi pattern.
Everything goes fine during compilation, but at runtime, the bundle crashes
when it tries to create an
*initConn = new InitialContext(environmentParameters);*
*Stack report:*
javax.naming.NoInitialContextException: Cannot instantiate class:
org.apache.activemq.jndi.ActiveMQInitialContextFactory [Root exception is
java.lang.ClassNotFoundException:
org.apache.activemq.jndi.ActiveMQInitialContextFactory]
[...] at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
Caused by: java.lang.ClassNotFoundException:
org.apache.activemq.jndi.ActiveMQInitialContextFactory
... 11 more
The *environmentParameters* are:
java.naming.factory.initial =
org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url = tcp://myServer:61616
java.naming.security.principal = system
java.naming.security.credentials = manager
connectionFactoryNames = TopicCF
topic.serviceTopic = jms.serviceTopic
The appication, uses ActiveMQ as JMS messageBroker.
I read something about "two version of JMS in my classpath", but I tried to
remove the javax.jms without valid results
*Here, the application manifest*
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: GOSGi
Bundle-SymbolicName: GOSGi
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.myApp.osgi.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: javax.jms,
javax.naming,
org.apache.activemq,
org.osgi.framework;version="1.3.0"
Bundle-ClassPath: .,
externallib/activemq-all-5.3.2.jar,
externallib/drools-api-5.1.1.jar,
externallib/drools-core-5.1.1.jar,
externallib/javax.jms.jar,
externallib/jsr173_1.0_api.jar,
externallib/resolver.jar,
externallib/saxon9he.jar,
externallib/xbean_xpath.jar,
externallib/xbean.jar,
externallib/xmlbeans-qname.jar,
externallib/xmlpublic.jar,
lib/ComplexEventResponse.jar,
lib/ComplexEventRule.jar
Export-Package: javax.jms,
org.apache.activemq
Bundle-ActivationPolicy: lazy
*Here the build.properties*
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
Conf/,\
externallib/activemq-all-5.3.2.jar,\
externallib/drools-core-5.1.1.jar,\
externallib/javax.jms.jar
jars.extra.classpath = externallib/activemq-all-5.3.2.jar,\
externallib/drools-api-5.1.1.jar,\
externallib/drools-core-5.1.1.jar,\
externallib/javax.jms.jar,\
externallib/jsr173_1.0_api.jar,\
externallib/resolver.jar,\
externallib/saxon9he.jar,\
externallib/xbean_xpath.jar,\
externallib/xbean.jar,\
externallib/xmlbeans-qname.jar,\
externallib/xmlpublic.jar
The code, as Java application, works fine...
May anyone help me? :)
Thank you!
--
Ascert - Taking systems to the Edge
[email protected]
+44 (0)20 7488 3470
www.ascert.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]