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

  • Home
  • SEARCH
  • 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 8456089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:27:26+00:00 2026-06-10T12:27:26+00:00

I defined an EJB and I’m trying to use it from another war: In

  • 0

I defined an EJB and I’m trying to use it from another war:

In ejb-api.jar:

@Remote
public interface Example {
    // ...
}

In ejb-impl.war (uses ejb-api.jar):

@Stateless(mappedName = "ExampleEjb")
public class ExampleBean implements Example {
    // ...
}

In ejb-user.war (uses ejb-api.jar):

@WebServlet("/ejbuser")
public class UserServlet extends HttpServlet {

    @Override
    public void doGet(...) throws Exception {
        Example example = null;
        try {
            InitialContext context = new InitialContext();
            example = (Example)context.lookup("ExampleEjb");
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }
}

I deployed ejb-impl.war and ejb-user.war to an instance of JBoss AS 7.1.
If I put all classes in the same war file, then the EJB is found. But this way, it’s not (I get a NamingException).

Furthermore, if I add a jndi.properties file with these contents…

java.naming.factory.initial = org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url = remote://localhost:4447
jboss.naming.client.ejb.context = true
java.naming.factory.url.pkgs = org.jboss.ejb.client.naming

… then I get this kind of warning:

16:55:46,268 WARNING [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-7) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.example.war:main" from Service Module Loader: javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.example.war:main" from Service Module Loader
    at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681) [rt.jar:1.7.0_03]
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) [rt.jar:1.7.0_03]
    at javax.naming.InitialContext.init(InitialContext.java:242) [rt.jar:1.7.0_03]
    at javax.naming.InitialContext.<init>(InitialContext.java:192) [rt.jar:1.7.0_03]
    at com.sun.faces.config.WebConfiguration.processJndiEntries(WebConfiguration.java:687) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.config.WebConfiguration.<init>(WebConfiguration.java:134) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.config.WebConfiguration.getInstance(WebConfiguration.java:194) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:163) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]

Do you know what I’m doing wrong?

  • 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-06-10T12:27:28+00:00Added an answer on June 10, 2026 at 12:27 pm

    According to @Stateless’ documentation, “Application servers are not required to support any particular form or type of mapped name, nor the ability to use mapped names.” Therefore, it’s not a good idea to use it to change the bean’s mapped name IMHO.

    Let’s try

    1. removing mappedName from @Stateless
    2. EDITED: using ExampleBean’s name in the java:global namespace:
      java:global[/application name]/module name/enterprise bean name[/interface name]

    Further reading about portable JNDI syntax

    EDITED:
    You’re deploying both of your modules to the same app server, aren’t you? Then, you don’t need a jndi.properties file, let’s try not using it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a very strange behavior using EJB beans: @Local public interface Provider {
I have a EJB defined as this: package com.foo; @Stateless (mappedName=HelloWorld) public class HelloWorldBean
I have an EAR file (JEE6) containing one ejb-jar (sample-ejb) file and one war
I have an EAR file containing multiple ejb-jar and war. In an ejb-jar, I
I've got a session bean, defined in an ejb-jar.xml and jboss.xml. It's defined with
I defined a custom component and tried to use binding as the following: <ui:composition
I defined the Scheme procedure to return another procedure with 2 parameters : (define
I defined a global variable that is called from other view and it is
I defined next class with virtual properties: public class Order: BaseEPharmObject { public Order()
I'm getting a java.lang.ClassNotFoundException: javax.ejb.EJBObject error when I'm running my application as a JAR

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.