Calling and packaging EJB rule sessions for Java EE

EJB3 rule session JAR files are provided for WebSphere® Application Server 8.0 and 8.5, JBoss 5.1 and 6.1, and WebLogic 10.

About this task

To package the JAR files for Java™ EE, write your client application, map the JNDI reference to the execution unit (XU) (optional), and put the files into the relevant archive files. EJB3 deployment descriptors are optional, therefore you do not have to edit and package this XML file.

Procedure

To package an EJB factory for Java EE:

  1. Write and compile the client code.

    Use the IlrEJB3SessionFactory and set the necessary JNDI names.

    For example, you can use the following values for WebSphere Application Server 8.0, or 8.5:

    IlrEJB3SessionFactory sessionFactory = new IlrEJB3SessionFactory();  
    sessionFactory.setStatelessLocalJndiName("ejblocal:ilog.rules.res.session.impl.ejb3.IlrStatelessSessionLocal");  
    sessionFactory.setStatelessRemoteJndiName("ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote");  
    sessionFactory.setStatefulLocalJndiName("ejblocal:ilog.rules.res.session.impl.ejb3.IlrStatefulSessionLocal");  
    sessionFactory.setStatefulRemoteJndiName("ilog.rules.res.session.impl.ejb3.IlrStatefulSessionRemote");
  2. If applicable, map the JNDI reference to the execution unit (XU).

    With EJB3, the nonspecific ejb-jar.xml descriptor is not mandatory. However, you might have to modify the application-server specific EJB descriptor to map the JNDI reference to the XU. Default JNDI mappings are included to work with the default XU JNDI name.

  3. Package the .class, .jsp, and .html files, and (optionally) the deployment descriptors into the appropriate archive files.
    1. Assemble the application modules into a Java EE application EAR file including the jrules-res-session-ejb3-<appserver>.jar file.

      <appserver> is a placeholder for the version number of WebSphere Application Server.

      You can either edit the deployment descriptors directly or use a tool to add XML tags.

    2. In your application.xml file, add the following code, where <appserver> is the relevant application server.

      Typically, add the following values:

      • WAS85 for WebSphere Application Server V8.5
      • WAS8 for WebSphere Application Server V8.0
      • WL10 for WebLogic 10
      • JBOSS5 for JBoss 5.1
      • JBOSS6 for JBoss 6.1
      <application>
          ........
         <module>
           <ejb>my_ejb_application.jar</ejb>
         </module>
         <module>
           <ejb>jrules-res-session-ejb3-<appserver>.jar</ejb>
         </module>
      ....
      </application>

      You can package Java XOM resources in different ways. The simplest way is to put the classes into a separate JAR file, then package the archive with the rule session EJB-JAR in the same EAR file.

  4. Optional: If you use WebSphere Application Server in secure mode, make sure that the client application that uses and packages the Rule Execution Server rule sessions is passed a META-INF/was.policy file with the following content.
    Specify the EJB JAR file name that matches your WebSphere Application Server version number. For example, for WebSphere Application Server 8.5:
    grant codeBase "file :jrules-res-session-ejb3-WAS85.jar" {
                    permission java.lang.RuntimePermission "getClassLoader";
                    permission java.lang.RuntimePermission "setContextClassLoader";
                    permission java.io.FilePermission "${java.io.tmpdir}${/}-", "read,write,delete";
                    /* Log */
                    permission java.io.FilePermission "${was.install.root}${/}-", "read,write";
                    permission java.io.FilePermission "${user.install.root}${/}-", "read,write";
                    /* MBean plugin */
                    permission com.ibm.websphere.security.WebSphereRuntimePermission "AdminPermission";
                    permission javax.management.MBeanPermission "*", "*";
                    permission java.util.PropertyPermission "*", "read,write";
                    /* XU Config */
                    permission java.lang.RuntimePermission "accessDeclaredMembers";
                    permission java.net.NetPermission "specifyStreamHandler";
    };