How to properly start OC4J on a production server.

7

The proper way to start OC4J is sparsely documented by Oracle:

To start OC4J in a standalone environment, issue the following command from the j2ee/home/ directory:
    java -jar oc4j.jar options

This may
often be adequate for development or test purposes, but it never
is in a production environment. ....
Apparently Oracle’s documentation writers assume developers are
sufficiently familiar with the java command to know what extra options to use. But in my experience this is not always the case. What I suggest is this:

    java -Xmx128M -server -jar oc4j.jar

Notes:

  •  -Xmx128M: Sets
    maximum memory to 128MB (substitute a suitable amount). This defaults to a
    mere 64MB, which is almost never enough for a webapp that relies on
    bulk
    data from a database. Whithout this option, the applications
    performance is likely to be seriously degraded, or worse, because of lack of
    sufficient memory allocation. Use stress tests to establish an optimal setting.
  • -server: This
    flag activates server-mode optimization of the JVM. Server-mode
    optimizes JVM perfomance for typical server runtime conditions, i.e.
    longrunning processes and little or no use of graphical libraries of
    the host OS. Without this flag, the JVM usually starts in
    client-mode. In comparison, server-mode performance is slower at first,
    but faster after a while.

For more, see the java tools documentation at http://java.sun.com/j2se/1.5.0/docs/tooldocs/index.html, or similar for your JDK version. 

Share.

About Author

7 Comments

  1. In OC4J 10.1.3, new start / stop scripts are available in OH/bin. These pass the value of the environment variable OC4J_JVM_ARGS into java when starting oc4j. So you can, for example, set in your environment:

    OC4J_JVM_ARGS=-Xmx128M -java

    then start OC4J with:

    bin/oc4j -start

    or on Windows:

    bin/oc4j.cmd -start

    Thanks,
    Brian

  2. Jacco Landlust on

    @Rob, why don’t you use opmnctl or dcmctl for starting, or even better: the enterprise manager website?

    If you do this, the configuration for the OC4J component is parsed. In this configuration ($ORACLE_HOME/j2ee/home/oc4j_opmn.xml) a number of java options are passed to the server. The -server option is one of them. The memory option (which you want to pass too) can be added there too. If you do this, the option is passed without depending on command line options.

    I think the XML file is easy enough to understand, please edit this from the enterprise website too (to avoid sync problems)

    If you want to use the same option with tomcat (or any other J2EE server), you can use the environment variable called JAVA_OPTS. This is passed trough the catalina.sh script.

    Now you know why this isn’t discussed in the Oracle manuals. Oracle wants you to use their management website ;)

  3. Jacco Landlust on

    @Rob, why don’t you use opmnctl or dcmctl for starting, or even better: the enterprise manager website?

    If you do this, the configuration for the OC4J component is parsed. In this configuration ($ORACLE_HOME/j2ee/home/oc4j_opmn.xml) a number of java options are passed to the server. The -server option is one of them. The memory option (which you want to pass too) can be added there too. If you do this, the option is passed without depending on command line options.

    I think the XML file is easy enough to understand, please edit this from the enterprise website too (to avoid sync problems)

    If you want to use the same option with tomcat (or any other J2EE server), you can use the environment variable called JAVA_OPTS. This is passed trough the catalina.sh script.

    Now you know why this isn’t discussed in the Oracle manuals. Oracle wants you to use their management website ;)

  4. Rob van Maris on

    I was referring to OC4J in a standalone environment, e.g. without Oracle AS. The title doesn’t mention this, but it should be clear from the documentation quote.