Letting tomcat start a class

I have a class which runs as a daemon thread. I want this class to start right after tomcat boots. Is there a way to make Tomcat execute a class on startup?
The only way I can think of is creating a simple class which fetches a JSP that starts the thread. If anyone knows a better solution, I would be grateful.

If you want to run something on startup you can do it via a web.xml file:
   <servlet>
      <servlet-name>StartupServlet</servlet-name>
      <servlet-class>xxx.xxx.xxx.xxx.StartupServlet</servlet-class>
      <init-param>
      <param-name>name</param-name>
      <param-value>value</param-value>
      </init-param>
      <init-param>
      <param-name>name2</param-name>
      <param-value>value2</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>     
   </servlet> 

Similar Messages

  • How to run class after Tomcat starts?

    Hello!,
    I want to run a class after Tomcat start.
    How can I achieve?
    Reg,
    Chetan

    Well the official way to do it it to create a class which implements org.apache.catalina.LifecycleListener. Then you can name the class in a <Listener> element in server.xml. It can appear at various levels e.g. inside the Engine block, and it will receive notification when that level starts and stops.

  • Can i let tomcat automatically start when Window be up

    Hi,
    I developer a small client-server search project for a not profit organization, the project is being testing , but i don't why and who, shout down the PC and reopen it , I have a password , avoid people to tuch and change the Web application, databaese, and so on. its a way to let tomcat automatically up when windowns start?
    Thank you
    by the way is weblogic is free for use?

    I run Tomcat as a Windows Service under WinXP, there are instructions on how to do this on the Tomcat site. The service can be configured to start automatically with the system.
    Weblogic is free for development use, for comercial use it costs a large amount of money. I don't know situation for non-profit organizations, but yu could contact BEA. For a small project you are probably better off with Tomcat and Hibernate.

  • My 4s worked fine until i upgraded to IOS8. Is anyone starting a class action lawsuit against Apple?

    My 4s worked fine until i upgraded to IOS8. Is anyone starting a class action lawsuit against Apple?

    I already had all of the features turned off, had 20% free, all transparency were turned off and a few apps were on refresh and now are all turned off.
    Like I said, my phone worked fine until I installed IOS 8 and now the screen will freeze intermittingly and runs very slowly when searching it. In other words IOS 8 significantly diminished the operation of a perfectly good phone and Apple will not let you roll it back to IOS 7. They F’d up my phone intentionally to sell us all the latest model.

  • BB protect: Error starting net_rim_bb_dryad_gui:Class 'net.rim.device.api.iui.theme.Themes$Writer' not found

    Hello there.
    I am using a blackberry curve 8520. It came with version 4 of the OS. I upgradede it yesterday, 15 feb to version 5. After the upgrade so far I am experiencing 2 technical problems.
     1 is with the blackberry protect app. which when I launch give me this error message: BB protect: Error starting net_rim_bb_dryad_gui:Class 'net.rim.device.api.iui.theme.Themes$Writer' not found with an OK button. 
    2. When I enter the blackberry app world it give me the following message: A BlackBerry Idenity update is neeeded. Would you like to install it now ? yes/no. The problem here is, it never installs, tried it the whole day yesterday as I am still trying it now. I have rebooted the device, removed battery and sim several times. Still. This is what it give me instead. Blackberry idenity installation failed. Please try again later. (80003).
    Sorry if I am askign basic questions but I am not a techy person at all. Thanks in advance, 

    Hi and welcome to the forums!
    We need to fix your issues in reverse order.
    The Blackberry Protect program requires a valid Blackberry ID to operate.
    (To use BlackBerry Protect you must have the following items:
    • BlackBerry® ID account
    • Data plan from your wireless service provider)
    I suggest we use KB29613 to fix the Blackberry Identity problem.
    Once your Blackberry ID is established you can access Blackberry App World
    and download the latest version of Blackberry Protect.
    Let us know how it goes!
    Thanks,
    Bifocals
    KB29613 The error "BlackBerry Identity installation failed. Please try again later. (80003)" is displayed within BlackBerry App World
    User Guide - BlackBerry Protect
    Security Note - BlackBerry Protect
    Click Accept as Solution for posts that have solved your issue(s)!
    Be sure to click Like! for those who have helped you.
    Install BlackBerry Protect it's a free application designed to help find your lost BlackBerry smartphone, and keep the information on it secure.

  • Perform action when Tomcat start and stop

    Hi. I'd read a thread about performing an action when Tomcat starts with configuring the web.xml file. I just wonder whether it's probable or not to perform an action when the Tomcat is stop. I mean like when the Tomcat is called to stop it'll run a class or call a servlet first before it's finally shut down. Is it possible to do that???
    Thanx!

    It should by possible with a Listener. You can see the use within the server.xml with the ServletLifecycleListener.
    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
    debug="0"/>
    Look into the LifecycleListener Interface from the source and the implementations. I see some samples with mBeans using this interface.
    Examples:
    http://rollerweblogger.org/page/roller/20040625
    I 'have never try it out, but it should work like described!
    regards Dietmar

  • Jonatan R. Aug 1, 2012 5:42 PM Hello, didnt really know hwere to post this guess it more belong under like "computers" generally,    but! For a while...        (-THE LONGER VERSION) : No whait!, let me start where it all began, 2009, a december (erhh.. ii

    Hello, didnt really know hwere to post this guess it more belong under like "computers" generally, 
    but! For a while... 
        (-THE LONGER VERSION) :
    No whait!, let me start where it all began, 2009, a december (erhh.. iii think? Hwatever!) litlle me hwere nearly Totally blank to the computer world. And suddenly it stood there on the table, a shining (it was shining back there) new "hp pavillion entertainment pc" with its smell of fresh plastic mixed hwith the strong smell from the cardboardbox, remember it as if it were yesterday
    ... Since then.... I have today a good solid pc knowing! (at more advance level cmd,bott menu, recovery, blah, blah... NERD!) here at the last awhile, ive prommised to make a lot! A lot of video projects!
    (okay 2, but some big ones!) avchd multilayer 2 hours!!!! 
    So the poor hp laptop -dual core i2 4gb ram, has been begged to it knees! And simply cant handle it of course! and it have just trough time benn loaded with lots of crap, and is extremly noisy, heat, slow, anoying = unusable!
    SO hwat i need is...
        (-THE SHORTER) :
    A computer setup that will EASILY! could handle stuff like that  (avchd, multilayer, 2 hours project) -and simmilar. A total power machine! But Im tired of windows! And ugly cheap looking design! The times have changed and i change with them!
    NOW I WANT APPLE!! 
    But but but... Hwat should i get????
    1. Im NOT a billionare!
    2. I repeat: NOT a billionare!
    3. I also need portability for every day use beyond the hardcore creative editing and use
    AT LAST:
     i saw in front of me this genius plan... With a macbook pro, a tuned one, with as much of ram,cpu,gpu, and everything else as it can posibble have
    -the perfect combination of transportabillity, everydayuse and total power!
    When it gets combine with,
    A cinemadisplay
    A extra keyboard
    And a extra magic mouse
    And this power macbook pro, with screen, mouse, and keyboard i've found a really good offer at.
    MY ACTUAL QUESTION.... :
    Now it is yours turn to please! be creative! Please! Hwat does all you genius heads! think and say?
    WILL A super tuned MACBBOK PRO COMBINED WITH ACCESSORIES, AT ALL, BE ABLE TO REPLACE A STRONG MAC PRO, OR AT LEAST BE MORE THAN ENOUGH FOR REALLY HEAVY STUFF? And if yes, HOW strong actually (ram,cpu,gpu...) will it need to have to be "more than enough"?
    If no, what would all of  you then suggest that is perfect in relation to everything?
    PLEASE ANSWER!!

    Jonatan R. wrote:
    WILL A super tuned MACBBOK PRO COMBINED WITH ACCESSORIES, AT ALL, BE ABLE TO REPLACE A STRONG MAC PRO,
    No,
    the MacPro is the muscle machine and not constrained by power or cooling limitations like the MacBoo Pro is.
    OR AT LEAST BE MORE THAN ENOUGH FOR REALLY HEAVY STUFF?
    If you press the MacBook Pro like a desktop machine, it will blow fans like a hurricane but will do the job eventually.
    The longer you blow fans on a laptop, the sooner it clogs up with crippling dust and shortens the life of the machine.
    You'll need the top end 15" or better, not the 13" as it has no dedicated graphics, only CPU graphics.
    Preferably if you just now getting into video, you should be considering Avid on a Windows 7 tower, it's because Apple has been ignoring the MacPro for hardware updates to improve it and it seems like they don't want to carry it anymore. Also the last Final Cut Pro version had Hollywood up in arms as Apple removed a lot of required abilities to make it more "consumer friendly" which upset the Pro market who likes control.
    Apple is focusing on the consumer computing market and getting away from the "Pro" market which needs the heavier hardware to handle video needs. They stopped selling the X-RAID and the X-Server, so Apple really isn't a "computer" company any longer.
    Sure you can use a MacBook Pro and a external monitor for doing home movies and such occasionally, but if your into serious production you need to consdier other options now.
    There is nothing wrong in getting a MacBook Air and a Windows 7 professional video tower too.

  • Every time I update LR to a new version I seem to need a patch to make it work..... once again here I am SOS! I've just update LR to the 5.7 version and It wont let me start it: The application was unable to start correctly (0xc000007b).

    Every time I update LR to a new version I seem to need a patch to make it work..... once again here I am SOS! I've just update LR to the 5.7 version and It wont let me start it: The application was unable to start correctly (0xc000007b).

    Your system is missing a couple DLLs that LR needs, but the fix at Adobe is to copy them to the LR folder which gets replaced for each install, so you have to redo it after each LR install.  It would be worth documenting the process and saving the DLLs so you don’t have to ask about it each time:
    http://helpx.adobe.com/lightroom/kb/error-unable-start-correctly-0xc00007b.html
    You might also use the AIO210 program to add them as detailed in this YouTube video—maybe this is a more permanent fix, but since the files are from media-fire be very careful about what you do so as not to install a virus on your computer. 
    I’d scan the downloaded ZIP you download with whatever virus and internet security software you have and don’t be fooled by extraneous popups you might see during the download process.  I was able to download the aio210.zip after authorizing one Captcha window and closed at least one bogus popup trying to get me to install other software.  I also scanned the downloaded zip with two virus scanners and both said it was clean.  Here is the YouTube video, where the link to the ZIP to download is in the description once you expand it:
    https://www.youtube.com/watch?v=vlT0N2CX50g

  • If I copy the "lcds" folder, Tomcat starts with socket errors

    In the documentation it is said that when you create a new server-side application, you can start by copying the 'webapps/lcds' folder. I did that but then, Tomcat starts with some socket errors:
    [LCDS]SocketServer 'my-rtmp-SocketServer' failed to pre-validate desired socket settings for BindSocketAddress: 0.0.0.0:2038
    java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
    [LCDS]SocketServer 'my-rtmp-SocketServer' failed to start.
    flex.messaging.LocalizedException: SocketServer 'my-rtmp-SocketServer' cannot bind to accept client connections on port '2038' because another process has already bound the port. Please ensure that multiple endpoints across all applications  are not configured to use this same port.
    Am I doing something wrong?
    Thanks,
    Borek

    What is happening is that you are getting a port conflict for the socket-based NIO and RTMP endpoints used in the channel definitions in the services-config.xml file of your new web app. The issue is that you have endpoints bound to the same port  in the LCDS web and in your new web app.
    You can deal with this one of two ways:
    Option 1: In that services-config.xml file, search on "RTMP" and "NIO" to find the channel definitions and change the port numbers to something slightly different than the ones used in the LCDS web app.
    Options 2: Move the LCDS web app out of the picture so it doesn't get loaded, and just use a template for future web apps. If you aren't using it for any of your development, there is really no reason you have to load it.
    I'll add a note about this to the documentation that talks about using the LCDS web app as a template.

  • I created new Apple ID and when I use a Game Center game that is associated with it. It tries to launch a game for someone else. Instead of letting me start a new game. And this other person still plays this game and does not want me playing their game.

    So the big question here is how on earth do i reset my profiles on Game Center so that I can play my own games. I tried the thing where you swipe and choose remove uninstalled the game no matter what it came back up with the other persons game, instead of letting me start my own game. I even made a new Apple ID and it did it too.

    Sounds like you are logged in with this persons ID still. Go to Settings>iCloud does this persons Apple ID appear here? If so select it and Sign-Out.  Remember to do the same when you've finished and tell them what you've done so they have no issues.
    Regards,
    Steve

  • Is there a way to make an audio clip not cover the whole project? I want to add audio clip or song and let it start at a certain point in the project. I'm working with iMovie on IPad!

    Is there a way to make an audio clip not cover the whole project in iMovie? I want to add audio clip or song and let it start at a certain point in the project. Whenever I add audio or song it covers the whole project. I'm working with iMovie on IPad!

    Thank you for your reply Karsten but unfortunately this didn't help me so far. Or maybe I'm missing something?
    First the link is a tutorial for iMovie on a Mac. I'm using iMovie on iPad so the steps are inapplicable.
    Second it is only possible for me to manipulate the end part of the sound clip to whichever duration I want. But I can't do the same with the 'beginning' of the sound clip.
    I simply want to place some photos in the beginning of my video with no sound in the background then after like 2 secs I want to start the music clip. For some reason that is not possible! Cause every time I drop the music clip unto my project timeline it automatically place it self along with the first frame in the project! And consequently the photos and music are forced to start together.
    Hope I'm making sense...

  • Cant get past the "lets get started" page!!!!!

    When I click on the "ipod" section in my itunes library, theres a page that says "Lets get started" and tells me to name my ipod and all that. the problem is that the right part of the page is cut off and i cant reach the options that i assume are there. Theres no bottom scroll; i cant reach it. Because of this, i cant add pictures, video, or change my settings. I have Windows 98. PLEASE HELP!

    yeah... the minimum system requirements for iPod nano are XP or Vista. If you can get your hands on such an OS, go for it, otherwise, um.... i'm sorry i can't help much more, i think you'll need to find a way to access a computer with XP or Vista. sorry i couldn't help you more!
    -MacDarling55

  • Stop all Message delivery until start-up class executes

              On fail-over, I need to be able to keep any messages from topics/queues from being
              sent to the destinations until a start-up class has been executed and initialized
              the application. The problem is that the mdb's get deployed prior to the start-up
              class and immediately receive messages. This causes problems since the mdb's
              rely on the start-up class executing prior to onMessage().
              Is there a way to disable message delivery on start-up, prior to the deployment
              of the mdb's? I have implemented a temporary solution of checking to see if the
              start-up class has been bootstrapped, and if no, do a thread sleep for a specified
              time period and repeat...
              

    I had the same issue. We wrote a startup class that spawns a new thread to
              make a JMX call to see if the server is up. Once the server is up, the
              thread would deploy the MDB using JMX.
              Adarsh
              Looks like you came up with a good workaround.
              "Josh Zook" <[email protected]> wrote in message
              news:3cbd9fff$[email protected]..
              >
              > On fail-over, I need to be able to keep any messages from topics/queues
              from being
              > sent to the destinations until a start-up class has been executed and
              initialized
              > the application. The problem is that the mdb's get deployed prior to the
              start-up
              > class and immediately receive messages. This causes problems since the
              mdb's
              > rely on the start-up class executing prior to onMessage().
              >
              > Is there a way to disable message delivery on start-up, prior to the
              deployment
              > of the mdb's? I have implemented a temporary solution of checking to see
              if the
              > start-up class has been bootstrapped, and if no, do a thread sleep for a
              specified
              > time period and repeat...
              

  • ClassNotFoundException while calling start-up class in EAR

    Hi,
    I have a seemingly strange problem while executing a start-up class in my deployed
    (exploded) EAR. As suggested in WebLogic docs, I'm using the weblogic-application.xml
    to configure my startup class:
    <weblogic-application>
    <listener>
    <listener-class>com.i2.srm.integration.utils.IntegServerStartupManager</listener-class>
    </listener>
    </weblogic-application>
    When the start-up class is executed, it configures a listener class for some JMS
    queues. But Weblogic JMS code cannot find the listener class, even though other
    classes in the same jar & package are resolved (please see stack trace below).
    Also, here is the dir structure of my application:
    <application EAR dir>
         /APP-INF
              /lib
                   messaging-sb-client.jar
                   sourcingInteg.jar
         /META-INF
              application.xml
              weblogic-application.xml
         /messaging
              /com/i2/srm/messaging/..
              /META-INF
         /test
              /com/i2/srm/integration/test/..
              /META-INF
    Both the listener class & the class 'not found' are in the same jar file: sourcingInteg.jar.
    Stack Trace :
    weblogic.jms.common.JMSException: Error create server session pool
         at weblogic.jms.backend.BackEnd.serverSessionPoolCreate(BackEnd.java:1733)
         at weblogic.jms.backend.BackEnd.invoke(BackEnd.java:2863)
         at weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.java:609)
         at weblogic.jms.dispatcher.DispatcherImpl.dispatchSync(DispatcherImpl.java:153)
         at weblogic.jms.frontend.FEConnection.serverSessionPoolCreate(FEConnection.java:906)
         at weblogic.jms.frontend.FEConnection.invoke(FEConnection.java:1629)
         at weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.java:609)
         at weblogic.jms.dispatcher.DispatcherImpl.dispatchSync(DispatcherImpl.java:153)
         at weblogic.jms.backend.BEServerSessionPoolFactory.createServerSessionPool(BEServerSessionPoolFactory.java:133)
         at weblogic.jms.backend.BEServerSessionPoolFactory.getServerSessionPool(BEServerSessionPoolFactory.java:72)
         at com.i2.srm.messaging.controllers.JmsHelper.setSessionPool(JmsHelper.java:97)
         at com.i2.srm.messaging.controllers.ListenerManager.registerListener(ListenerManager.java:179)
         at com.i2.srm.integration.messaging.SRMServerListenerManager.createQueues(SRMServerListenerManager.java:94)
         at com.i2.srm.integration.messaging.SRMServerListenerManager.init(SRMServerListenerManager.java:55)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.i2.srm.rfc.utils.RWBaseServerStartupManager.invokeInit(RWBaseServerStartupManager.java:54)
         at com.i2.srm.rfc.utils.RWBaseServerStartupManager.invokeAllStartups(RWBaseServerStartupManager.java:131)
         at com.i2.srm.integration.utils.IntegServerStartupManager.postStart(IntegServerStartupManager.java:26)
         at weblogic.j2ee.ListenerInvocationAction.run(ListenerInvocationAction.java:58)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)
         at weblogic.j2ee.J2EEApplicationContainer.notifySecureListener(J2EEApplicationContainer.java:4449)
         at weblogic.j2ee.J2EEApplicationContainer.notify(J2EEApplicationContainer.java:4426)
         at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2098)
         at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2052)
         at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2000)
         at weblogic.management.deploy.slave.SlaveDeployer$Application.setActivation(SlaveDeployer.java:3073)
         at weblogic.management.deploy.slave.SlaveDeployer.setActivationStateForAllApplications(SlaveDeployer.java:1647)
         at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.java:403)
         at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume(DeploymentManagerServerLifeCycleImpl.java:230)
         at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:131)
         at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:927)
         at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:354)
         at weblogic.Server.main(Server.java:32)
    Caused by: weblogic.jms.common.ConfigurationException: Listener class, com.i2.srm.integration.messaging.IntegMessageListener,
    not found
         at weblogic.jms.backend.BEServerSessionPool.setListener(BEServerSessionPool.java:283)
         at weblogic.jms.backend.BEServerSessionPool.initialize(BEServerSessionPool.java:220)
         at weblogic.jms.backend.BEServerSessionPool.<init>(BEServerSessionPool.java:130)
         at weblogic.jms.backend.BackEnd$4.run(BackEnd.java:1713)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:123)
         at weblogic.jms.backend.BackEnd.serverSessionPoolCreate(BackEnd.java:1709)
         ... 36 more
    Any clues are appreciated!
    Thanks in advance,
    - Gagan

    Avi, I was just waiting for the "servlet hack".
    I really prefer the application client way, much cleaner, no servlet container needed, and could be tested outside the container.
    --olaf                                                                                                                                                                                                                                                                                                                                                                                       

  • Order of starting startup classes

    I am using WLS 4.5. Is there a way to tell the server in which order to
    start the startup classes?
    I have tried putting them in certain order in the properties file, but that
    certainly does not
    do it. Any other tricks?

    per the WLS 4.5.1 documentation you can start the classes in a specific
    order by putting them in the same line in the properties file separated by
    commas.
    e.g.
    virtual class name= class A, class B, class C
    Read the part on start up classes in the doc on the WebLogic properties
    file.
    farnaz <[email protected]> wrote in message
    news:8i5nph$ifu$[email protected]..
    I am using WLS 4.5. Is there a way to tell the server in which order to
    start the startup classes?
    I have tried putting them in certain order in the properties file, butthat
    certainly does not
    do it. Any other tricks?

Maybe you are looking for

  • I want to save my movies and projects on an external drive

    Does anyone know how I can change the settings on imovie to save imported movies into an external disk? When you ase asked to select where to save the movies, it only gives me the option to save on my Mac HD and if you move the clips then you can't u

  • Illustrator and Photoshop CS2 have both suddenly "Quit Unexpectedly"

    I haven't upgraded because I've been comfortable using this version and didn't see any need to up grade. Until now. I called Adobe and was told that they won't support or gaurantee any of their product older than CS6. Any Ideas why they both suddenly

  • Verity search display results

    I have been able to get my collection indexed and get a resulting page from a search. The page displays the Title of the page and the link to the page. I would like it to display more like a Google results page; with a description. Can I pull the Met

  • BADI for Goods Issue against 541 movement type

    We want to check the stock of a subcontracting vendor for some materials, suppose a subcontracting vendor is having a material of 10 qtys. the system should throw an error message saying that the subcontracting vendor is already having the stock of 1

  • Trying to set up email account for sub account

    I have been trying to set up an email account for a sub account through verizon message center all day with no luck.  It won't let me past the first screen.  Any ideas?