5

beans.xml开始在我们的EJB和 jar 文件中使用文件后,我遇到了非常奇怪的异常。
我们使用JBoss7.1.1发布。
我们的应用程序被打包为 ear 文件。
它已部署并较早地正常工作。
有一些 Module1 EJB 组件。现在我们@Inject annotation在 Module1 中使用了一些 bean,因此添加了 META-INF/beans.xml。
另一个 EJB 组件 Module2 使用来自 Module1 的 EJB,例如:

@EJB

private IOmistajaFinderLocal omistajaFinder;

但是现在应用程序无法部署在 JBoss 上。有以下例外:

java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only
      at org.jboss.as.naming.WritableServiceBasedNamingStore.requireOwner(WritableServiceBasedNamingStore.java:126)
      at org.jboss.as.naming.WritableServiceBasedNamingStore.createSubcontext(WritableServiceBasedNamingStore.java:116)
      at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:338)
      at org.jboss.as.naming.InitialContext.createSubcontext(InitialContext.java:229)
      at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:346)
      at javax.naming.InitialContext.createSubcontext(Unknown Source)
      at com.sun.jersey.server.impl.cdi.CDIExtension$1.stepInto(CDIExtension.java:280)
      at com.sun.jersey.server.impl.cdi.CDIExtension.diveIntoJNDIContext(CDIExtension.java:267)
      at com.sun.jersey.server.impl.cdi.CDIExtension.createJerseyConfigJNDIContext(CDIExtension.java:273)
      at com.sun.jersey.server.impl.cdi.CDIExtension.initialize(CDIExtension.java:192)
      at com.sun.jersey.server.impl.cdi.CDIExtension.beforeBeanDiscovery(CDIExtension.java:297)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
      at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
      at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
      at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
      at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:241)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229)
      at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)
      at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:75)
      at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:46)
      at org.jboss.weld.bootstrap.events.BeforeBeanDiscoveryImpl.fire(BeforeBeanDiscoveryImpl.java:46)
      at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:322)
      at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:81)
      at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)


      at org.jboss.as.weld.services.WeldService.start(WeldService.java:83)
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_09]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_09]
      at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_09]

 Caused by: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :
java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only
      at
 org.jboss.as.naming.WritableServiceBasedNamingStore.requireOwner(WritableServiceBasedNamingStore.java:126)
      at org.jboss.as.naming.WritableServiceBasedNamingStore.createSubcontext(WritableServiceBasedNamingStore.java:116)
      at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:338)
      at org.jboss.as.naming.InitialContext.createSubcontext(InitialContext.java:229)
      at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:346)
      at javax.naming.InitialContext.createSubcontext(Unknown Source)
      at com.sun.jersey.server.impl.cdi.CDIExtension$1.stepInto(CDIExtension.java:280)
      at com.sun.jersey.server.impl.cdi.CDIExtension.diveIntoJNDIContext(CDIExtension.java:267)
      at com.sun.jersey.server.impl.cdi.CDIExtension.createJerseyConfigJNDIContext(CDIExtension.java:273)
      at com.sun.jersey.server.impl.cdi.CDIExtension.initialize(CDIExtension.java:192)
      at com.sun.jersey.server.impl.cdi.CDIExtension.beforeBeanDiscovery(CDIExtension.java:297)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
      at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
      at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
      at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
      at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:241)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229)
      at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)
      at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:75)
      at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:46)
      at org.jboss.weld.bootstrap.events.BeforeBeanDiscoveryImpl.fire(BeforeBeanDiscoveryImpl.java:46)
      at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:322)
      at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:81)
      at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)


      at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:48)
      at org.jboss.weld.bootstrap.events.BeforeBeanDiscoveryImpl.fire(BeforeBeanDiscoveryImpl.java:46)
      at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:322)
      at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:81)
      at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
      ... 5 more


