Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caused by: javax.enterprise.inject.CreationException: java.lang.NullPointerException #83

Open
cmoulliard opened this issue Jun 14, 2012 · 8 comments

Comments

@cmoulliard
Copy link

Hi,

The following config generates this error at the console of Karaf and in the log

Console of Karaf

17:32:39.878 [fileinstall-/] INFO o.j.w.e.o.i.i.ServicePublisher - Registering/Starting OSGi Service for bundle org.apache.camel.camel-cdi
17:32:39.879 [fileinstall-/] INFO o.j.w.e.o.i.i.ServicePublisher - Registering OSGi service org.apache.camel.component.cdi.CdiCamelContext as org.apache.camel.component.cdi.CdiCamelContext
17:32:40.099 [fileinstall-/] INFO o.j.w.e.o.i.i.Weld - Starting Weld instance for bundle camel-cdi [86]
17:32:40.099 [fileinstall-/] INFO org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
17:32:40.125 [fileinstall-/] INFO o.j.w.e.o.i.i.ServicePublisher - Registering/Starting OSGi Service for bundle camel-cdi
17:32:40.127 [fileinstall-/] ERROR o.j.w.e.o.i.e.OSGiServiceBean - Unable to instantiate OSGiServiceBean [CdiCamelContext] with qualifiers [@Any @OSGiService @filter(value=)] due to java.lang.NullPointerException
17:

Log

2012-06-14 17:35:05,823 | WARN | raf-2.2.7/deploy | fileinstall | 6 - org.apache.felix.fileinstall - 3.2.2 | Error while starting bundle: file:/Users/chmoulli/MyApplications/apache-karaf-2.2.7/deploy/weld-osgi-core-extension-1.2.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Activator start error in bundle org.jboss.weld.osgi.weld-osgi-core-extension [51].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1889)[org.apache.felix.framework-3.0.9.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)[org.apache.felix.framework-3.0.9.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:918)[org.apache.felix.framework-3.0.9.jar:]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1246)[6:org.apache.felix.fileinstall:3.2.2]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1220)[6:org.apache.felix.fileinstall:3.2.2]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1209)[6:org.apache.felix.fileinstall:3.2.2]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:500)[6:org.apache.felix.fileinstall:3.2.2]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:291)[6:org.apache.felix.fileinstall:3.2.2]
Caused by: javax.enterprise.inject.CreationException: java.lang.NullPointerException
at org.jboss.weld.environment.osgi.impl.extension.OSGiServiceBean.create(OSGiServiceBean.java:177)[51:org.jboss.weld.osgi.weld-osgi-core-extension:1.2.0.SNAPSHOT]
at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:64)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:623)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:688)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:119)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:703)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:712)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:162)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:158)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:132)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:154)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:291)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:64)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:623)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:228)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:576)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:566)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:561)[52:org.jboss.weld.osgi.weld-osgi-core-mandatory:1.2.0.SNAPSHOT]
at org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.startManagement(IntegrationActivator.java:235)[51:org.jboss.weld.osgi.weld-osgi-core-extension:1.2.0.SNAPSHOT]
at org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.startCDIOSGi(IntegrationActivator.java:115)[51:org.jboss.weld.osgi.weld-osgi-core-extension:1.2.0.SNAPSHOT]
at org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.start(IntegrationActivator.java:83)[51:org.jboss.weld.osgi.weld-osgi-core-extension:1.2.0.SNAPSHOT]
at org.jboss.weld.environment.osgi.impl.Activator.start(Activator.java:62)[51:org.jboss.weld.osgi.weld-osgi-core-extension:1.2.0.SNAPSHOT]

Bundle Camel-CDI

@publish
public class CdiCamelContext extends DefaultCamelContext {

public CdiCamelContext() {
    setRegistry(new CdiBeanRegistry());
    setInjector(new CdiInjector(getInjector()));
}

}

Bundle Example

