Inside Scoop on J2EE : Tips and tricks on J2EE and Oracle Application Server by Debu Panda
Updated: 11/14/2005; 11:24:45 AM.

 

Subscribe to "Inside Scoop on J2EE" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Thursday, October 06, 2005

There have been some confusions surrounding when to use dedicated.connection and when to use dedicated.rmicontext and why you need to use.

 

These properties are required in OC4J releases between 9.0.2.x to 10.1.2.x and let me briefly describe what these properties are meant for.

 

When two or more clients in the same process retrieve an InitialContext, OC4J returns a cached context. Thus, each client receives the same InitialContext, which is assigned to the process.
 
Server lookup, which results in server load balancing, happens only if the client retrieves its own InitialContext. If you set dedicated.rmicontext to true, then each client receives its own InitialContext instead of a shared context.
 
When  dedicated.connection is set to true, OC4J creates a brand new connection  and hence a thread for each initial context so it uses more resources and may cut into descriptor limits. So there might be minor performance implication when using dedicated.connection.

 

Of these two, we recommend to use dedicated.rmicontext.

 

The good news is that we heard all your feedback and are making sure that you do NOT need to use any of these properties in OC4J 10.1.3 and use of these properties will be ignored.

 

We have introduced a well-defined JNDI environment property oracle.j2ee.rmi.loadBalance in 10.1.3 for load balancing purposes

  • oracle.j2ee.rmi.loadBalance=client (the default - it is not necessary to specify this)
  • oracle.j2ee.rmi.loadBalance=context - Goes to a new server when a separate context is used (similar to some optimization provided by dedicated.rmicontext)
  • oracle.j2ee.rmi.loadBalance=lookup - Goes to a new server for every lookup

Hope this clarifies some confusions surrounding dedicated.rmicontext and dedicated.connection and gives you an idea how we are addressing this in 10.1.3!


11:23:10 AM    comment []

I've seen some confusion around looking up remote EJB in OC4J although this has been documented in the EJB Guide and Services Guide. So let me clarify how do you look up an EJB in OC4J standalone and OC4J in OracleAS environment.

 

OC4J allows to lookup remote EJBs using ORMI, RMI-IIOP or HTTP Tunneling over ORMI. In this blog, I will discuss use of ORMI.

 

What Context Factory to Use

 

OC4J 10.1.2 and earlier

 

com.evermind.server.RMIInitialContextFactory – Use this from remote web , ejb and thick Java client and you do not have a application client.

 

com.evermind.server.ApplicationClientInitialContextFactory – Only if you are using application (thick ) java client and you have application-client.xml available at the client side with EJB references

 

 

OC4J 10.1.3

If you are using 10.1.3 then the package names for these context factories have been renamed and  you should start using oracle.j2ee.rmi.RMIInitialContextFactory  and oracle.j2ee.naming.ApplicationClientInitialContextFactory.

 

 

Provider URL

Incorrect provider URL is the cause of the most of the errors encountered by users.

 

Standalone

The value for java.naming.provider.url should be of format ormi://<;hostname>:<ormi port>/<appName>

 

The ORMI port is configured using the rmi.xml. The default port is 23791.

 

The appName is the application name that you used while deploying the application and can be found in the server.xml.

 

For example the provider URL could be java.naming.provider.url=ormi://dpanda-us:23793/ejb30slsb

 

Where dpanda-us is my hostname and 23793 is my ORMI port and ejb30slsb is the name of my application.

 

 

OC4J in OracleAS Install (Managed by OPMN)

 

 

The value for java.naming.provider.url should be of format opmn:ormi://<;hostname>:<opmn request port>:<oc4j-instance-name>/ejbsamples

 

OC4J is managed by OPMN in an OracleAS install and ORMI port is dynamically allocated and you may have more than one OC4J processes that may be used for load balancing / failover by OPMN. You have to use the opmn request port instead of using the ORMI port. You can find the ORMI request port from opmn.xml as follows:

 

<notification-server>

    <port local="6100" remote="6200" request="6004"/>

…..

</notification-server>

 

The default request port is 6003

 

 

In an OracleAS install you may have more than one instance of OC4J and you use the name the instance where you have deployed the application. The default instance name is home.

 

So if my hostname is dpanda-us, request port is 6004 and name of instance is home1 then my provider URL will look like follows

 

java.naming.provider.url=opmn:ormi://dpanda-us:6004:home1 /ejb30slsb

 

 

What EJB name to lookup

 

The context factory you are using determines what values to use in the conext.lookup.

 

RMIInitialContextFactory

 

If you are using  RMIInitialContextFactory then you have to use the ejb-name specified in the ejb-jar.xml or name element when using annotation with EJB 3.0 .e.g. I’ve defined ejb-name as “HelloWorldBean” in the deployment descriptor as follows 

 <session>

         <ejb-name>HelloBean</ejb-name>

      <home>hello.HelloHome</home>

 

then I look up as follows:

 

// This for use with com.evermind.server.rmi.RMIInitialContextFactory

        Object homeObject = context.lookup("HelloBean");

 

ApplicationClientInitialContextFactory

 

If you are using ApplicationClientInitialContextFactory then you have to lookup using the ejb-ref-name defined in the application-client.xml in the format java:comp/env/<ejb-ref-name>.

 

For example, I’ve defined the ejb-references in the application-client.xml as follows

 

<ejb-ref>

          <ejb-ref-name>Helloworld</ejb-ref-name>

           <ejb-ref-type>Session</ejb-ref-type>

                        ..

 </ejb-ref>

 

then I lookup as follows:

 

 

// This is for use with com.evermind.server.ApplicationClientInitialContextFactory

      Object homeObject = context.lookup("java:comp/env/Helloworld");

 

 

Use of Dedicated.connection vs dedicated.rmicontext

 

 Set dedicated.rmicontext or dedicated.connection true as appropriate.

 

You have to use either of this OC4J specific property while looking of remote EJB from web or ejb client in 10.1.2 and earlier.These properties will not be required in 10.1.3.

 

Hope I clarified the use of remote EJB and I will describe how to lookup EJBs in OC4J from a third-party web container like Tomcat.

 

 

 

 

 

 

 


7:29:56 AM    comment []

© Copyright 2005 Debu Panda.

PS: These are my own thoughts and not of my employer ..



Click here to visit the Radio UserLand website.
 


October 2005
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Sep   Nov