08:55:05,315 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"Helle.ear\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"Helle.ear\".WeldService: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :
 java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only
      at org.jboss.as.naming.WritableServiceBasedNamingStore.requireOwner(WritableServiceBasedNamingStore.java:126)
      at org.jboss.as.naming.WritableServiceBasedNamingStore.createSubcontext(WritableServiceBasedNamingStore.java:116)
      at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:338)
      at org.jboss.as.naming.InitialContext.createSubcontext(InitialContext.java:229)
      at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:346)
      at javax.naming.InitialContext.createSubcontext(Unknown Source)
      at com.sun.jersey.server.impl.cdi.CDIExtension$1.stepInto(CDIExtension.java:280)
      at com.sun.jersey.server.impl.cdi.CDIExtension.diveIntoJNDIContext(CDIExtension.java:267)
      at com.sun.jersey.server.impl.cdi.CDIExtension.createJerseyConfigJNDIContext(CDIExtension.java:273)
      at com.sun.jersey.server.impl.cdi.CDIExtension.initialize(CDIExtension.java:192)
      at com.sun.jersey.server.impl.cdi.CDIExtension.beforeBeanDiscovery(CDIExtension.java:297)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
      at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
      at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
      at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
      at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:241)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229)
      at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)
      at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:75)
      at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:46)
      at org.jboss.weld.bootstrap.events.BeforeBeanDiscoveryImpl.fire(BeforeBeanDiscoveryImpl.java:46)
      at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:322)
      at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:81)
      at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
"}}}}

Module1 和 Module2 都包含在 application.xml 文件和生成的 ear 文件中。删除 beans.xml 解决了部署过程,但在这种情况下,我们不能使用 @Injection 注释。

有什么问题,我该如何解决?谢谢你。

4

3 回答 3

16

这是使用运动衫时的一个已知问题。尝试将以下选项添加到您的 jvm,这将解决您的问题。如果您从 Eclipse 运行 jboss 服务器,则添加到服务器运行时配置。如果您使用standalone.bat 从命令提示符启动jboss,则将以下选项添加到standalone.conf.bat。同样,如果您使用*Nix,则添加到standalone.conf。

set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true"
于 2013-05-13T21:29:29.687 回答
2

为了在 Eclipse 中使用(运行和调试),打开服务器属性,启动配置属性并设置 VM 参数:-Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true

于 2016-06-24T14:00:00.633 回答
0

我能够做到这一点。在命名 jar 中添加补丁。只需更改 org.jboss.as.naming.service.NamingStoreService -> readOnly = true

完整的java类 -

public class NamingStoreService implements Service<ServiceBasedNamingStore> {

private final boolean readOnly = false;
private volatile ServiceBasedNamingStore store;

public NamingStoreService() {
    this(false);
    System.out.println("Setting readOnly "+readOnly);
}

public NamingStoreService(boolean readOnly) {
    System.out.println("Setting readOnly "+readOnly);
}

/**
 * Creates the naming store if not provided by the constructor.
 *
 * @param context The start context
 * @throws StartException If any problems occur creating the context
 */
public void start(final StartContext context) throws StartException {
    if(store == null) {
        final ServiceRegistry serviceRegistry = context.getController().getServiceContainer();
        final ServiceName serviceNameBase = context.getController().getName();
        final ServiceTarget serviceTarget = context.getChildTarget();
        store = readOnly ? new ServiceBasedNamingStore(serviceRegistry, serviceNameBase) : new WritableServiceBasedNamingStore(serviceRegistry, serviceNameBase, serviceTarget);
    }
}

/**
 * Destroys the naming store.
 *
 * @param context The stop context
 */
public void stop(StopContext context) {
    if(store != null) {
        try {
            store.close();
            store = null;
        } catch (NamingException e) {
            throw MESSAGES.failedToDestroyRootContext(e);
        }
    }
}

/**
 * Get the context value.
 *
 * @return The naming store
 * @throws IllegalStateException
 */
public ServiceBasedNamingStore getValue() throws IllegalStateException {
    return store;
}
}
于 2015-04-30T15:29:39.780 回答