Listeners, load a class on startup and creating threads in infinite loop

This is an identical post to the one I made in the jsp forum. I do this as I know, being a regular here, that there are equally good people(in j2ee web application development) in both these forum, but many of them stick to their particular forums of choice - jsp / servlets.
I was wondering if there is any means by which I could launch my own class when tomcat starts (in the same jvm).
1. I need one or more Thread/TimerTask because the requirement is such that the application would have continous data drops (in the form of logs) which has to be picked up, parsed and pushed into a db. Another part of the application reads the data from the db on requests (http) and displays it over the web. The thread has to poll for arrival of new logs and then hand it over to a framework for parsing and inserting the parsed data to a db.
2. I know that I can possibly use a servlet with a load-on-startup value greater than 1 and code my requirement into the init method. However, using a servlet for a functionality different from servicing http requests has me worried. (valid ?), not to mention the fact that Iam very uneasy about creating threads from within Servlets.
3. I googled hard and found that I could probably use a tomcat specific context lifecycle listener.
4. I could also possibly use the servlet api - the ServletContextListener.
5. I have rejected #2 and settled on either #3 or #4 - the ServletContextListener or Tomcat specific Lifecycle Listener, though the later, as I said binds me to Tomcat (which is ok for me). Are there any other specific (dis)advantages of using either especially when I have to create threads from within them (on context startup)? Other than memory leaks, killing the thread objects & associated resources on context shutdown, is there anything else that I need to watch out for while using threads.
6. I wonder is there is there a plain startup hook available in tomcat (rather than listeners) - from where I can launch a class that starts a thread in the same jvm as tomcat's ?
Thanks In Advance,
Ram.

Anybody ? Sorry for bumping up.
Thanks,
Ram.

