How to load a java class at server start-up

Hi,
I have one custome java class that is being referenced by all the applications deployed in OC4J container. How can I load that class automatically and be evailable in the path at server start-up time. Is there an option available to give the class name that also gets loaded automatically.
Thanks

To me, you have two mixed issues.
1. OC4J supports a startup/shutdown model where a named class will be invoked when the container is started (or stopped).
This is described in the doc here:
http://download-west.oracle.com/docs/cd/B32110_01/web.1013/b28952/startclas.htm#CIHECEIB
Note that this specifically calls the methods that are implemented from the respective OC4JShutdown and OC4JStartup interfaces -- the class that is instantiated and called here is not available to all other applications by default. This is more to suit the need where something needs to be done when the container is started/stopped.
2 The next option is where you just want to make a class available to all applications deployed to the container. For this we provide the shared-library mechanism. Using this you can either make use of the implicit global.libraries shared-lib in which you simply drop JAR files into the j2ee/home/applib directory whereupon the classes will become available by default to all applications. Or you can choose to install a shared-library that contains your specific classes (in a JAR file) and then import that into the default application whereupon the configuration will be inherited by all deployed applications.
cheers
-steve-

Similar Messages

  • How to load a java class when application is at first time browsed.

    Hi
    How can i load a simple java class on application startup.
    For servlet it could be done using "load on startup" tag in web.xml
    but how could the same be achieved for a simple java class.
    Thanks

    Hi
    Code is given below....
    package com;
    import java.io.IOException;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class Test {
    Test()
         HttpServletRequest request=null;
         HttpServletResponse response=null;
         RequestDispatcher requestDispatcher = request.getRequestDispatcher("a.jsp");
         try {
              requestDispatcher.forward(request,response);
         } catch (ServletException e) {
              System.out.println("success");
              e.printStackTrace();
         } catch (IOException e) {
              System.out.println("success 1");
              e.printStackTrace();
         finally
              System.out.println("success 2");
         System.out.println("success 3");
    }Web.xml :
    <servlet>
            <servlet-name>simple</servlet-name>
            <servlet-class>com.Test</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
      <servlet-mapping>
          <servlet-name>simple</servlet-name>
          <url-pattern>/init.do</url-pattern>
        </servlet-mapping>Error Trace :
    org.apache.catalina.core.StandardContext loadOnStartup
    SEVERE: Servlet /DispatcherTest threw load() exception
    java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.Test with modifiers ""
         at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
         at java.lang.Class.newInstance0(Class.java:344)
         at java.lang.Class.newInstance(Class.java:303)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
         at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
         at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857)
         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
         at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1069)
         at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1162)
         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
         at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1304)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1568)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557)
         at java.lang.Thread.run(Thread.java:595)

  • Invoking a java class while server start up

    Hi,
    I want to invoke a java class/method immediately after a web server is started. Can any body tell me how to do this.
    Regards,
    Prakash

    It is easy.
    Write a serlvet, lets call it ConfigServlet that handles the configuration parameters of a web-application.
    My GenericConfigServlet looks like this:
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Enumeration;
    import java.util.Map;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.log4j.Logger;
    public class GenericConfigServlet extends HttpServlet
         private static final long serialVersionUID = 1L;
         public void init(ServletConfig config) throws ServletException
              super.init(config);
              ServletContext sCtx = getServletContext();
              ServletConfig sCfg = getServletConfig();
                String prefix =  sCtx.getRealPath("/");
                synchronized (this)
                   Enumeration initParams = sCfg.getInitParameterNames();
                   String key, value;
                   GenericConfigProperties.setApplicationBasePath(prefix);
                   while (initParams.hasMoreElements()) {
                        key = (String) initParams.nextElement();
                        value = sCfg.getInitParameter(key);
                        GenericConfigProperties.setProperty(key,value);
    }Then in your web.xml, you write like this:
    <servlet-name>ConfigServlet</servlet-name>
              <servlet-class>GenericConfigServlet</servlet-class>
              <init-param>
                   <param-name>LICENSES</param-name>
                   <param-value>1</param-value>
              </init-param>
              <init-param>
                   <param-name>TMP_DIRECTORY</param-name>
                   <param-value>C:\\temp\\</param-value>
              </init-param>
              <init-param>
                   <param-name>INPUTFILE</param-name>
                   <param-value>C:\\temp\\_input.txt</param-value>
              </init-param>
              <load-on-startup>0</load-on-startup>
         </servlet>You can add any number of init-param-tags.
    The important thing is the element <load-on-startup>0</load-on-startup>. This tells the webserver to load this servlet first. A lower number is loades before a higher so if you have a servlet that you want to load but you need the configuration to be done first, that servlet definition should read <load-on-startup>1</load-on-startup>.
    Of course, you can do anything you want in the init-method. This is just one way of doing it.
    Message was edited by:
    Lajm
    Additionals...
    Message was edited by:
    Lajm
    Hideing company name... ;-)

  • SQLPLUS: How to verify that java class file have been loaded

    Hi All,
    I just loaded my Java class file using CREATE OR REPLACE JAVA.
    Java was created sucessfuly, but how can I check or find out if my file have been loaded correctly.
    I also found a command :
    SQL>exec myjava.showobjects
    but i don't have the loadjava utility install....is there any command from SQL PLUS?
    thanks

    Thanks for the sql command....after that query what do I do next to see if for example tree.class is in the dba_object.
    Sorry, I am a newbie and the question may be a bit generic .....

  • Than how can i get java class by using it's class file?

    Hi
    After compilation of a java program, it creates a class file.
    After getting class file suppose class file has been deleted.
    Than how can i get java class by using it's class file?
    Thanks in advance.

    get a decompiler and run your class file through it--I'll assume you want the source code back and that you are not trying to recover a missing class file by attempting to use the class file that is missing--if it's missing, then I've not a clue on how to get it back by using what is already missing.
    BTW: many of your compilers have source control--if it does, just restore your missing file.

  • How to call a Java class from another java class ??

    Hi ..... can somebody plz tell me
    How to call a Java Class from another Java Class assuming both in the same Package??
    I want to call the entire Java Class  (not any specific method only........I want all the functionalities of that class)
    Please provide me some slotuions!!
    Waiting for some fast replies!!
    Regards
    Smita Mohanty

    Hi Smita,
    you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
    e.g.
    you have developed A.java and B.java, both are in same package.
    in implementaion of B.java
    class B
                A obj = new A();
                 //to access A's methods
                 A.method();
                // to access A's variable
                //either
               A.variable= value.
               //or
               A.setvariable() or A.getvariable()

  • How to load a java card applet into a java card

    Dear All,
    I am a novice to java card technology..
    I have done some search on how to load a java card applet into a smart card but haven't found a satisfactory answer. I have read about installer.jar and scriptgen tool but I want to load the applet from a java program and not from command line. It would be of great help if somebody can help me out.
    If somebody can share a sample program which load a javacard applet(.CAP file) into a smart card, I will be very thankful.
    I am able to find some client applications which help us send APDU commands and recieve response APDU's to interact with an applet loaded on to the smart card but not application which actually load the applet.
    I have heard of OCF and GP.. some say that OCF technology is outdated and no longer in use.. can somebosy throw some light on this too..
    cheers,
    ganesh

    hi siavash,
    thanks for the quick response.. i checked out GPShell as suggested, it looked like a tool by which one can load an applet on to card and send some sample apdu commands... but I want to load the applet from the code.
    My application should look something like this.. it will be a swing applicaton where I have a drop down with a list of readers, I select the one desired and then click on "LOAD" after inserting a blank java card, at this point my applet which is stored in my DB should get loaded on to the java card. The next step should be to personalize it where I enter the values for the static variables of my applet and click "PERSONALIZE", at this point all these values should be embedded into APDU commands and sent to the java card for processing.
    For achieving this I am yet to find a comprehensive sample or documentation on the net.
    Please help...
    regards,
    ganesh

  • How to use a java class in difference project under a same workspace!

    Hi, there:
    I have a problem. I want to reuse a java class which is located in another project of the same workspace. I do not know how to set the two project setting or how to import the java class. I deeply appreciate.
    Sheng-He

    include it as a library
    open project settings goto libraries and simply add your class

  • How to configure Sun Java System Application Server Enterprise Edition 8.1

    hi all,
    How to configure Sun Java System Application Server Enterprise Edition 8.1 to my IDE..( jstudio)
    I have installed jes for my windows system.. so that i have removed platform version of Application Server..
    I try to add the Enterprise application Server (Sun Java System Application Server Enterprise Edition 8.1) to JStudio IDE..
    but i couldn't;

    Configuring your IDE to integrate with Sun App Server is something you probably will have to ask in some sort of JStudio forum. Other than for Netbeans, Eclipse, or possibly IntelliJ IDEA, you might not have much luck answering an IDE question here. I could be wrong though. Maybe somebody will have an answer for you and set me straight.

  • How to load oracle data into SQL SERVER 2000?

    how to load oracle data into SQL SERVER 2000.
    IS THERE ANY UTILITY AVAILABLE?

    Not a concern for an Oracle forum.
    Als no need for SHOUTING.
    Conventional solutions are
    - dump the data to a csv file and load it in Mickeysoft SQL server
    - use Oracle Heterogeneous services
    - use Mickeysoft DTS
    Whatever you prefer.
    Sybrand Bakker
    Senior Oracle DBA

  • Problem when loading simple java class in Oracle

    Hi,
    I am using loadjava to load the java class in the oracle database. But it is failing. Can some one please help me out with this.
    Command.
    loadjava -thin -user username/password@zrtph0ja:1521:database -resolve firstProcedure.class
    Errors:
    Error while computing shortname of firstProcedure
    ORA-06550: line 1, column 13:
    PLS-00201: identifier 'DBMS_JAVA.SHORTNAME' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error while computing shortname of firstProcedure
    ORA-06550: line 1, column 13:
    PLS-00201: identifier 'DBMS_JAVA.SHORTNAME' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ORA-29521: referenced name java/io/PrintStream could not be found
    ORA-29521: referenced name java/lang/Object could not be found
    ORA-29521: referenced name java/lang/String could not be found
    ORA-29521: referenced name java/lang/StringBuffer could not be found
    ORA-29521: referenced name java/lang/System could not be found
    loadjava: 7 errors
    Please help.
    Regards
    Sudhir
    null

    U havent installed JServer in ur DBMS.
    Read the Oracle 8i JServer Manual for
    manually installing the Oracle JVM.

  • How to invoke a Java class located outside of  BPEL PM server?

    I konw the way of invoking the Java class deployed in BPEL PM server by using WISF binding. But now I have a legacy Java Application located in another Appache Server.I hope the BPEL process can invoke this legacy Java Application. How should I do?
    Anybody can help me?
    Kind regard
    Qu

    You can use axis to create a webservice out of this class, or do the same with oracle jdeveloper - remote class mean remote protocol..
    /clemens

  • Seeking problem for how to load object in class Test to class Server...

    hello everyone, currently, i put some method named calla() in class Test....i have difficulty when to invoke the method from class Server...this is my Server class code
    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.net.InetSocketAddress;
    import java.net.URI;
    import com.sun.net.httpserver.HttpExchange;
    import com.sun.net.httpserver.HttpHandler;
    import com.sun.net.httpserver.HttpServer;
    import com.sun.net.httpserver.Headers;
    public class SimpleHttpServer2{
    public static void main(String[] args) throws Exception { // for the main method (basic main method)
    HttpServer server = HttpServer.create(new InetSocketAddress(12345), 0);
    server.createContext("/", new RootHandler());
    server.setExecutor(null); // creates a default executor
    server.start();
    MainDialog a = new MainDialog();
    a.calla();
    static class RootHandler implements HttpHandler {
    public void handle(HttpExchange t) throws IOException {
    URI xyz = t.getRequestURI();
    String response = "";
    String resp = "" + xyz;
    if(resp.equals("/?act=1")){
    // put in wait_doc code
    // then if a document is ready,
    // put the results of the read in response below
    response = "Waiting to read";
      // ClassLoader newClassLoader = new
       //       java.net.URLClassLoader( newClassLoader.calla );
    // response = a.calla();
    }else if(resp.equals("/?act=2")){
    response = "Initialise the reader";
    }else
    response = "Error!";
    t.sendResponseHeaders(200, response.length());
    OutputStream os = t.getResponseBody();
    os.write(response.getBytes());
    os.close();
    }i hope u guys can pull me out from this problem...thank you

    i want to run it in my browser....but the process didnt show up...its just run in my IDE called Netbeans....bcause i can see i put the object at main class...so, it just directly call it...but, what i want to do is, if at browser, i type : http://localhost:12345/?act=1 , it will return to the browser, the process that include in calla() inside Test class....when i put this object below main class, i know, this browser process that calla(), but it just display on my Netbeans not to browser...then, im try use ClassLoaderURI, but still not get....this is my final step in doing my project...if i can invoke this calla() into my browser, then, my project will finish...so, any idea, how to call....previously, im just try put this mehod inside RootHandler method like this:
    HttpServer server = HttpServer.create(new InetSocketAddress(12345), 0);
    server.createContext("/", new RootHandler());
    static class RootHandler implements HttpHandler {
    public void handle(HttpExchange t) throws IOException {
    URI xyz = t.getRequestURI();
    String response = "";
    String resp = "" + xyz;
    // URI z;
    if(resp.equals("/?act=1")){
    // put in wait_doc code
    // then if a document is ready,
    // put the results of the read in response below
    response = "Initialise the reader";
    MainDialog abc = new MainDialog();
    abc.Initialise();
    System.out.println("response: " + abc);
      // ClassLoader newClassLoader = new
       //       java.net.URLClassLoader( newClassLoader.calla );
    // response = a.calla();
    }else if(resp.equals("/?act=2")){
    response = "Waiting the reader";
    MainDialog abc = new MainDialog();
    abc.Reader();
    }else
    response = "Error!";
    t.sendResponseHeaders(200, response.length());
    OutputStream os = t.getResponseBody();
    os.write(response.getBytes());
    os.close();
    }but, its just run in my IDE again, not to browser...so, how to settle this problem??

  • How to create custom java class in Content Server

    Hi All,
    I want to develop a custom java class (.class) file and upload in the UCM(Stellent Content Server). The problem is that I have to use some objects like DataResultSet, SharedObjects etc in my java class file. Since these class files resides in the Content Server I am not able to create a custom java class with these objects.
    Can any one help me to solve the above issue
    With thanks and regards
    Mohan

    Hey there,
    All of the core content server class files are included in a single jar file. This jar is in one of 2 places in the 10gr3 version of UCM:
    1. If you have an unpatched content server include $IntradocDir/shared/classes/server.zip in your classpath
    2. If you have a patched content server include $IntradocDir/custom/CS10gR35CoreUpdate/classes.jar in your classpath.
    In UCM 11g the jar file is located in %MIDDLEWARE_HOME%/Oracle_ECM1/ucm/idc/jlib/idcserver.jar
    P.S. Venkat is correct, post UCM specific questions in the ECM forum.
    Hope that helps,
    Andy Weaver - Senior Software Consultant
    Fishbowl Solutions < http://www.fishbowlsolutions.com?WT.mc_id=L_Oracle_Consulting_amw_OTN_WCS >

  • Java class how to load a JavaFX class?

    I want to start a JavaFX application from a Java class,how can implement it?
    Thank you so much!

    I want to start a JavaFX application from a Java class,how can implement it?
    Thank you so much!

Maybe you are looking for

  • Pdf and vector files will not open in Adobe Illustrator after Yosemite Update

    I updated my OS on recommendation from apple. Pdf and vector files will not open in adobe illustrator now. Am i using the latest OS?

  • Attaching a stylus to the Droid X...

    Well, I've tried looking at pictures but can't seem to get the angle I'm looking for, and since my phone won't be here until next week, I was wondering if anybody could tell me if it's possible to attach a stylus to the Droid X...? Some phones have t

  • How to Export EUL tables ?

    Hi all, I have upgraded Discoverer admin/ desktop form 4.1.37 to 4.1.48. When i try to connect to Administrator it asks me to export EUL tables so that it will upgrade EUL. Iam unable to connect to Adminstrator/Desktop 4.1.48 as a Application user. H

  • How to reinstall Elements 12 [was:?]

    I accidently clicked on UNINSTALL ELEMENTS 12.  How do I get it back?

  • Cannot import video file into LR5

    I'm trying to import a video file (.vob) into LR5 do do some basic editing. When I point LR at the folder it cannot "see" the file and so will not import it. Does LR look for specific file types? If so which ones? Working in win7 64bit  and LR 5.2 Al