aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes access one EAR from another EAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "access one EAR from another EAR" Watch "access one EAR from another EAR" New topic
Author

access one EAR from another EAR

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
Currently I have an "app1.ear" deployer to server. If I deploy another "app2.ear" to the same server. I want the code in app1.ear to access code in app2.ear, for example, from app1.ear code I want to call an action in app2.ear and display a jsp bundled in app2.ear. Is this doable ?

Do I have to bundle app2.ear together with app1.ear into a consolidated EAR ?

Thanks.
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Yes, it is possible.. you could use either Html form and [a href] tag in the case you would access WebApplication..
If you want to bundle it in one EAR, it depends on your decision,..
For easiness, i would choose bundle it in one EAR..

Please correct me if i'm wrong..
Thanks..

Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 645
How would using two separate EAR application affect security? For example, if you log-in to one EAR, will those credentials be passed to the other EAR? I think it won't, but I'm not sure and willing to be enlightened
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
I want to call an action in app2.ear and display a jsp bundled in app2.ear. Is this doable ?

Sounds like an awful design. It depends on what you mean by "call an action." It also sounds like the JSP page is in the wrong place. Either way, Session EJB are access via JNDI lookup. So you can certainly code communication between EJBs from multiple deployments, i.e. EAR.

What does "call an action mean"?
Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
Let me see if I can elaborate it bit more --- Currently I have an app1.ear web application. In one page I want to add a tab at the top, when user clicks this link, it should brings a new page search page underneath the existing tabs (including the new tab), then user can pick search criteria and hit submit, the result jsp page still appears under all the tabs. That's it. Talking about the tabs, currently there are a few there already, when user clicks a different tab it invokes some struts action and brings that page individually.

Now the question is -- for the module for the new tab, can I bundle it into a separate new EAR file ? i.e. in the current EAR I only add the tab link pointing /app2/search/. Is this feasible theoretically ? So, when user clicks the new tab link, it invokes the action class bundled in the new app2.ear. The new app2.ear also includes its ejb, jsf, etc.

The reason why I am asking this is the current app1.ear is developed by a remote team and they don't want us to add code to their part except adding tab and link.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Raj Ohadi wrote:The reason why I am asking this is the current app1.ear is developed by a remote team and they don't want us to add code to their part except adding tab and link.

This is a red flag. This is why we have jars - so we can share code with each other.

On your problem, you can make remote calls at the EJB layer. Or direct below the tab via a frame. I recommend you not compromise the design over a fear of sharing code. Which is what this sounds like.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Struts-based actions can be invoked by a simple link, i.e. HTTP-based URL.

So, if Web application #1 wants to have a link to call an action in Web application #2, then it can certainly do so via hyper-link.

This is not difficult. However, attempting to have two separate web applications share the same screens sounds like a big nightmare and a horrible design. It also indicates a poor software development process and will be hard to maintain.

Designs like this are most likely contributing to Java's negative reputation and helping .NET become more popular.


i.e. in the current EAR I only add the tab link pointing /app2/search/. Is this feasible theoretically ?


No, you cannot have the link point to a relative path of a different web application. Your link would have to point to a complete URL to invoke the action, e.g. http://43.12.32.12:897/app2/search
Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
Jeanne Boyarsky wrote:
Raj Ohadi wrote:The reason why I am asking this is the current app1.ear is developed by a remote team and they don't want us to add code to their part except adding tab and link.

This is a red flag. This is why we have jars - so we can share code with each other.

On your problem, you can make remote calls at the EJB layer. Or direct below the tab via a frame. I recommend you not compromise the design over a fear of sharing code. Which is what this sounds like.


So, are you suggesting I add ejb jar to the existing .ear and put the new jsp pages in the same existing .ear ?
Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
James Clarks wrote:Struts-based actions can be invoked by a simple link, i.e. HTTP-based URL.

So, if Web application #1 wants to have a link to call an action in Web application #2, then it can certainly do so via hyper-link.

This is not difficult. However, attempting to have two separate web applications share the same screens sounds like a big nightmare and a horrible design. It also indicates a poor software development process and will be hard to maintain.

Designs like this are most likely contributing to Java's negative reputation and helping .NET become more popular.


i.e. in the current EAR I only add the tab link pointing /app2/search/. Is this feasible theoretically ?


No, you cannot have the link point to a relative path of a different web application. Your link would have to point to a complete URL to invoke the action, e.g. http://43.12.32.12:897/app2/search



Thanks James. I want to check the feasibility first for knowledge purpose. so from application one if I use complete URL to make a call to invoke application 2 (a struts), can I let application 2 return a JSP page with submit buttom, then I add this JSP to application 1's JSP ? Is that possible ? Now, remember in the JSP it returns it also has a submit button. By clicking the submit button I can invoke application 2 again, and then add the returned JSP to application 1.. Is this doable ?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Raj Ohadi wrote:So, are you suggesting I add ejb jar to the existing .ear and put the new jsp pages in the same existing .ear ?

Yes.
Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
James Clarks wrote:Struts-based actions can be invoked by a simple link, i.e. HTTP-based URL.

So, if Web application #1 wants to have a link to call an action in Web application #2, then it can certainly do so via hyper-link.

This is not difficult. However, attempting to have two separate web applications share the same screens sounds like a big nightmare and a horrible design. It also indicates a poor software development process and will be hard to maintain.

Designs like this are most likely contributing to Java's negative reputation and helping .NET become more popular.


i.e. in the current EAR I only add the tab link pointing /app2/search/. Is this feasible theoretically ?


No, you cannot have the link point to a relative path of a different web application. Your link would have to point to a complete URL to invoke the action, e.g. http://43.12.32.12:897/app2/search


Thanks James. I want to check the feasibility first for knowledge purpose. so from application one if I use complete URL to make a call to invoke application 2 (a struts), can I let application 2 return a JSP page with submit buttom, then I add this JSP to application 1's JSP ? Is that possible ? Now, remember in the JSP it returns it also has a submit button. By clicking the submit button I can invoke application 2 again, and then add the returned JSP to application 1.. Is this doable ?

 
wood burning stoves
 
subject: access one EAR from another EAR