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 ?
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.
Customer surveys are for companies who didn't pay proper attention to begin with.
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.
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.
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.
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.