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)

Similar Messages

  • How to trigger a JAVA class when replication is processed?

    Hi,
    How I can trigger a JAVA class when a replication is processed?
    Also I want to get the payload involved in that process.
    Is there any way to do this?
    Please post your suggestions on this...
    Regards,
    Shankar .A

    If you are interested in building your own payload format, check the ContentBuilder interface.
    If you want to get notified, when a replication is triggered, check the Sling event tab in the Felix console (http://localhost:4502/system/console/events). You can register your event OSGI event listener and process that information. See http://sling.apache.org/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html for some more information and samples.
    Jörg

  • 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-

  • 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 .....

  • 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 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

  • 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 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

  • Call a java class when deleting a user

    Hi,
    I have identified the "Deprovision Form" as the form used when you want to delete a user. What I would to do is invoke a java class when you press on OK on the delete user page.
    thanks in advance.

    You can try to call the java class in a Field's Expansion block by putting the condition that
    <cond>
    <eq>
    buttonValue
    OK
    <eq>
    then call java....

  • "You are opening the application----- for the first time"  error

    I've seen a few people post about this from as far back as 2005 but I haven't found anything that worked for me. I believe I started having this problem after upgrading to Snow Leopard.
    When opening an application, most often Microsoft Office by opening a specific document/file, I get the warning that I'm opening the application for the first time. This is mostly an annoyance but I don't know how to get this error to stop coming up. I saw a suggestion to delete caches and make sure the application was set as default for that file type; these haven't solved the problem yet.
    Thanks!!

    Thanks for the reply, unfortunately I'm not sure it helped. I did recently trash a couple caches, but this was after the problem had started. I found an old post that suggested the cache might be corrupted and that it would be a good idea to trash it.
    The link you posted notes that the deleted cache could cause that problem, but I would think a new cache would be created and it would be resolved. Is it possible I have a setting that's erasing it? How would I change that? It also sounds like in the link you posted that theMacMac's problem eventually went away without explanation.

  • How do I sign in to my iTunes for the first time? Everytime I try it says I have not used iTunes before, and to review my account information.

    How do I sign in to my iTunes for the first time? Everytime I try it says I have not used iTunes before, and to review my account information.

    It sounds like you are trying to create a new icloud account, not just logging into an existing account.  When you type in your Apple ID and get that error, it's because you are trying to create an account using the same ID that is already being used in another account.
    Go to Settings>iCloud and scroll to the bottom of the screen.  If you are logged in, press the Delete button, then try logging in with the existing ID.
    As for pics, the most secure way is to connect ipod to PC with USB and look at the Photos tab for your device in iTunes.  Using Photo Stream is another way, but it doesn't always work, depending on conditions.

  • Selection screen value not assigning to the value when executed for the first time

    Hi ,
    Im My program at selection screen there are company code, vendor account and open items at key date(takes system date as default value).
    Facing problem at open items at key date - Open key date parameter is taken from LDB - KDF.
    First time when I am executing the program it is taking system date value in the selection screen variable even though I have given the different date.
    This problem is only when I execute for first time or press enter without giving company code.
    Can any one please help us to come out of this problem.
    Regards
    Sri Bhargavi

    HI,
         you can use the Event as AT SELECTION-SCREEN

  • Known Issue while running Adobe Story desktop application for the first time on Mac OS 10.8

    You may encounter the following error message while running the Adobe Story desktop application for the first time on Mac OS 10.8:
    For resolution, please go to:
    http://helpx.adobe.com/story/kb/run-story-app-mac-os.html

    The /Developer directory contains the compiler(s) and various tools and libraries.
    Does your user account name really contain a single quote? If so, it looks like the quote is getting eaten by one of the build scripts, which is resulting in a file path that doesn't exist.

  • How to disable chanllenging questions while user log in for first time

    Hi All,
    How to disable challenging questions while user log in for first time in OIM 10g and OIM 11g
    also i need to know how to change the Oracle logo with custom logo in both versions

    In 11G:
    To disable challenge questions at start up: http://download.oracle.com/docs/cd/E17904_01/doc.1111/e14308/system_props.htm#BABBDCJH (System Property Named: "Force to set question at start up)
    To change logo: http://download.oracle.com/docs/cd/E14571_01/doc.1111/e14309/uicust.htm#CHDIFJEJ
    In 10G:
    Dig the documentation.
    A suggestion, please go through the documents first as they have quite a bit of information.
    HTH,
    BB

Maybe you are looking for

  • Handling error in data entry screen

    Dear experts, I developed a module pool program which is an entry screen capturing some fields such as matnr,lifnr. Incase there is a failure to store data on to mseg table  using BAPI for movement, i have set a custom message by using the command as

  • WSDL generation from existing WebService

    Hello everybody, we have got an existing WebService which we want to migrate to XI. Because we don't want to change the clients interfaces we would like to import the WSDL and XSD and than generate a WSDL from XI. First problem: The WebService exists

  • Show names acting up on xygraph

    I have a tab control layout in which an xy graph is on one tab and the inputs for it are on the other. Ive set up the cursors on the xy graph to show names, although when i add a cursor, then look at it on the other tab, i see the name twice, once ab

  • I am having a hard time . i am trying to import  .MOV into adobe premiere elements 10. ???

    i am trying to import     .MOV into adobe premiere essentials 10.   please help

  • BOE XIR2 SP5 All processing servers are down and not starting up

    Hi Guys, My all processing servers are down and not starting up I restarted all the service by ccm.sh I killed all the servives manually and started again Still  only processing servers go down  any clue guys I  really stucked here I cheked logs I go