• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deploy or application start-up listener

 
Grega Krajnc
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which version of Java EE and which application server? Also what kind of application are you deploying (servlets, EJBs)?

 
Grega Krajnc
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic