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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:12:31+00:00 2026-06-16T00:12:31+00:00

I have eclipse juno and jboss AS 7.1 final running on my machine and

  • 0

I have eclipse juno and jboss AS 7.1 final running on my machine and configured it through it (eclipse juno). I hava a simple stateless bean and its interface (in fact is exactly the same example from the book Enterprise Java Beans 3.1 6th Edition). Here is the code:


package beans;

public class CalculatorBeanBase implements CalculatorCommonBusiness{

    public int add(int[] opers){

        int sum = 0;
        for(int c:opers){
            sum+=c;
        }
        return sum;
    }

}

package beans;

public interface CalculatorCommonBusiness {

    public int add(int[] opers);

}

package beans;

public interface CalculatorRemoteBusiness extends CalculatorCommonBusiness {}

package beans;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;

@Stateless
@LocalBean
public class SimpleCalculatorBean extends CalculatorBeanBase {}

I am trying to do the following JUnit testing, unfortunately the example mentions something like “using a standard jndi.properties file that we assume to be presente on the classpath” (here is my first problem, I have no idea what this means, I in fact did some research but I cant quite understand how it works, confuses me, and ultimately cant seem to make it work).

package beans;

import javax.naming.Context;
import javax.naming.InitialContext;
import junit.framework.TestCase;
import org.junit.BeforeClass;
import org.junit.Test;

public class CalculatorIntegrationTestCase {

    private static Context namingContext;
    private static SimpleCalculatorBean cal;
    private static final String JNDI_NAME_CALC = "java:global/jndi.properties/SimpleCalculatorBean";

    @BeforeClass
    public static void obtainProxyReferences() throws Throwable {
        namingContext = new InitialContext();
        cal = (SimpleCalculatorBean)namingContext.lookup(JNDI_NAME_CALC);
    }

    private void assertAdditionSucceeds(SimpleCalculatorBean cal){
        final int[] oper = {2,3,4};
        final int expectedSum = 9;
        final int actualSum = cal.add(oper);

        TestCase.assertEquals("Assert Failed!!. The actual value is not the expected",expectedSum, actualSum);
    }

    @Test
    public void testAdditionUsingBusinessReference() throws Throwable {
        this.assertAdditionSucceeds(cal);
    }
}

I need to know how that jndi. properties file works and how I have to set it up. (I read about this last issue, and I got the folloing .txt file and changed its extension to .jar, I dont know if that was right):

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jpn://localhost:1099 
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Finally I put that .jar file into the classpath (Don´t know if I did it right: rigth-click on project, build path, libraries, add external jars).

I did all the above stuff but I keep getting the following:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at beans.CalculatorIntegrationTestCase.obtainProxyReferences(CalculatorIntegrationTestCase.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Of course I published the Project (through eclipse though, project>run>run on server). Help would be appreciated

  • 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-16T00:12:31+00:00Added an answer on June 16, 2026 at 12:12 am

    AS7 has completely new implementation of remote ejb/jndi which means you cannot use jnp anymore stuff anymore.

    take a look at https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

    and https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project

    There you can find instructions how to do it now.

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

Sidebar

Related Questions

I have Eclipse Juno running on 64bit windows 7, I tried installing Aptana Studio
I have recently updated to eclipse juno. I have also updated mercurial to its
Have Eclipse Juno, maven 2.2.1, and m2eclipse running on a Red Hat Linux platform...
I have Eclipse Juno and m2e installed. It is configured to use external maven
I'm trying to add Apache server to Eclipse(Juno). I have installed Apache server 7.0,
I have Eclipse set up fairly nicely to run the G++ compiler through Cygwin.
I have Eclipse PDT version 1.3.0 PHP Version 5.3.8 Running on windows XP Pro
I currently have Eclipse Ganymede running on my system. I wanted to install Eclipse
I have to optimize performance of a team project (in eclipse Juno). To identify
I'm using Eclipse juno and osx 10.8 . I have java 7 with eclipse

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.