ILOG JRules User Guide > Executing Rules > Tasks > Executing a Ruleset Using Rule Execution Server > Invoking a Ruleset Using a Stateless Rule Session > Getting the Provider Class for a Stateless Rule Session

The following tasks show you how to get the provider class from both a local and a remote client. A remote client is where the client does not run in the same JVM as the rule session. A local client is where the client runs in the same JVM as the rule session; for example, in a JSP page.

To get the provider class for a remote client:

Properties jndiProperties = new Properties();
  jndiProperties.load(new FileInputStream("jndi.properties"));
  IlrRuleSessionProvider rsProvider = new    IlrRuleSessionProviderFactory.Builder(jndiProperties).build();

Note
The jndi.properties file depends on the application server. Following is an example for WebLogic 9.2 (found in the How to Use a Rule Session in Java EE sample).

===============================

# The URL of the EJB server

java.naming.provider.url=t3://localhost:7001/

# The user's name. To be uncommented when there is one

# java.naming.security.principal=

# The user's password. To be uncommented when there is one

# java.naming.security.credentials=

# The initial factory class name

java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory

==============================

To get the provider class for a local client:

IlrRuleSessionProvider rsProvider = new
   IlrRuleSessionProviderFactory.Builder(IlrRuleSessionProviderFactory.
   MANAGED_RULESESSION_PROVIDER).build();

You can get the provider class for a local client that does not invoke an EJB, where the client does not run in the same JVM as the rule session and does not use the session as an EJB (for example, in a JSP page).

To get the provider class for a local client that does not invoke an EJB:

IlrRuleSessionProvider rsProvider = new
   IlrRuleSessionProviderFactory.Builder(IlrRuleSessionProviderFactory.
   SIMPLE_RULESESSION_PROVIDER).build();

You can also get the provider class in a J2SE environment (where the rule sessions are not used in an application server context).

To get the provider class in a J2SE environment:

// It will print the XU logs on System.err 
PrintWriter loggerPrinter = new PrintWriter(System.err); 
IlrRuleSessionProvider rsProvider = new
   IlrRuleSessionProviderFactory.Builder(IlrRuleSessionProviderFactory.
   J2SE_RULESESSION_PROVIDER).setLogger(loggerPrinter).build();