public class BootStrap {

Logger logger = LoggerFactory.getLogger(BootStrap.class);

@Inject @OSGiService
CdiCamelContext camelCtx;

@Inject
SimpleCamelRoute simpleRoute;

public void onStartup(@Observes BundleContainerEvents.BundleContainerInitialized event) throws Exception {
    logger.info(">> Create CamelContext and register Camel Route.");

Regards,

Charles

@cmoulliard
Copy link
Author

Exception -->

17:48:02.081 [Karaf Shell C] ERROR o.j.w.e.o.i.e.OSGiServiceBean - Unable to instantiate OSGiServiceBean [CdiCamelContext] with qualifiers [@Any @OSGiService @filter(value=)] due to java.lang.NullPointerException
ERROR: Bundle org.jboss.weld.osgi.weld-osgi-core-extension [51] EventDispatcher: Error during dispatch. (javax.enterprise.inject.CreationException: java.lang.NullPointerException)
javax.enterprise.inject.CreationException: java.lang.NullPointerException
at org.jboss.weld.environment.osgi.impl.extension.OSGiServiceBean.create(OSGiServiceBean.java:177)
at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:64)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:623)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:688)
at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:119)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:703)
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:712)
at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:162)
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:158)
at org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:132)
at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:154)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:291)
at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:64)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:623)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:228)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)
at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:576)
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:566)
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:561)
at org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.startManagement(IntegrationActivator.java:235)
at org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.bundleChanged(IntegrationActivator.java:150)
at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:807)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:729)
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3761)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1787)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:918)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
at org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:30)
at org.apache.karaf.shell.osgi.BundlesCommand.doExecute(BundlesCommand.java:37)
at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.karaf.shell.console.jline.Console.run(Console.java:166)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
at org.apache.felix.framework.resolver.ResolverImpl.permutateIfNeeded(ResolverImpl.java:1156)
at org.apache.felix.framework.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:1085)
at org.apache.felix.framework.resolver.ResolverImpl.resolve(ResolverImpl.java:171)
at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:4103)
at org.apache.felix.framework.ModuleImpl.searchDynamicImports(ModuleImpl.java:1412)

@mathieuancelin
Copy link
Owner

Hey Charles, is it possible to get your code or at least your dependencies so I can test your use case and debug ?

@mathieuancelin
Copy link
Owner

Charles can you try to do something like :

@publish
@ApplicationScoped
public class CdiCamelContextImpl implements CdiCamelContext {

    private final DefaultCamelContext context = new DefaultCamelContext();

    public CdiCamelContextImpl() {
        context.setRegistry(new CdiBeanRegistry());
        context.setInjector(new CdiInjector(getInjector()));
    }

    @Override
    public DefaultCamelContext context() {
         return this.context;
    }
}

Here I just want to know if the error come from the framework itself or from the creation of the CamelContext

@cmoulliard
Copy link
Author

Le code de camel-cdi se trouve ici :

https://svn.apache.org/repos/asf/camel/trunk/components/camel-cdi/

et mon example dans github

https://github.com/cmoulliard/cdi-camel-example/

Je n'ai pas committe ni dans camel-cdi ni dans min mon repo github les
modifs d'hier soir pour tester weld-osgi

Pour tester karaf, c'est simple --> tu le récupère ici
http://repo1.maven.org/maven2/org/apache/karaf/apache-karaf/2.2.7/

Ensuite tu lances ./karaf dans le répertoire bin

et tu déploies le projet avec les commandes suivantes

features:addurl
mvn:org.apache.camel.karaf/apache-camel/2.10-SNAPSHOT/xml/features
features:install camel
install
-s wrap:mvn:org.apache.deltaspike.core/deltaspike-core-api/0.3-incubating-SNAPSHOT
features:install camel-cdi
install -s mvn:com.fusesource/camel-cdi-example/1.0

Tu copies les jars de weld-osgi dans le répertoire deploy de karaf. En
faisant list -l , tu devrais voir ensuite ceci danq la console karaf

[ 50] [Active ] [ ] [ ] [ 80]
file:/Users/chmoulli/MyApplications/apache-karaf-2.2.7/deploy/weld-osgi-core-integration-1.2.0-SNAPSHOT.jar
[ 51] [Active ] [ ] [ ] [ 80]
file:/Users/chmoulli/MyApplications/apache-karaf-2.2.7/deploy/weld-osgi-core-extension-1.2.0-SNAPSHOT.jar
[ 52] [Active ] [ ] [ ] [ 80]
file:/Users/chmoulli/MyApplications/apache-karaf-2.2.7/deploy/weld-osgi-core-mandatory-1.2.0-SNAPSHOT.jar
[ 54] [Active ] [ ] [ ] [ 80]
file:/Users/chmoulli/MyApplications/apache-karaf-2.2.7/deploy/weld-osgi-core-spi-1.2.0-SNAPSHOT.jar
[ 55] [Active ] [ ] [ ] [ 80]
file:/Users/chmoulli/MyApplications/apache-karaf-2.2.7/deploy/weld-osgi-core-api-1.2.0-SNAPSHOT.jar

