1 Reply Latest reply on Dec 23, 2015 8:37 AM by Jay SenSharma

    Illegal context in name: java:app/jdbc/ActionBazaarDS

    Kiran Mohan Newbie

      The deployment of an EAR with the below contents:

      META-INF/MANIFEST.MF

      META-INF/application.xml

      META-INF/glassfish-resources.xml

      META-INF/wildfly-ds.xml

      actionbazaar-chapter3-client.jar

      actionbazaar-chapter3-ejb.jar

      actionbazaar-chapter3-web.war

       

      fails with the exception: java.lang.RuntimeException: WFLYNAM0030: Illegal context in name: java:app/jdbc/ActionBazaarDS"

       

      The file META-INF/wildfly-ds.xml configures a datasource for the application with the problematic JNDI name.

      <?xml version="1.0" encoding="UTF-8"?>

      <datasources xmlns="http://www.jboss.org/ironjacamar/schema"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="

              http://www.jboss.org/ironjacamar/schema

              http://docs.jboss.org/ironjacamar/schema/datasources_1_1.xsd">

          <datasource enabled="true"

              jndi-name="java:app/jdbc/ActionBazaarDS"

              pool-name="Chapter3EmbeddedH2Pool">

              <connection-url>jdbc:h2:mem:chapter3 ;DB_CLOSE_DELAY=-1</connection-url>

              <driver>h2</driver>

          </datasource>

      </datasources>

       

      The same JNDI name works with GlassFIsh 4.1. But I am not sure what is incorrect here.

      Please explain what is wrong here.

        • 1. Re: Illegal context in name: java:app/jdbc/ActionBazaarDS
          Jay SenSharma Master

          For the Deployable DataSources (*-ds.xml) You can try other names like :

           

          java:global/jdbc/ActionBazaarDS

          java:jboss/jdbc/ActionBazaarDS

          java:/something/ActionBazaarDS

           

          In Wildfly the DataSource or non EJB components the JNDI name can be described as mentioned in the following code:

          https://github.com/wildfly/wildfly/blob/master/naming/src/main/java/org/jboss/as/naming/deployment/ContextNames.java

           

              public static BindInfo bindInfoFor(final String jndiName) {
                  // TODO: handle non java: schemes
                  String bindName;
                  if (jndiName.startsWith("java:")) {
                      bindName = jndiName.substring(5);
                  } else if (!jndiName.startsWith("jboss") && !jndiName.startsWith("global") && !jndiName.startsWith("/")) {
                      bindName = "/" + jndiName;
                  } else {
                      bindName = jndiName;
                  }
                  final ServiceName parentContextName;
                  if(bindName.startsWith("jboss/exported/")) {
                      parentContextName = EXPORTED_CONTEXT_SERVICE_NAME;
                      bindName = bindName.substring(15);
                  } else if (bindName.startsWith("jboss/")) {
                      parentContextName = JBOSS_CONTEXT_SERVICE_NAME;
                      bindName = bindName.substring(6);
                  } else if (bindName.startsWith("global/")) {
                      parentContextName = GLOBAL_CONTEXT_SERVICE_NAME;
                      bindName = bindName.substring(7);
                  } else if (bindName.startsWith("/")) {
                      parentContextName = JAVA_CONTEXT_SERVICE_NAME;
                      bindName = bindName.substring(1);
                  } else {
                      throw NamingLogger.ROOT_LOGGER.illegalContextInName(jndiName);
                  }
                  return new BindInfo(parentContextName, bindName);
              }
          
          

           

          Regards

          Jay SenSharma