Skip Headers

Oracle® Application Server Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 2 (10.1.2)
Part No. B15505-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Sharing Classes

If you want to share classes between EJBs, you can do one of the following:

If you want to share classes between EJB and Web applications, you should place the referenced classes in a shared JAR.

If you receive a ClassCastException, then you probably have the following situation:

To solve this problem, either eliminate the copied classes out of the WAR file or turn off the search_local_classes_first attribute. This attribute tells the class loader to load in the classes in the WAR file before loading in any other classes, including the classes within the EJB JAR file. For more information on this attribute, see the "Loading WAR File Classes Before System Classes in OC4J" section in the "Servlet Development" chapter of the Oracle Application Server Containers for J2EE Servlet Developer's Guide.

Out of Memory During Execution

If you see that the OC4J memory is growing consistently while executing, then you may have invalid symbolic links in your application.xml file. OC4J loads all resources using the links in the application.xml file. If these links are invalid, then the C heap continues to grow causing OC4J to run out of memory. Ensure that all symbolic links are valid and restart OC4J.

In addition, keep the number of JAR files to a minimum in the in the directories where the symbolic links point. Eliminate all unused JARs from these directories. OC4J searches all JARs for classes and resources; thus, taking time and memory consumption by the file cache, as well as being mapped into the address space.

ClassCastException

When you have an EJB or Web application that references other shared EJB classes, you should place the referenced classes in a shared JAR. In certain situations, if you copy the shared EJB classes into WAR file or another application that references them, you may receive a ClassCastException because of a class loader issue. To be completely safe, never copy referenced EJB classes into the WAR file of its application or into another application.

Static Block in an EJB

During EJB deployment in OC4J, you load the bean class to find out its methods so that you can generate EJB wrappers. Because the code in the static block is executed as the class is being loaded, the JNDI environment context is not yet set up. Even during runtime, the bean is in the "does not exist" stage. In this stage of the life cycle, the JNDI environment context is undefined, and the bean provider cannot rely on it to be available. To work around this problem, set up and cache the context during the construction of the bean, in the ejbCreate() method, or in the setSessionContext() method.

OC4J Instances Terminating Due To ping Timeout

Under some conditions, the OPMN process monitoring software in Oracle Application Server may lose contact with an OC4J process. This can occur because of unexpected delays in the hearbeat protocol used by OPMN and OC4J to verify the proper functioning of the OC4J instance.

If this problem occurs sporadically, you can try increasing the ping timeout parameters as described in the following instructions.

However, if this occurs regularly, due to a consistent resource shortage, then you must increase the available hardware resources to solve the problem.

The following conditions can cause this problem:

  • An overloaded host processor

  • One or more computation-intensive applications running in the OC4J instance.

  • Deployment of applications with large numbers (hundreds) of EJBs. Full garbage collections of large heaps can cause the OC4J process to become less responsive during the garbage collection phase. Although this should not occur during normal usage, deployment of large applications with many EJBs in a memory-constrained environment can trigger this behavior.

You can configure the behavior of the "ping protocol" between OPMN and OC4J in the opmn.xml configuration file.

When OC4J exceeds the timeout intervals specified for the ping protocol, the process monitoring software decides that the OC4J process has stopped responding and, therefore, terminates the OC4J process.

If you suspect this behavior in an Oracle Application Server installation, then use the following steps to troubleshoot and work around:

  1. When OC4J instances are "mysteriously" terminating, first increase diagnostic logging to determine if ping failures are triggering the termination:

    1. Increase the OPMN logging level to 5 so that you can see the pings.

      In the opmn/conf/opmn.xml file, edit the following line:

      log-file path="$ORACLE_HOME/opmn/logs/ipm.log" level="5" ...
      
      
    2. Reload the daemon.

      opmn/bin/opmnctl reload
      
      
  2. Look in opmn/logs/ipm.log for the following line :

    Process Ping Failed:  OC4J~<instance name>~default_island~1 (opmnid)
    
    
  3. The line above indicates that the memory and CPU resources of the current host are probably not sufficient to perform the operation within the currently specified ping timeout interval (used by OPMN to determine OC4J "responsiveness").

    Change the settings as follows:

    1. Increase the timeout and interval. For example:

      <ping timeout="60" interval="60"/>"
      <data id="reverseping-failed-ping-limit" value="5" />
      
      
    2. Reload the daemon.

      opmn/bin/opmnctl reload
      
      
    3. Restart the appropriate OC4J instance.

  4. Repeat the top-level operation that caused the timeout failure.