< Prev - Examples - Next >

Using Java EE Connector Builder With JBoss

This example is based on the scalar type example. It calls a PL/SQL stored procedure and returns a transfer object. The calling api is always identical in any PL/SQL Connector Builder. The configuration describes for the remote access to the stateless session beans.

JBoss Server Configuration

Module configuration allows direct access to the Oracle JDBC driver.
XML-File : <jboss-home>/modules/system/layers/base/com/oracle/main/modules.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle">
 <resources>
   <resource-root path="ojdbc7.jar"/>
   <resource-root path="sdoapi.jar"/>
   <resource-root path="sdoutl.jar"/>
   <resource-root path="ucp.jar"/>
 </resources>
 <dependencies>
   <module name="javax.api"/>
   <module name="javax.transaction.api"/>
   <module name="javax.servlet.api" optional="true"/>
 </dependencies>
</module>
EAR module configuration to access the Oracle jdbc driver.
XML-File : src/main/application/META-INF/jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="com.oracle" />
    </dependencies>
    <resources>
        <resource-root path="ojdbc7.jar"/>
    </resources>
   </deployment>
</jboss-deployment-structure>

Client Configuration

A context class configures the remote naming context and the calling prefix to the remote stateless session beans. It is used by the factory bean.
Java Class : JavaEeContext.java
package factory;

import java.io.InputStream;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;

final class JavaEeContext {
  private static Properties properties;

  private JavaEeContext() {}

  private static synchronized void initProperties() throws Exception {
    if (properties == null) {
      try (InputStream is = JavaEeContext.class.getResourceAsStream("/java_ee_jboss_client.properties")) {
        properties = new Properties();
        properties.load(is);
      }
    }
  }

  static Context getContext() throws Exception {
    if (properties == null) {
      initProperties();
    }
    Context context = new InitialContext(properties);

    return context;
  }

  static String getJndiModulePrefix() throws Exception {
    return "ejb:/java_ee_jboss_server";
  }
}

Running The Example

< Prev - Examples - Next >