Some time ago I stumbled on a weird exception when deploying an EAR on IBM WebSphere Application Server 8.5. The EAR got successfully installed, but when the application server tried to start the WAR archive of my EAR I got this exception:

javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: java
	at org.apache.aries.jndi.DelegateContext.lookup(
	at javax.naming.InitialContext.lookup(

After searching the web for this exception I came to the conclusion that I have to debug it on my own. Some days of debugging later I found out that there was a configuration problem that was not obvious. So I decided to write this blog and I hope that it can safe you a lot of time.

The problem arises when versions of the JEE descriptors (e.g. web.xml, ejb-jar.xml) and the type of container specific descriptors (e.g. ibm-web-bnd.xmi or ibm-web-bnd.xml) are not compatible.

In my case the version of the WEB-INF/web.xml in my WAR archive was set to 3.0.


and the ibm-web-bnd.xmi descriptor was used. E.g.

<?xml version="1.0" encoding="UTF-8"?>
<webappbnd:WebAppBinding xmi:version="2.0" xmlns:xmi="" xmlns:common="common.xmi" xmlns:webappbnd="webappbnd.xmi" xmi:id="WebAppBinding_1" virtualHostName="default_host">
  <webapp href="WEB-INF/web.xml#someApp"/>
  <resRefBindings xmi:id="ResourceRefBinding_1172302423734" jndiName="jdbc/someDS">
    <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_12743024234335"/>
  <ejbRefBindings xmi:id="EjbRefBinding_1289572370126" jndiName="">
    <bindingEjbRef xmi:type="common:EJBLocalRef" href="WEB-INF/web.xml#EJBLocalRef_1367972173131"/>

The problem with this configuration is that for a web-app version 3.0 you have to use ibm-web-bnd.xml instead of xmi. Otherwise the container can not setup the jndi environment correctly which leads to the “javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: java”.

Sometime you also get a javax.naming.NamingException telling you that the context java can not be found.

So at least one can say that

  • web-app version <= 2.4 use ibm-web-bnd.xmi
  • web-app version >= 2.5 use ibm-web-bnd.xml

Migrating ibm-web-bnd.xmi to ibm-web-bnd.xml

In my case I had a ibm-web-bnd.xmi and I needed to convert it to the xml descriptor. Thus I thought it would be nice if I could do it via XSLT.

Since my application only used ejbRefBindings and resRefBindings I wrote a xslt script that can convert an ibm-web-bnd.xmi to an ibm-web-bnd.xml

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
	xmlns:xsl="" xmlns:webappbnd="webappbnd.xmi"

	<xsl:template match="webappbnd:WebAppBinding">
		<xsl:variable name="webAppId" select="substring-after( webapp/@href, '#')" />
		<xsl:variable name="virtualHostName" select="@virtualHostName" />
		<web-bnd xmlns=""

			<xsl:attribute name="id"><xsl:value-of select="$webAppId" /></xsl:attribute>

				<xsl:attribute name="name"><xsl:value-of select="$virtualHostName" /></xsl:attribute>

			<xsl:apply-templates select="resRefBindings" />
			<xsl:apply-templates select="ejbRefBindings" />

	<xsl:template match="resRefBindings">
		<xsl:variable name="bindingResourceRef"
			select="substring-after(bindingResourceRef/@href, '#ResourceRef_')" />
		<xsl:variable name="resRefName"
			select="document('web.xml')//webapp:web-app/webapp:resource-ref[@id = concat('ResourceRef_', $bindingResourceRef)]/webapp:res-ref-name" />
		<xsl:variable name="bindingName" select="@jndiName" />

			<xsl:when test="string-length(normalize-space($resRefName)) = 0">
				<xsl:text disable-output-escaping="yes"><![CDATA[<!-- ibm-web-bnd.xmi to xml transformation exception: Found resRefBindings with id ResourceRef_]]></xsl:text>
				<xsl:value-of select="$bindingResourceRef" />
				<xsl:text disable-output-escaping="yes"><![CDATA[ that has no matching reference in web.xml -->]]></xsl:text>
					<xsl:attribute name="name"><xsl:value-of
						select="$resRefName" /></xsl:attribute>
					<xsl:attribute name="binding-name"><xsl:value-of
						select="$bindingName" /></xsl:attribute>

	<xsl:template match="ejbRefBindings">
		<xsl:variable name="bindingEjbRef"
			select="substring-after(bindingEjbRef/@href, '#EJBLocalRef_')" />
		<xsl:variable name="ejbRefName"
			select="document('web.xml')//webapp:web-app/webapp:ejb-local-ref[@id = concat('EJBLocalRef_', $bindingEjbRef)]/webapp:ejb-ref-name" />
		<xsl:variable name="bindingName" select="@jndiName" />

			<xsl:when test="string-length(normalize-space($ejbRefName)) = 0">
				<xsl:text disable-output-escaping="yes"><![CDATA[<!-- ibm-web-bnd.xmi to xml transformation exception: Found ejbRefBindings with id EJBLocalRef_]]></xsl:text>
				<xsl:value-of select="$bindingEjbRef" />
				<xsl:text disable-output-escaping="yes"><![CDATA[ that has no matching reference in web.xml -->]]></xsl:text>
					<xsl:attribute name="name"><xsl:value-of
						select="$ejbRefName" /></xsl:attribute>
					<xsl:attribute name="binding-name"><xsl:value-of
						select="$bindingName" /></xsl:attribute>


Assuming that you have the following folder setup


Here is some java code that can help you to transform the ibm-web-bnd.xmi to xml – or use some xslt processor of your choice.

import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;

public class Transform {

	public static void main(String[] args) throws Exception {
		File inputXmlFile = new File(args[0]);
		File xsltFile = new File(args[1]);

		StreamSource inputXml = new StreamSource(inputXmlFile);
		StreamSource xslt = new StreamSource(xsltFile);

		TransformerFactory transformerFactory = TransformerFactory
		Transformer transformer = transformerFactory.newTransformer(xslt);

		Result outputTarget = new StreamResult(new File(args[2]));
		transformer.transform(inputXml, outputTarget);

If you use the example java code above you can compile it in the directory shown above and execute it with this command line

> java Transformer ibm-web-bnd.xmi ibm-web-bnd.xmi-to-xml.xslt ibm-web-bnd.xml