Similar Messages

  • Trouble transferring and authorizing- In an Infinite loop

    I am stuck in an infinite loop. Upon transferring from iphone to my laptop it says I need to authorize computer, my old username comes up, i enter the correct one and it says computer is already authorized and it loops back around.

    have the reading loop in a different class which will have its own Thread running aside from the main program's thread. This way your application will do both at once :)

  • Triggering event FMRE-CREATED in an infinite loop

    Hi guys,
    Iu2019m having a big problem in Public Sector Management with Founds Management Government when I create a Found reservation Tcode FMX1.
    My problem is the triggering event FMRE-CREATED  (event to start the Workflow) because when the document is created, this event is generated by the system which is fine, but inside on my Workflow I have a task to change the status with FMRE-SetLock, when this method is executed, automatically trigger an event FMRE-CREATED again, so my WF gets in a infinite loop.
    How can I tell the system to donu2019t trigger this event when the status is changed?
    Thanks a lot
    Felipe Uribe.

    Hi,
    but inside on my Workflow I have a task to change the status with FMRE-SetLock, when this method is executed, automatically trigger an event FMRE-CREATED again, so my WF gets in a infinite loop.
    How you changing the status? Check any Function Module or BAPI to change the status.
    You have acheive it via Start Condition, check are you getting entry in the Table  SWFREVTLOG for Creation.
    If second time creating, check for the entry in the table, if found not allow it.
    Regards,
    Surjith

  • Problem in loading a class from server

    hello,
    Please help me ,i m using this code to load a class from server and this code load this successfully but i don't how to make object of class that is just loaded.
    i want to load the class and use its method in my program please help me i m in very critical position.
    pelase help me give me hint
    import java.sql.*;
    import java.net.*;
    import java.io.*;
    public class MyLoader
    public static void main (String argv[]) throws Exception
    URLClassLoader loader = new URLClassLoader(new URL[] { new URL("url") });
    // Load class from class loader. argv[0] is the name of the class to be loaded
    String str = "FinalMyConnection";
         Class c = loader.loadClass (str);
    System.out.println(c.getClass().getName());
    // Create an instance of the class just loaded
    Object o = c.newInstance();
         System.out.println(o.getClass());
         FinalMyConnection mycon = new FinalMyConnection();
         String query1 = " select * from game_master order by game_id;";
         mycon.connect();
              ResultSet rs1=mycon.executequery(query1);
              while (rs1.next())
              String s1=rs1.getString(1);
                   String s2=rs1.getString(2);
                   System.out.println("game_id"+s1);
                   System.out.println("game_name"+s2);
    }

    also load all required parser and sax classes into oracle,i.e.,
    you can load the '.jar' file containg all the parser and sax classes and then load you ContentHandler class.

  • Loading a class via reflection without knowing the full qualified path ?

    Hi there
    I d like to load a class via reflection and call the constructor of the class object. My problem is that I dont know the full qulified name e.g. org.xyz.Classname bur only the Classname.
    I tried different things but none seem to work:
         1. Class c = Class.forName("Classname");  //does not suffice, full qualified name required
    2. ClassLoader classloader = java.lang.ClassLoader.getSystemClassLoader();
             try {
               Class cl = classloader.loadClass(stripFileType(Filename));//if i do not pass the full qualified name i get a ClassNotFoundException
    3. I tried to consruct a class object with my own classloader , calling:
              Class cl = super.defineClass(null, b, 0, b.length );     b is of type byte[]This almost works. I get a class Object without knowing the full qulified path. I can transform a filename into a raw array of bytes and I get the class out of it. But there is still a problem: If there are more than on classes defined in the same textfile I get an InvocationTargetException.
    It looks like this:
    package org.eml.adaptiveUI.demo;
    import com.borland.jbcl.layout.*;
    import java.awt.*;
    import org.eml.adaptiveUI.layout.*;
    import javax.swing.*;
    import java.awt.event.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class twoButtons extends JFrame {
      SPanel sPanel1 = new SPanel();
      JButton jButton1 = new JButton();
      GridBagLayout gridBagLayout1 = new GridBagLayout();
      GridBagLayout gridBagLayout2 = new GridBagLayout();
      public twoButtons() throws HeadlessException {
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      public static void main(String args[]){
        twoButtons twob = new twoButtons();
        twob.pack();
        twob.show();
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(gridBagLayout1);
        jButton1.setText("button 1");
        jButton1.addActionListener(new TransformationDemo_jButton1_actionAdapter(this));
        this.getContentPane().add(sPanel1,  new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
                ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(57, 52, 94, 108), 35, 44));
        sPanel1.add(jButton1,  new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
                ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 41, 0, 0), 0, 0));
      void jButton1_actionPerformed(ActionEvent e) {
        System.out.println("button 1 source: " + e.getSource());
        System.out.println("d: " + e.getID());
       System.out.println("/n commmand: " + e.getActionCommand());
    class TransformationDemo_jButton1_actionAdapter implements java.awt.event.ActionListener {
      twoButtons adaptee;
      TransformationDemo_jButton1_actionAdapter(twoButtons adaptee) {
        this.adaptee = adaptee;
      public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }As you can see there is the class TransformationDemo_jButton1_actionAdapter class defined in the same classfile. The problem is now that the twoButtons constructor calls the TransfomationDemo_jButton1_actionAdapter constructor and this leads to InvocationTargetException. I dont know if this is a java bug because it should be possible.
    Can you help me?

    hi thanks at first,
    the thing you mentioned could be a problem, but I dont think it is.
    If I have the full qualified name (which I havent) then everything goes normal. I only have to load the "twoButtons" class and not the other (actionadapter class), so I dont think this is the point. In this case the twoButtons constructor constructs an object of the actionadapter class and everything goes well. The bad thing is though that I do not have the full qulified name :(
    Invocation target exception tells me (in own words): Tried to acces the constructor of the actionadapter class (which is not public) out of class reflectionTest class .
    reflectionTest is the class where the reflection stuff happens and the twoButttons class is defineClass() ed.
    The problem is, only twoButtons class has the rights to call methods from the actionadapter class, the reflection class does not. BUT: I do not call the actionadapter methods from the reflection class. I call them only from the twoButtons class.
    I hope somebody understands my problem :)

  • Why oc4j allows to use File IOs and manage thread in EJB?

    I don't understand why Oc4j 9.0.2 allows to use File IO and create thread in EJBs? These things should be denied in its implemenation.

    Any chance I can get this data?

  • [SOLVED]Create .service file to load powertop settings at startup.

    Hi I installed powertop and ran it
    sudo powertop -html
    and the recommendations I got, i pasted them in a file, and saved it as startup.sh, and made it executable.
    Now with init, i could write it in /etc/rc.local so that it would be called automatically at startup, but with systemd,
    I think one would need to create a systemd service file which could be enabled for startup,and would call the startup.sh file.
    Can anyone help with creating the .service file, or alternatively, suggest a simpler method for loading powertop's reccomendations at startup? Thanks!
    Last edited by aaditya (2013-09-04 18:29:53)

    Really, this should be done with the tools that are inherently in the system.  So it should be achieved with module options, udev rules, sysctl.d/sysctl.conf, and in some cases, tmpfiles.d.
    See this wiki page to get an idea of how to get this stuff going.
    You can use some kind of rc.local service if you want.  But it is probably moer appropriate to have these things load only if necessary.  For example, if there is a power saving option for my ethernet card, but I choose to only load the module when I need it (therefore blacklist it) in order to really save power, it would be silly to have a script that tries to write values to a directory in /sys/class/net that doesn't exist.
    Alternatively, you could use something like laptop-mode-tools, which allows one to have these settings turned on or off depending on the A/C state of the machine. But I really think that with machines these days, there is really not much of a difference whether these power saving functions are on or off, in terms of an average users computing experience.

  • I tried to sync my phone and received this message: "iTunes was unable to load data class info from sync services. Reconnect or try again later." Now it doesn't sync calendars because it says I need to download Outlook, which I already have

    I have synced my phone to my computer several times. This time i received this message: "iTunes was unable to load data class infor from sync services. Reconnect or try again later." It says if I want to sync calendar I must install Outlook to my computer?? Why does iTunes not recongnize that I already have Outlook installed on my computer?

    This worked for me...i did a restore on my computer to take it to a date prior to the last update i did on itunes and now it works just fine.  Everytime i do a backup it syncs my Outlook! When a request comes up saying there's a new version of itunes click here to download the latest one DON'T do it.
    Here's how to do a restore on your computer:
    Create a restore point
    A restore point is a representation of a stored state of your computer's system files. You can use a restore point to restore your computer's system files to an earlier point in time. Restore points are automatically created by System Restore weekly and when System Restore detects the beginning of a change to your computer, such as when you install a program or a driver.
    System image backups stored on hard disks can also be used for System Restore, just like the restore points created by system protection. Even though system image backups contain both your system files and personal data, your data files won't be affected by System Restore. For more information about system images, see What is a system image? You can create a restore point manually at any time by following the steps below.
    Go to the Windows website to watch the video. (1:08)
      Click to open System. 
    In the left pane, click System protection. If you're prompted for an administrator password or confirmation, type the password or provide confirmation.
    Click the System Protection tab, and then click Create.
    In the System Protection dialog box, type a description, and then click Create.
    For more information about System Restore, see What is System Restore?
    I HOPE THIS WORKS!
    Annette9114

  • ITunes was unable to load data class information from Sync Services.  Reconnect or try again later AND Your iPhone has never been backed up to this computer AND always Not Responding

    First: I get the message telling me that "iTunes was unable to load data class information from Sync Services.  Reconnect or try again later."
    Second: In the Summary Tab under Backups, iTunes is telling me that my iPhone has never been backed up to my computer - which is not true. It's also telling me that my iPhone has never been backed up to iCloud. Again, not true. Although my backups are all missing from iTunes, I can see what I think is them in their folder: C:\Users\*your user name here*\AppData\Roaming\Apple Computer\MobileSync.
    Third: iTunes is SLOOOOOOOOW. It takes nearly ten minutes - sometimes more - to launch, and when it does, it's constantly not responding. It seems every time I touch something it stops responding.
    Fourth: I've been searching this "help" forum for a solution, and I've seen many other references, yet the only suggestion I've seen from someone from Apple is a reference to a solution that is over 2 years old - and DOESN'T WORK for anyone I can see who's tried it!
    I've tried everything I could think of, and that others have suggested, including:
    Uninstalling and re-installing iTunes
    Ensuring I have the latest version of iTunes
    Re-setting sync history
    Renaming my Backup folder at the path above, and letting iTunes create a new one
    Running around the house whilst pulling my hair and yelling obscenities
    None helped. At all.
    Hmmm... Been a devoted Apple/iOS guy for years, but maybe it's time to switch to Android?

    I've resolved the issue with iTunes constantly not responding. It's a bit embarrassing. I had a DVD in the drive that was corrupt, and once I was able to remove it - BAM - iTunes ran perfectly.
    I'm still getting the Sync Services message, and my backups are still not showing in iTunes.
    Getting there.... I hope!

  • Problems creating jar in netbeans - Failed to load main-class

    Hi,
    I was wondering if someone could help with a problem I'm having creating a jar. I have a project in netbeans 6.5 and used Netbeans' GUI Builder (matisse) to create some of the UI elements in the project. I've tried many times to do "Clean and Build" to build my project. It builds successfully, but the jar that gets created gives the following error:
    "Failed to load Main-Class manifest attribute from C:\... filepath here...."
    I checked the manifest file, and that contains:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.1
    Created-By: 11.0-b16 (Sun Microsystems Inc.)
    I tried adding Main-Class: gui.MainGUI (which would be the class that contains my main function) to this file and tried running it again, but it then said "Invalid or corrupt Jarfile" when I try running it. MainGUI does exist in the Jar. I also tried with just Main-Class: MainGUI, same error.
    Does anyone know what I'm doing wrong? In NetBeans, if you go to the project properties, Main Class is specified as "gui.MainGUI" also, so that isn't the issue. Additionally, I have Swing Layout Extensions and Swing Application Framework included in the added libraries (required for the GUI builder, I think).
    Thanks for any help.

    Try creating a new Java project and be sure to choose project type Java Application.
    Copy source code to the newly created project and try again.

  • Itunes was unable to load data class information from sync services.Reconnect and try again later.

    when I open itunes I get message " itunes was unable to load data class information from sync services. reconnect or try again later "
    I am unable to sync my ipad 2 or iphone 4 through itunes. I have tried all suggested options, removing itunes and related components from control panel + verified completely uninstalled from C program files + then reinstalling latest version of itunes (version 11.3.1.2). Also tried running itunes as administrator. Also tried reset sync history in itunes  Also tried system restore on windows 7 from earlier period.Still get the same above message.
    I run 64bit windows 7. Have recently renewed my Norton Intenet Security. Everything was OK up till then. Could this have anything to do with it.

    A quick cursory browse seems to point that the problem is on Apples end since the last update of iTunes, theres loads of forum posts about it but Apple themselves arent responding as yet other then the usual "unplug, delete sync data, reconnect or completely uninstall iTunes" spiel which doesnt work so hopefully they will fix it sooner or later

  • I get this message when i try to sync and download my iphone:  itunes was unable to load data class information from sync services, reconnect or try again later.  what does that mean and who do you fix it

    I get this message when i try to sync and download my iphone,   ITUNES was unable to load data class information from sync services,  reconnect or try again later.    this has happened twice.  i have not downloaded by phone in several months.  the first time i got this message i did not understand i and left my phone plug in for 12 hrs and it never did anything.   today.  when i got the message i just unplugged it.
    help

    http://support.apple.com/kb/TS2690?viewlocale=en_US&locale=en_US

  • HT1386 my ipad won't sink; I continually get message:  itunes was unable to load data class information from Sync Services. Reconnect or try again later.  I have done both several times and still receive same messaage.

    My iPad won't sink with my computer.  I continually receive this message: "iTunes was unable to load data class information from Sync Services.  Reconnect or try again later."  I have tried this over a number of days and receive the same message.  Any suggestions??

    IOS: Syncing with iTunes
    http://support.apple.com/kb/HT1386
    Apple - Support - iPad - Syncing
    http://www.apple.com/support/ipad/syncing/
    ITunes: Syncing media content to your iOS devices
    http://support.apple.com/kb/ht1351
    There are some similar posts on the right side of this page (More Like This). Look at those posts.
     Cheers, Tom

  • I can't transfer music to my ipod touch and a window pops up saying that iTunes was unable to load data class information from Sync Services.

    I'm trying to transfer music to my iPod touch using iTunes, but it won't let me.
    It syncs fine now, but then this window pops up and I can't transfer musics.
    Is there anyone who can help me?

    http://support.apple.com/kb/TS2690
    iTunes for Windows: "Unable to load data class" or "Unable to load provider data" sync services alert

  • I have an ipod touch 5th gen and when connected to itunes i get a message saying itunes was unable to load data class information from sync services. reconnect or try again later. anyone got any ideas? i've tried most things on most forums but still no jo

    i have an ipod touch 5th gen and when connected to itunes i get a message saying itunes was unable to load data class information from sync services. reconnect or try again later. anyone got any ideas? i've tried most things on most forums but still no joy

    Try here:
    iTunes for Windows: "Unable to load data class" or "Unable to load provider data" sync services alert
    If not successful see the previous discussion on the right side of this page with the green checkmark.

Maybe you are looking for

  • When i download itunes 10.6, it downloads but has an error when it installs. What can i do to fix this?

    hi, i tried to download itunes 10.6, the download worked fine, but halfway through the installing it stopped and gave me an error. does anyone know how to fix this?

  • Pdf creation problems

    I have been updating various computers and one of them is giving me problems.  When the user sends a pdf print from AutoCAD via our pdf pc3 file, AutoCAD sends the print just fine, but then the file ends up in the pdf pc3 que and gives and error mess

  • Import of structure of folders

    Hi I have a question in my  dev system I have created  many folders  then  my question is Can I import these structure from dev to QA on cfolders? Regards Danny

  • Video Asset Management

    Looking for suggestions. We are a small business with 2-3 people editing on FCPX in the same room all on separate computers with separate versions of FCPX working on generally separate projects. We are all plugged into the same hard drive storage to

  • Is it Mandatory to Load the Accounting Definitios wrt SLA?

    Hi Gurus, We have upgraded our system from 11.5.10 to 12.1.2. I have few Questions regarding the Loading Accounting Definitions w.r.t SLA. Do we need to Load the Accounting Definitions? Can we validate the existing Accounting Definitions? Will that b