Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Stuck with EE project and multi-Thread application need help!  RSS feed

 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm stuck!!! i have a EE project and its working fine it fills a form and saves it in to the db, i made a small drawing



and i have a regular java application with multi-threads in it (i made this way because JSF doesn't work to well with THREADS) , my questions are:

1. can i access the EJB's on my EE project from my regular application to access the database?
2. How can i tell to my JSF page that my regular application its actually running?

Sorry i'd been reading about it all over the place for 2 days now and i'm stuck, i'm still learning about EJB, any help would be appreciated, i read about JMS but i just getting to know it, any ideas? thanks!!
 
Kamal Wickramanayake
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. can i access the EJB's on my EE project from my regular application to access the database?


Oh yes. That's what EJBs are meant for. In your client code you perform JNDI lookup to access the Remote Interface of the EJB. Then you just call the methods.

2. How can i tell to my JSF page that my regular application its actually running?


If that is needed you might maintain a flag in the DB. Generally there's no need to do things like that. You might be having a special requirement.
 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yes. That's what EJBs are meant for. In your client code you perform JNDI lookup to access the Remote Interface of the EJB. Then you just call the methods.


Great!!! that's gonna save me a lot of work.

If that is needed you might maintain a flag in the DB. Generally there's no need to do things like that. You might be having a special requirement.


Yeah you gave me a good idea, im gonna set a flag with a dateTime in the DB to know if my application its running, so my App will report to the DB, and my JSF page would look it up. And start the Application with a call to the system from the manageBean, that if the App its not running.

its there a way to tell what Applications are running on my JVM from a java application? that would save me some work as well!

Thanks Kamal for the help!
 
Kamal Wickramanayake
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah you gave me a good idea, im gonna set a flag with a dateTime in the DB to know if my application its running, so my App will report to the DB, and my JSF page would look it up. And start the Application with a call to the system from the manageBean, that if the App its not running.


I doubt if you really should do it that way. I thought your regular app is to run probably in another machine. It seems you want it to start via your web application. May be you should just integrate it to the same web application by not using a system call. You should be able to easily do it with a new web application lifecycle listener (configured via web.xml). When the application server starts up, the listener gets notifications. You trigger the execution of your multiple threads from there. You can set a flag just on the Servlet context (setAttribute). Your JSF code will also be able to check if the flag is set or not (getAttribute).

This way, you don't need to depend on remote interface of the EJBs. You can access them (from your multi-threaded code) in the same way you are accessing them right now from JSF.
 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oka i read a little about ServletContextListener after your post, and its a great tool im gonna try it out, but im a little worried about the multithreads wont it give me any problems on my web application? cause i read somewhere that JSF doesnt work to well with multithreads, Thanks again for your replies!
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Monique wrote:cause i read somewhere that JSF doesnt work to well with multithreads

JSF is a web framework, so it had better work just fine in a multi-threaded scenario - otherwise, what's the point?
 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info ill try out
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!