Application calling lookup on external-context fails with WFNAM00007: Invalid URL scheme name "null" in JBoss EAP 7
Environment
Red Hat JBoss Enterprise Application Platform (EAP) 7
Issue
- We configured an external context in the naming subsystem , but when our application tries to lookup java:global/external/someValue it is failing with WFNAM00007: Invalid URL scheme name "null" in JBoss EAP 7 :
Caused by: javax.naming.InvalidNameException: WFNAM00007: Invalid URL scheme name "null"
at org.wildfly.naming.client.WildFlyRootContext.getProviderContext(WildFlyRootContext.java:808)
at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:155)
at javax.naming.InitialContext.lookup(InitialContext.java:421)
at javax.naming.InitialContext.lookup(InitialContext.java:421)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:236)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:239)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at org.apache.jsp.context_jsp._jspService(context_jsp.java:114)
... 46 more
The external context configuration is :
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<bindings>
<external-context name="java:global/external/" module="org.jboss.as.naming" class="javax.naming.InitialContext" cache="false">
<environment>
<property name="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"></property>
<property name="java.naming.provider.url" value="http-remoting://remote-host:8080"></property>
<property name="java.naming.security.principal" value="user"></property>
<property name="java.naming.security.credentials" value="password"></property>
</environment>
</external-context>
</bindings>
<remote-naming></remote>
</subsystem>
Resolution
EAP 7.1+
org.jboss.naming.remote.client.InitialContextFactory and the module org.jboss.remote-naming were deprecated (the module still exists and is just an alias for the module org.wildfly.naming-client and the class org.jboss.naming.remote.client.InitialContextFactory still exists but just proxies to org.wildfly.naming.client.WildFlyInitialContextFactory , the deprecated class & module will be removed for EAP 8.0)
You should use org.wildfly.naming.client.WildFlyInitialContextFactory from the module org.wildfly.naming-client
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<bindings>
<external-context name="java:global/external/" module="org.wildfly.naming-client" class="javax.naming.InitialContext" cache="false">
<environment>
<property name="java.naming.factory.initial" value="org.wildfly.naming.client.WildFlyInitialContextFactory"></property>
<property name="java.naming.provider.url" value="http-remoting://remote-host:8080"></property>
<property name="java.naming.security.principal" value="user"></property>
<property name="java.naming.security.credentials" value="password"></property>
</environment>
</external-context>
</bindings>
<remote-naming></remote>
</subsystem>
EAP 7.0
The initial context factory org.jboss.naming.remote.client.InitialContextFactory being specified in the external-context is not in the module org.jboss.as.naming, it is in org.jboss.remote-naming, so change it to this:
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<bindings>
<external-context name="java:global/external/" module="org.jboss.remote-naming" class="javax.naming.InitialContext" cache="false">
<environment>
<property name="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"></property>
<property name="java.naming.provider.url" value="http-remoting://remote-host:8080"></property>
<property name="java.naming.security.principal" value="user"></property>
<property name="java.naming.security.credentials" value="password"></property>
</environment>
</external-context>
</bindings>
<remote-naming></remote>
</subsystem>
Related Solutions
Root Cause
The class specified in the java.naming.factory.initial value is not in the module specified on the external-context
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.