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 1101893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:06:03+00:00 2026-05-17T01:06:03+00:00

I am unable to get dependency injection to work for my remote service and

  • 0

I am unable to get dependency injection to work for my remote service and I cannot figure out why. I want an instance of RemoteService so I wrote.

@EJB(name="RemoteService")
private RemoteService service;

And the Bean itself is defined with mappedName=”RemoteService:

@Stateless(mappedName = "RemoteService")
public class RemoteServiceBean implements RemoteService

When I try to run this code I get an InjectionException:

EJB5070: Exception creating stateless session bean : [{0}]
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref RemoteService@jndi: service.remote.RemoteService@null@service.remote.RemoteService@Session@null into class service.OrderServiceBean
        at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
        at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
        at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
        at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:538)
        at com.sun.ejb.containers.StatelessSessionContainer.access$100(StatelessSessionContainer.java:111)
        at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:783)
        at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:199)
        at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:489)
        at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:1709)
        at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1238)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:195)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:83)
        at $Proxy766.size(Unknown Source)
        at 

I have no ejb config files but I shouldn’t need any, right? The remote service is running on the same glassfish instance as the service trying to reference it. Checking the JNDI browser in glassfish admin verifies that the EJB has been deployed with the correct jndi name and if I remove the @EJB annotation and do the lookup manually in the constructor it also works:

public OrderServiceBean()
  {
    try
    {
      final Properties properties = new Properties();
      properties.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
      properties.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
      properties.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
      properties.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
      properties.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

      final InitialContext initialContext = new InitialContext(properties);
      this.service = (RemoteService) initialContext.lookup("RemoteService");
    }

Ideas?

  • 1 1 Answer
  • 1 View
  • 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-17T01:06:04+00:00Added an answer on May 17, 2026 at 1:06 am

    I can’t believe I hadn’t tried it but it seems I hadn’t, I obviously hadn’t tried referencing the EJB through mappedName. So changing the reference to this makes it work:

    @EJB(mappedName="RemoteService")
    private RemoteService service;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm unable to get this jquery statement to work on page load but it
I am unable to get a Javascript callback to work with gmaps4_rails when the
I'm unable to get trace log file for WCF service on server. The file
I've been unable to get the wonderful Eclipse Colorer plugin to work with my
I am unable to get this to work: var proxyResponse = function(res) { return
I am unable to get any dependency from github using rebar. rebar.config file: {sub_dirs,
I get unable to open database file when executing rc = sqlite3_open(test.db, &db); ??
I am unable to get the correct title for this, please change the title
I am unable to get a highcharts plugin to render a chart in a
I'm unable to get the Central Maven repo index. I'm running Netbeans 7.0.1 and

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.