File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Deploy or application start-up listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Deploy or application start-up listener" Watch "Deploy or application start-up listener" New topic
Author

Deploy or application start-up listener

Grega Krajnc
Greenhorn

Joined: Nov 18, 2010
Posts: 4
Hello!

I hope, somebody from you, guys will be able to help me.
I would like to make a code, which would be executed on application deployment or startup. Is there any listener of Java EE server, which would make it possible?

The reason, why I need this feature is, that I would like to generate some classes during runtime, using javassist and use them during application running. Am I even on right dirrection to do something like this?

Thank you for your future response.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10046
    
163

Which version of Java EE and which application server? Also what kind of application are you deploying (servlets, EJBs)?


[My Blog] [JavaRanch Journal]
Grega Krajnc
Greenhorn

Joined: Nov 18, 2010
Posts: 4
Thank you for your reply.

I'm using Java EE 5. About app server I would like to be independent, because source, which I'm writing is primarily for framework, which we will use for different projects.
In the first place generated code, I would like to make will be for EJBs.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10046
    
163

In Java EE 5, there isn't a way to trigger a EJB on application deployment. There is a way for doing this in Java EE 6 with @Singleton @Startup beans.

For Java EE 5, the easiest way to get similar functionality is to package your application as a .ear with a .war module (web) and a EJB module. You can then have a ServletContextListener which will be triggered when the web application is deployed.

Also, search for "startup" (without the quotes) in this EJB forum and you will find some interesting discussions (on page 1 and 2) related to this.
Grega Krajnc
Greenhorn

Joined: Nov 18, 2010
Posts: 4
So, for features I would like to use, I have to switch to Java EE 6. But for now I will try to do workaround with .war module, as you suggested.

Thank you very much for this information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deploy or application start-up listener