In JBOSS, how do I lookup an EJB if jnp port and rmi port are changed to 3099 and 3098 respectively?

I changed the default ports from 1098, 1099 to 3098 and 3099 respectively as I plan to run multiple JBOSS instances through same JBOSS 4.03 PS1 server? How do I lookup and create the EJB Remote Home inetrface?
JoegalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mayank SAssociate Director - Product EngineeringCommented:
Not sure, maybe try the provider URL as "IIOP:3099///"
0
borislavmarkovCommented:
put in your initial context these properties:

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

change the port 1099 to your port.

Then proceed with normal lookup of EJB and don't forget to include jboss-client.jar in your application.
If you lookup your EJB from JSP page then things are different.
0
Mayank SAssociate Director - Product EngineeringCommented:
Put all these values in a properties-file so that you can tweak it whenever you want.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

JoegalAuthor Commented:
I was using the port  3099 as follows:

props.put(
                  Context.INITIAL_CONTEXT_FACTORY,
                  "org.jnp.interfaces.NamingContextFactory");
            props.put(
                  Context.URL_PKG_PREFIXES,
                  "org.jboss.naming:org.jnp.interfaces");
            props.put(Context.PROVIDER_URL, "jnp://localhost:3099");            
            Context ctx = new InitialContext(props);



------------------------------------------------------------------------------

The problem occurs at this.home.create() method

System.out.println("Alive");
instance = this.home.create();
System.out.println("Dead");

-------------------------------------------------------------------------------

The exception I encounter is :

java.rmi.ConnectException: Failed to communicate; nested exception is:
      java.io.EOFException
      at org.jboss.invocation.pooled.interfaces.PooledInvokerProxy.invoke(PooledInvokerProxy.java:351)
      at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:227)
      at org.jboss.invocation.MarshallingInvokerInterceptor.invoke(MarshallingInvokerInterceptor.java:37)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
      at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:169)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
      at $Proxy0.create(Unknown Source)
      at test.Testit.testGetNetype(Testit.java:74)
      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 junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.io.EOFException
      at java.io.DataInputStream.readInt(Unknown Source)
      at java.io.ObjectInputStream$BlockDataInputStream.readInt(Unknown Source)
      at java.io.ObjectInputStream.readInt(Unknown Source)
      at org.jboss.invocation.pooled.interfaces.PooledInvokerProxy.readExternal(PooledInvokerProxy.java:423)
      at java.io.ObjectInputStream.readExternalData(Unknown Source)
      at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      at java.io.ObjectInputStream.readObject0(Unknown Source)
      at java.io.ObjectInputStream.readObject(Unknown Source)
      at java.util.HashMap.readObject(Unknown Source)
      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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
      at java.io.ObjectInputStream.readSerialData(Unknown Source)
      at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      at java.io.ObjectInputStream.readObject0(Unknown Source)
      at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      at java.io.ObjectInputStream.readSerialData(Unknown Source)
      at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      at java.io.ObjectInputStream.readObject0(Unknown Source)
      at java.io.ObjectInputStream.readObject(Unknown Source)
      at org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:143)
      at java.io.ObjectInputStream.readExternalData(Unknown Source)
      at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      at java.io.ObjectInputStream.readObject0(Unknown Source)
      at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      at java.io.ObjectInputStream.readSerialData(Unknown Source)
      at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      at java.io.ObjectInputStream.readObject0(Unknown Source)
      at java.io.ObjectInputStream.readObject(Unknown Source)
      at org.jboss.invocation.pooled.interfaces.PooledInvokerProxy.invoke(PooledInvokerProxy.java:335)
      ... 23 more

0
borislavmarkovCommented:
Ok change provider to localhost:3099 without the jnp in front of it, then be sure to use  "PortableRemoteObject.narrow"

like this:

       Properties p = new Properties();
        p.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
        p.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
        p.put(InitialContext.PROVIDER_URL,"localhost:1099");
        InitialContext ctx = new InitialContext(p);

        MSSessionHome homeSession = (MSSessionHome) PortableRemoteObject.narrow(ctx.lookup(EJBNames.MS_SESS_EJB), MSSessionHome.class);
        MSSessionRemote remoteSession = homeSession.create("" + System.currentTimeMillis());

then tell me which Jboss do you use.
0
Mayank SAssociate Director - Product EngineeringCommented:
What if you try "jnp:3099///" ?
0
JoegalAuthor Commented:
The code does not have problem in getting the RemoteHome object. Its running into the problem at the "create" method.

System.out.println("Alive");
            instance = this.home.create();
            System.out.println("Dead");
0
Mayank SAssociate Director - Product EngineeringCommented:
Effectively that is where it should occur if it has to occur too, as long as EJBNames.MS_SESS_EJB, etc can be located in your config files.
0
JoegalAuthor Commented:
The same code works on my friend's PC. Does it have to do with my PC settings/properties?
0
Mayank SAssociate Director - Product EngineeringCommented:
What is the final code you used?
0
JoegalAuthor Commented:
/**
       * Get the initial naming context
       */
      protected Context getInitialContext() throws Exception {
            Hashtable props = new Hashtable();
            props.put(
                  Context.INITIAL_CONTEXT_FACTORY,
                  "org.jnp.interfaces.NamingContextFactory");
            props.put(
                  Context.URL_PKG_PREFIXES,
                  "org.jboss.naming:org.jnp.interfaces");
            props.put(Context.PROVIDER_URL, "jnp://localhost:3099");            
            Context ctx = new InitialContext(props);
            return ctx;
      }

Following is what I see in the server.log file:

2006-04-21 11:50:16,353 DEBUG [org.jboss.invocation.pooled.server.ServerThread] failed
java.io.EOFException
      at java.io.ObjectInputStream$BlockDataInputStream.readByte(Unknown Source)
      at java.io.ObjectInputStream.readByte(Unknown Source)
      at org.jboss.invocation.pooled.server.ServerThread.acknowledge(ServerThread.java:187)
      at org.jboss.invocation.pooled.server.ServerThread.dorun(ServerThread.java:267)
      at org.jboss.invocation.pooled.server.ServerThread.run(ServerThread.java:139)
2006-04-21 11:50:16,353 DEBUG [org.jboss.invocation.pooled.server.ServerThread] begin thread wait
0
Mayank SAssociate Director - Product EngineeringCommented:
That doesn't seem to be an exception with the bean look-up.
0
JoegalAuthor Commented:
The problem occurs at this.home.create() method

System.out.println("Alive");
instance = this.home.create();
System.out.println("Dead");

The following post talks about remote exception being thrown when the create method is called:

http://jboss.com/index.html?module=bb&op=viewtopic&p=3932926
0
JoegalAuthor Commented:
I found the solution after lot of debugging. My client does not have all the JBOSS client jars in its classpath. I was just including jbossall-client.jar. It is not sufficient. When I included all the client jars under jboss4.03\jboss-4.0.3SP1\client\, the problem went away.
0
JoegalAuthor Commented:
Dear moderator,

Please close the question since I figured out the problem.
0
Mayank SAssociate Director - Product EngineeringCommented:
>> The following post talks about remote exception being thrown when the create method is called:

Yeah, actually all exceptions thrown from the server will be RemoteExceptions.

>> My client does not have all the JBOSS client jars in its classpath.

Oh well, didn't think that the new URL had anything to do with class-path :) of course all JARs have to be included otherwise the JVM will not recognize the classes (for loading).

http://www.mindprod.com/jgloss/classpath.html
0
GranModCommented:
PAQed with points refunded (125)

GranMod
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.