Charles

On Fri, Jun 15, 2012 at 10:16 AM, Mathieu ANCELIN <
[email protected]

wrote:

Hey Charles, is it possible to get your code or at least your dependencies
so I can test your use case and debug ?


Reply to this email directly or view it on GitHub:
#83 (comment)

@cmoulliard
Copy link
Author

Meme erreur :

11:26:39.326 [FelixStartLev] ERROR o.j.w.e.o.i.i.ServicePublisher - Unable
to instantiate the service for class class
org.apache.camel.component.cdi.CdiCamelContext2Impl, CDI return this error:
com.google.common.collect.ComputationException:
java.lang.NullPointerException
java.lang.RuntimeException: com.google.common.collect.ComputationException:
java.lang.NullPointerException
at
org.jboss.weld.environment.osgi.impl.integration.ServicePublisher.registerAndLaunchComponents(ServicePublisher.java:171)
at
org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.startManagement(IntegrationActivator.java:233)
at
org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.startCDIOSGi(IntegrationActivator.java:115)
at
org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.serviceChanged(IntegrationActivator.java:181)
at
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:871)
at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:733)
at
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3772)
at org.apache.felix.framework.Felix.access$000(Felix.java:80)
at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:729)
at
org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107)
at org.apache.felix.framework.Felix.registerService(Felix.java:2861)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:229)
at
org.jboss.weld.environment.osgi.impl.WeldActivator.start(WeldActivator.java:48)
at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1842)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1163)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:680)
Caused by: com.google.common.collect.ComputationException:
java.lang.NullPointerException
at
com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:218)
at
com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)
at
com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)
at
org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:112)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:618)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:650)
at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:102)
at
org.jboss.weld.environment.osgi.impl.integration.ServicePublisher.registerAndLaunchComponents(ServicePublisher.java:167)
... 20 more
Caused by: java.lang.NullPointerException
at
org.apache.felix.framework.resolver.ResolverImpl.permutateIfNeeded(ResolverImpl.java:1156)
at
org.apache.felix.framework.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:1085)
at
org.apache.felix.framework.resolver.ResolverImpl.resolve(ResolverImpl.java:171)
at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:4103)
at
org.apache.felix.framework.ModuleImpl.searchDynamicImports(ModuleImpl.java:1412)
at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:734)
at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at
org.jboss.weld.environment.osgi.impl.integration.OSGiProxyService$BridgeClassLoader.loadClass(OSGiProxyService.java:83)
at
org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:271)
at org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:237)
at
org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:97)
at
org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:43)
at
org.jboss.weld.bean.proxy.ClientProxyProvider$CreateClientProxy.apply(ClientProxyProvider.java:62)
at
org.jboss.weld.bean.proxy.ClientProxyProvider$CreateClientProxy.apply(ClientProxyProvider.java:48)
at
com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)
... 27 more

Si je retire @ApplicationScoped

idem

11:30:07.476 [FelixStartLev] ERROR o.j.w.e.o.i.i.ServicePublisher - Unable
to instantiate the service for class class
org.apache.camel.component.cdi.CdiCamelContext2Impl, CDI return this error:
java.lang.NullPointerException
ERROR: Bundle org.jboss.weld.osgi.weld-osgi-core-extension [51] Error
starting
file:/Users/chmoulli/MyApplications/apache-karaf-2.2.7/deploy/weld-osgi-core-extension-1.2.0-SNAPSHOT.jar
(org.osgi.framework.BundleException: Activator start error in bundle
org.jboss.weld.osgi.weld-osgi-core-extension [51].)
java.lang.RuntimeException: java.lang.NullPointerException
at
org.jboss.weld.environment.osgi.impl.integration.ServicePublisher.registerAndLaunchComponents(ServicePublisher.java:171)
at
org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.startManagement(IntegrationActivator.java:233)
at
org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.startCDIOSGi(IntegrationActivator.java:115)
at
org.jboss.weld.environment.osgi.impl.integration.IntegrationActivator.start(IntegrationActivator.java:83)
at org.jboss.weld.environment.osgi.impl.Activator.start(Activator.java:62)
at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1842)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1163)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
at
org.apache.camel.component.cdi.CdiCamelContext2Impl.(CdiCamelContext2Impl.java:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.jboss.weld.introspector.jlr.WeldConstructorImpl.newInstance(WeldConstructorImpl.java:204)
at
org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:126)
at org.jboss.weld.bean.ManagedBean.createInstance(ManagedBean.java:334)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.produce(ManagedBean.java:201)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:290)
at
org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:64)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:623)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:650)
at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:102)
at
org.jboss.weld.environment.osgi.impl.integration.ServicePublisher.registerAndLaunchComponents(ServicePublisher.java:167)
... 10 more

On Fri, Jun 15, 2012 at 10:32 AM, Mathieu ANCELIN <
[email protected]

wrote:

Charles can you try to do something like :

@publish
@ApplicationScoped
public class CdiCamelContextImpl implements CdiCamelContext {

   private final DefaultCamelContext context;

   public CdiCamelContextImpl() {
       context.setRegistry(new CdiBeanRegistry());
       context.setInjector(new CdiInjector(getInjector()));
   }

   @Override
   public DefaultCamelContext context() {
        return this.context;
   }
}

Here I just want to know if the error come from the framework itself or
from the creation of the CamelContext


Reply to this email directly or view it on GitHub:
#83 (comment)

@mathieuancelin
Copy link
Owner

I don't know why the ApplicationScoped fails, it seems to be a proxy error. Anyway the error seems to come from org.apache.camel.component.cdi.CdiCamelContext2Impl.(CdiCamelContext2Impl.java:12). What happens here ?

@cmoulliard
Copy link
Author

I think that it fails to create the CdiBeanRegistry

line 12 --> context.setRegistry(new CdiBeanRegistry());

package org.apache.camel.component.cdi;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.enterprise.inject.spi.Bean;

import org.apache.camel.spi.Registry;
import org.apache.camel.util.ObjectHelper;
import org.apache.deltaspike.core.api.provider.BeanProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**

  • CdiBeanRegistry used by Camel to perform lookup into the CDI {@link
    javax.enterprise.inject.spi.BeanManager}.
    */
    public class CdiBeanRegistry implements Registry {

On Fri, Jun 15, 2012 at 12:18 PM, Mathieu ANCELIN <
[email protected]

wrote:

I don't know why the ApplicationScoped fails, it seems to be a proxy
error. Anyway the error seems to come from
org.apache.camel.component.cdi.CdiCamelContext2Impl.(CdiCamelContext2Impl.java:12).
What happens here ?


Reply to this email directly or view it on GitHub:
#83 (comment)

@cmoulliard
Copy link
Author

The Apache felix-3003 JIRA ticket has solved the error reported earlier in my post :

Caused by: java.lang.NullPointerException
at org.apache.felix.framework.resolver.ResolverImpl.permutateIfNeeded(ResolverImpl.java:1156)

This is fixed in Felix framework 4.0.3.

I have had another error after retesting in Karaf 2.3 with Felix 4.0.3

Caused by: java.lang.IllegalArgumentException: class org.apache.camel.component.cdi.CdiCamelContext is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at org.jboss.weld.environment.osgi.impl.extension.OSGiServiceBean.create(OSGiServiceBean.java:160)

that I have solved with the following modification in org.jboss.weld.environment.osgi.impl.extension.OSGiServiceBean

@Override
public Object create(CreationalContext creationalContext) {
    logger.trace("Entering OSGiServiceBean : create() with parameter");
    try {
        BundleContext context = ctx;
        if (context == null) {
            context = FrameworkUtil.getBundle(injectionPoint.getMember()
                    .getDeclaringClass()).getBundleContext();
        }
        DynamicServiceHandler handler =
                              new DynamicServiceHandler(context,
                                                        ((Class) type).getName(),
                                                        filter,
                                                        qualifiers,
                                                        timeout);
        // Object proxy = Proxy.newProxyInstance(getClass().getClassLoader(),
        //                                      new Class[] {getBeanClass()},
        //                                      handler);

        Object proxy = Proxy.newProxyInstance(getBeanClass().getClassLoader(),
                                              new Class[] {getBeanClass()},
                                              handler);

Regards,

Charles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants