File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes write jboss service to perform a task at startup. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "write jboss service to perform a task at startup." Watch "write jboss service to perform a task at startup." New topic

write jboss service to perform a task at startup.

sapna rana

Joined: Sep 01, 2008
Posts: 18

In my web application i have a option to upload images and the images are saved at two location one under the tmp folder in jboss(C:\jboss\server\default\tmp\deploy) and another under a folder (C:\jboss\vin_procure\images).
Now when we start jboss , tmp folder get overwrites and images are lost . So i need to write a jboss service in order to copy all the images under folder (C:\jboss\vin_procure\images) to the tmp folder in jboss.

Please suggest how can be write a jboss service or modify at

Thanks and Regards,
S Setty

Joined: Sep 08, 2008
Posts: 16
I think simple way is to write a Servlet to do this copy and set it to start on startup.
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

You can also create a Jboss SAR (Service Archive) which basically consists of a jboss-service.xml file (which states what services to start) and the EJBs/Pojos/whatever that do the actual work.

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Peter Johnson

Joined: May 14, 2008
Posts: 5852

There are other options.

First option: you could set up an external directory so that the images are accessed directly.

Second option: you could deploy your war as an exploded directory. The images would then not be copied to the tmp directory, and also not be removed on restart.

Both of these would be better options than copying files on startup.

JBoss In Action
I agree. Here's the link:
subject: write jboss service to perform a task at startup.
It's not a secret anymore!