beans.xml file and java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only
Asked Answered
S

3

5

I have very strange exception after starting using beans.xml file in our EJB and jar files.
We use JBoss7.1.1 release.
Our application is packaged as ear file.
It was deployed and works correctly earlier.
There is some Module1 EJB component. Now we use @Inject annotation for some beans in Module1 and therefore added META-INF/beans.xml.
Another EJB component Module2 uses EJB from Module1 like:

@EJB

private IOmistajaFinderLocal omistajaFinder;

But now application cannot be deployed on JBoss. There following exception:

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)
"}}}}

Both Module1 and Module2 are included in application.xml file and generated ear file. Deleting beans.xml resolves the deploying process but in this case we can not use @Injection annotation.

What is the problem and how can I resolve it? Thank you.

Sanctity answered 16/4, 2013 at 6:13 Comment(1)
Did you ever resolve this? I am having the exact same problem with Jersey and JBoss 8 (Wildfly)Dre
L
16

This is a known issue when using jersey. Try to add below option to your jvm, which will fix your issue. If you are running the jboss server from eclipse then add to the server runtime configuration. If you are starting the jboss from command prompt using standalone.bat then add the below option to standalone.conf.bat. Similarly if you are using *Nix then add to standalone.conf.

set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true"
Leacock answered 13/5, 2013 at 21:29 Comment(2)
This answer helped me getting the Neo4j Webadmin Server Component started from my war on jboss 7.1! Thank you !!!1Vortex
How can I add this using netbeans?Orfinger
P
2

For use in eclipse (run and debug), open server properties, launch configuration properties and set the VM arguments: -Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true

Phonetic answered 24/6, 2016 at 14:0 Comment(0)
I
0

I am able to manage this. Add a patch in naming jar. Just change org.jboss.as.naming.service.NamingStoreService -> readOnly = true

Full java class -

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;
}
}
Iyar answered 30/4, 2015 at 15:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.