• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running as one process

 
Greenhorn
Posts: 4
Hibernate Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Currently I have a Tomcat server with a servlet that when called communicates with a java application through RMI.
I need to embed the java application into Tomcat so that I can directly make calls from the servlet to objects without the need for RMI.
The Java application should be run once when Tomcat starts.
Can I do this and how ?
Many thanks
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Eli!

The standard JVM only supports a single Application running within its environment, and since Tomcat itself is an Application, that kind of rules out what you seem to want. If you just want application functions within Tomcat, however, that can be done, as long as you're careful where you put things and don't do things that interfere with Tomcat's own operation. Alternatively, you can also flip things inside out and have your application run an embedded Tomcat server.

RMI is about as efficient as it gets when you have two systems running in 2 separate address spaces (VMs). Keeping separate address spaces is a good way to reduce the coupling between major systems, so it's not something that should be discarded lightly.
 
Eli Hodos
Greenhorn
Posts: 4
Hibernate Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

Thank you for your comment.

While my application is working as two separate processes communicating with RMI it has some withdraws.
The main problem is that if Tomcat communicates with my app using RMI it opens its own session and as my app needs to distinguish among original sessions (user's ) it has a problem as all appear to come from the same user (tomcat).
I had successfully combined the two to run as one and I was debating how to communicate between them.
It seems that embedding tomcat inside my app will be a better approach then calling my app from tomcat, specially if i do it now from the servlet which doesn't seem as the right thing to do as it needs to be called once when tomcat starts.
Still all this is very confusing because my app relies now on communication through a dedicated port on which its listening to meaning a session is required so If the user communicates with the embedded tomcat on port 8080 I will still need to communicate from tomcat with my app at the dedicated port ... and I end at the same spot.

It will help if you could suggest a way to call my Start java class once from Tomcat at startup, not from the servlet.

Thanks,
Eli
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually when you do this kind of stuff where one RMI server has to discriminate among multiple clients, you include some sort of session ID token as one of the RMI parameters,
 
Eli Hodos
Greenhorn
Posts: 4
Hibernate Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Tim, currently I can distinguish among sessions using a parameter sent in the request but the system currently works at the session level and we wanted to avoid changing that by placing filters selecting information for each "real" session as it slows the system down.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I understood that. What I'd expect would be that for each requesting web user (HttpSession), you'd generate a corresponding RMI session ID and use that to manage that user's interactions with the RMI server. So that each user's interactions would be distinct from the other user interactions.
 
Eli Hodos
Greenhorn
Posts: 4
Hibernate Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat is an intermediate web server receiving information from a customer's site on port 8080 and sending it to my app which listens on a dedicated port.
My app sends a reply to Tomcat which replies to the customer's site.
Therefore the session I care for is the one connecting the customer web site with Tomcat but the session that my app sees is the session between Tomcat and the app on a dedicated port and the original session between the customer's web site and Tomcat is passed as a parameter.
I would like if possible that my app (maybe with an embedded tomcat server ?) could handle both 8080 and dedicated port calls centralized and pass data internally without creating a new session.
Port 8080 is just the default .. i can change that.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic