Discussions

General J2EE: Java stand alone app to j2ee

  1. Java stand alone app to j2ee (2 messages)

    I am very new to J2ee. I want to migrate a Java stand-alone app to a j2ee app (if possible). The app currently read/writes to a DB and connects to a WebLogic app server to perform some processing. The app needs to be running when the app server is running and performs processing at regular intervals. My questions are, I have heard that if I use EJB then I cannot directly access DB resources, instead resource adapters should be used for this purpose. Is this something I should investigate when modifying my app, my initial investigation into resource adapters leads me to believe they are overly complicated for what I am trying to achieve? Secondly, how can I initially invoke my app via the app server if it is rewritten for the j2ee env (eg. deployed as an EAR)? Currently I use an app server start up class to invoke my stand alone java jar on server start via Process exec(). I am confused as to whether I am trying to convert something to j2ee which shouldn't be migrated to j2ee? My reason for considering the re-write is the interaction between the app and the WebLogic app server.

    Threaded Messages (2)

  2. Re: Java stand alone app to j2ee[ Go to top ]

    It is very much possible to interact with database from EJBs though standalone application can be converted to Java EE application without using EJBs. To do some task at regular intervals you can use Timers. To invoke some process during server startup (or application deployment) use 'ServletContextListener'. Thanks, Vinod http://blog.vinodsingh.com/
  3. Reply.[ Go to top ]

    Hi Vanessa 1. EJBs can interact with DB using Datasources, and that is not overtly complicated. Once a Datasource is defined in appserver, ur EJB just lookups Datasource using its JNDI name, gets connection from datasource, and executes queries.. 2. I am not sure if I fully understand your second question. Assuming that you deploy application as EAR and want it to start at server start up, I can think of following options.. a. Write a servlet in your application, which invokes the entry point of your processing in its "init" method. Define this servlet to start at server start up - there is a property in web.xml - loadOnStartUp which can be used for this. b. Some app servers support Start up EJB (like IBM websphere) ..u can use the same For processing at regular intervals, use J2EE Timer API or Timer EJBs Thanks Rajiv Patil