在我的代码上,我正在使用代码CDI.current().getBeanManager()
在配置中注入一个bean,它返回一个异常:
WELD-001328: Unable to identify the correct BeanManager. The calling class org.eclipse.jnosql.artemis.util.BeanManagers is not placed in bean archive
我使用这种方法做错了吗? 有没有正确的方法来获取BeanManager?
整个异常:
javax.enterprise.inject.spi.DeploymentException: Deployment Failure for ConfigProperty graph in class com.eldermoraes.ch01.jnosql.graph.driver.GraphProducer Reason WELD-001328: Unable to identify the correct BeanManager. The calling class org.eclipse.jnosql.artemis.util.BeanManagers is not placed in bean archive
at fish.payara.microprofile.config.cdi.CDIExtension.validateInjectionPoint(CDIExtension.java:92)
at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85)
at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:168)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
at javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:124)
at org.jboss.weld.util.Observers.notify(Observers.java:166)
at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:171)
at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:44)
at org.jboss.weld.bootstrap.events.ProcessInjectionPointImpl.fire(ProcessInjectionPointImpl.java:46)
at org.jboss.weld.bootstrap.events.ContainerLifecycleEvents.fireProcessInjectionPoint(ContainerLifecycleEvents.java:288)
at org.jboss.weld.injection.InjectionPointFactory.processInjectionPoint(InjectionPointFactory.java:109)
at org.jboss.weld.injection.InjectionPointFactory.createFieldInjectionPoint(InjectionPointFactory.java:140)
at org.jboss.weld.injection.InjectionPointFactory.addFieldInjectionPoint(InjectionPointFactory.java:226)
at org.jboss.weld.injection.InjectionPointFactory.getFieldInjectionPoints(InjectionPointFactory.java:211)
at org.jboss.weld.injection.producer.DefaultInjector.<init>(DefaultInjector.java:56)
at org.jboss.weld.injection.producer.ResourceInjector.<init>(ResourceInjector.java:57)
at org.jboss.weld.injection.producer.ResourceInjector.of(ResourceInjector.java:48)
at org.jboss.weld.injection.producer.BeanInjectionTarget.<init>(BeanInjectionTarget.java:63)
at org.jboss.weld.injection.producer.BeanInjectionTarget.createDefault(BeanInjectionTarget.java:47)
at org.jboss.weld.manager.InjectionTargetFactoryImpl.chooseInjectionTarget(InjectionTargetFactoryImpl.java:139)
at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:88)
at org.jboss.weld.bean.ManagedBean.<init>(ManagedBean.java:102)
at org.jboss.weld.bean.ManagedBean.of(ManagedBean.java:82)
at org.jboss.weld.bootstrap.AbstractBeanDeployer.createManagedBean(AbstractBeanDeployer.java:280)
at org.jboss.weld.bootstrap.BeanDeployer.createClassBean(BeanDeployer.java:221)
at org.jboss.weld.bootstrap.BeanDeployer.createClassBeans(BeanDeployer.java:199)
at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:256)
at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:438)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:86)
at org.glassfish.weld.WeldDeployer.processApplicationLoaded(WeldDeployer.java:513)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:425)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:325)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepare(ApplicationLifecycle.java:523)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:558)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:554)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:553)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:584)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:576)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:575)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1495)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:120)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1877)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1753)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:564)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:251)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:166)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.weld.exceptions.IllegalStateException: WELD-001328: Unable to identify the correct BeanManager. The calling class org.eclipse.jnosql.artemis.util.BeanManagers is not placed in bean archive
at org.jboss.weld.SimpleCDI.unsatisfiedBeanManager(SimpleCDI.java:89)
at org.glassfish.weld.GlassFishWeldProvider$GlassFishEnhancedWeld.unsatisfiedBeanManager(GlassFishWeldProvider.java:89)
at org.jboss.weld.SimpleCDI$ClassNameToBeanManager.findBeanManager(SimpleCDI.java:67)
at org.jboss.weld.SimpleCDI$ClassNameToBeanManager.apply(SimpleCDI.java:47)
at org.jboss.weld.SimpleCDI$ClassNameToBeanManager.apply(SimpleCDI.java:40)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.lambda$null$0(ReentrantMapBackedComputingCache.java:55)
at org.jboss.weld.util.WeakLazyValueHolder$1.computeValue(WeakLazyValueHolder.java:35)
at org.jboss.weld.util.WeakLazyValueHolder.get(WeakLazyValueHolder.java:53)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:72)
at org.jboss.weld.SimpleCDI.getBeanManager(SimpleCDI.java:105)
at org.jboss.weld.SimpleCDI.getBeanManager(SimpleCDI.java:38)
at org.eclipse.jnosql.artemis.util.BeanManagers.getBeanManager(BeanManagers.java:66)
at org.eclipse.jnosql.artemis.util.BeanManagers.getInstance(BeanManagers.java:78)
at org.eclipse.jnosql.artemis.graph.configuration.GraphConverter.convert(GraphConverter.java:34)
at org.eclipse.jnosql.artemis.graph.configuration.GraphConverter.convert(GraphConverter.java:30)
at fish.payara.nucleus.microprofile.config.spi.PayaraConfig.convertString(PayaraConfig.java:270)
at fish.payara.nucleus.microprofile.config.spi.PayaraConfig.getValue(PayaraConfig.java:165)
at fish.payara.microprofile.config.cdi.ConfigPropertyProducer.getGenericProperty(ConfigPropertyProducer.java:97)
at fish.payara.microprofile.config.cdi.CDIExtension.validateInjectionPoint(CDIExtension.java:77)
我的代码
public class GraphConverter implements Converter<Graph> {
@Override
public Graph convert(String value) {
final SettingsConverter settingsConverter = BeanManagers.getInstance(SettingsConverter.class);
Config config = BeanManagers.getInstance(Config.class);
final Settings settings = settingsConverter.convert(value);
final String provider = value + ".provider";
final Class<?> configurationClass = config.getValue(provider, Class.class);
if (GraphConfiguration.class.isAssignableFrom(configurationClass)) {
final Reflections reflections = BeanManagers.getInstance(Reflections.class);
final GraphConfiguration configuration = (GraphConfiguration) reflections.newInstance(configurationClass);
return configuration.apply(settings);
}
throw new ConfigurationException("The class " + configurationClass + " is not valid to " + GraphConfiguration.class);
}
}