Search code examples
javaweb-servicesjbossjerseywildfly

JBoss Wildfly with Jersey Web Services Deployment Error JBAS011859: Naming context is read-only


Im working on a Java Webservices Project Using the Jersey Servlet (1.18.1). When deploying my EAR file to Jboss WildFly (8.1.0) I'm Getting the following Error and im unsure why its breaking as this same EAR file deployed and worked 100% in JBoss7 (7.1.1).
The Error stacktrace:

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(InitialContext.java:464)
at com.sun.jersey.server.impl.cdi.CDIExtension$1.stepInto(CDIExtension.java:280)

Solution

  • After Doing some research in JBoss Dev Forums i came across the answer. This is caused by a bug with Jersey which doesn't allow add JNDI entries into the JVM.

    To fix it add the following to the standalone.bat:

    set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true"
    

    or properties file:

    com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true