Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3318766
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:44:43+00:00 2026-05-17T22:44:43+00:00

I currently have a J2EE project containing an EJB and a WAR. Everything goes

  • 0

I currently have a J2EE project containing an EJB and a WAR. Everything goes fine while I have only one WAR and one EJB module bundled in the final EAR. I now need to develop an other WAR using the same EJB module.

So, I added the EJB module in the library of the new WAR. The problem is when I try to deploy the EAR bundled with the two WAR and the shared EJB, I get the following exception :

Caused by: java.lang.RuntimeException: Error while binding JNDI name com.alex.ejb.MyBeanRemote__3_x_Internal_RemoteBusinessHome__ for EJB : MyBean

As I remove the EJB from the library of the second WAR, everything work again.

Is there something I missed ?

Finally, the real question is “how to share an EJB within multiple web applications ?”

Thanks for help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:44:43+00:00Added an answer on May 17, 2026 at 10:44 pm

    The problem is when I try to deploy the EAR bundled with the two WAR and the shared EJB, I get the following exception (…)

    That’s because the beans get deployed twice, causing a naming collision. Actually, that’s just not how you should package your application when using an EAR packaging.

    Finally, the real question is “how to share an EJB within multiple web applications ?”

    Don’t put your EJB module(s) in the WEB-INF/lib folder of your Web modules, your EAR should have the following structure:

    myear.ear
    |-- META-INF
    |   |-- application.xml
    |   `-- sun-application.xml (optional)
    |-- myejbmodule1-ejb.jar
    |-- ...
    |-- myejbmoduleN-ejb.jar
    |-- mywebapp1-war.war
    `-- mywebapp2-war.war
    

    Resources

    • Java EE 6 Tutorial
      • Packaging Applications
    • EJB3 in Action
      • Packaging EJB 3 Applications
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have one project that currently contains multiple packages. These packages make up
We currently have one publisher and four subscribers using merge replication. Due to a
I currently have a project built with maven-archetype-webapp artifact. The default packaging for this
I have a J2EE project running on JBoss, with a maximum heap size of
I have a J2EE-based system which is running currently on Apache Tomcat. We are
We currently have a J2EE system implementing most of the OWASP top 10 security
I currently have the following script: http://jsfiddle.net/oshirowanen/mnXdv/ Which works fine, i.e. if a click
It has been a long while since I have really worked with J2EE so
I have an existing J2EE project which is very big and old. Therefore, my
I know the core java only and started to learning J2EE. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.