• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1396
  • Last Modified:

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?
0
Joegal
Asked:
Joegal
  • 7
  • 7
  • 2
  • +1
1 Solution
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 7
  • 7
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now