felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonello CalabrĂ² <antonello.cala...@isti.cnr.it>
Subject Re: ClassNotFoundException problem when activating bundle - org.apache.activemq.jndi.ActiveMQInitialContextFactory
Date Tue, 27 Sep 2011 08:10:26 GMT
Dear Rob,
thank you so much for the suggestion.
I tried unsuccessfully to add each import for activemq.. :(
So, I tried *successfully* to switch class loader into my application using

*
Thread.currentThread().setContextClassLoader(org.apache.activemq.jndi.ActiveMQInitialContextFactory.class.getClassLoader());
*

and seems to work.. partially :) cause when loading other resources/classes,
the application crashes when it tries to load drools engine at:

Class: ComplexEventProcessorImpl - Operation: Reading knowledge
base*java.lang.NoClassDefFoundError: sun/misc/Unsafe
*
    at
org.mvel2.optimizers.dynamic.DynamicClassLoader.<clinit>(DynamicClassLoader.java:39)
[...]
    at
org.drools.rule.builder.dialect.java.AbstractJavaRuleBuilder.<clinit>(AbstractJavaRuleBuilder.java:27)
    at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
[...]
Caused by: *java.lang.ClassNotFoundException*: *sun.misc.Unsafe* not found
by GOSGi [1]


ARGH! Should be a problem due to the modified class loader?
Because sun.misc.unsafe is part of rt.jar that should be java standard..

Suggestion?!

THANKSSS!!!!!


--Antonello




2011/9/26 Rob Walker <robw@ascert.com>

> 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
> robw@ascert.com
> +44 (0)20 7488 3470
> www.ascert.com
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@felix.**apache.org<users-unsubscribe@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message