我正在使用Jersey Servlet(1.18.1)开发Java Webservices项目。在将我的EAR文件部署到Jboss WildFly(8.1.0)时,我得到了以下错误,并且我不确定为什么它会在JBoss7(7.1.1)中部署并完成100%的同一EAR文件。
错误堆栈跟踪:
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)
答案 0 :(得分:7)
在JBoss Dev论坛上做了一些研究之后,我找到了答案。这是由Jersey的一个错误导致的,它不允许将JNDI条目添加到JVM中。
要解决此问题,请将以下内容添加到standalone.bat:
set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=**true**"
或属性文件:
com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true
答案 1 :(得分:0)
我能够管理这个。在命名jar中添加补丁。只需更改org.jboss.as.naming.service.NamingStoreService - > readOnly = true
完整的java类 -
公共类NamingStoreService实现服务{
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;
}
}
答案 2 :(得分:0)
如果您使用的是Mac,请将以下行添加到Jboss_home / bin目录中的standalone.conf文件中
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true"