• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JBoss Remote Lookup

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I would like to know about remote lookup in JBoss application server.

If its weblogic, we pass a Properties object to the initial context, with

the provider URL and context factory. In the same way what am I supposed to do it for JBoss.

This is how the code goes in weblogic:

Properties p=new Properties();
p.put(Context.PROVIDER_URL,"t3://127.0.0.1:7001/");
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
Context ctx=new InitialContext(p);

How to write the same in JBoss?

Thanks
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your question is about the context parameters for JBOSS then Check this......
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am not successful using the link which you have sent.

Says unable to find the context. Do I have to add any .jars in the classpath.

Could you please suggest.
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please post some code you used for others to see where the problem (if any in the code)
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my Code:

Properties p=new Properties();
p.put(Context.PROVIDER_URL,"127.0.0.1:8080");
p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming rg.jnp.interfaces");
Context ctx=new InitialContext(p);
Object obj=ctx.lookup("HelloBean");

Error:

Exception in thread "main" javax.naming.NoInitialContextException: Cannot instatiate class: org.jboss.naming rg.jnp.interfaces [Root exception is java.lang.ClassNotFoundException: org.jboss.naming rg.jnp.interfaces]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at mypack2.Client.main(Client.java:19)
Caused by: java.lang.ClassNotFoundException: org.jboss.naming rg.jnp.interface

at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)

To which .jar do I have to set the classpath.

thanks
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JBoss has a jbossall-client.jar (in the client directory of your server). It should be in there.
[ July 31, 2008: Message edited by: Paul Sturrock ]
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its there in the classpath paul.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That doesn't look right. Sure it shouldn't be org.jnp.interfaces.NamingContextFactory?
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Neither its working paul.
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you check the port for the JBOSS ?


I'm not sure 8080 is the right one.
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No its 8080. Am able to access the console.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jetendra Ivaturi:
Neither its working paul.



I've just successfully checked a lookup against JBoss 4.2.2 using the initial context factory I mention above. The only thing I added to my claspath to get it to work is jbossall-client.jar. A quick jar -tf jbossall-client.jar shows org.jnp.interfaces.NamingContextFactory is in there. I'd double check your classpath.
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
8080 is HTTP port. Try 3528 for the port number
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vijitha Kumara:
8080 is HTTP port. Try 3528 for the port number



If you run jboss and look at the jmx-console you will be able to find out for sure, but normally the provider URL and defauklt port is jnp://localhost:1099
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Same error even with 3528.

I have written all the classes required and the .xml files. compiled them.

And copied the folder into the deploy folder of EJB. Is the process correct.

Even its not getting deployed says an error while deploying.

That might be the reason am unable to lookup.
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ejb-jar.xml
------------

<?xml version="1.0"?>

<!DOCTYPE ejb-jar PUBLIC
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN'
'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>HelloBean</ejb-name>
<home>mypack2.HelloHome</home>
<remote>mypack2.Hello</remote>
<ejb-class>mypack2.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>


jboss-jar.xml
-------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>HelloBean</ejb-name>
<jndi-name>HelloBean</jndi-name>
</session>

</jboss>

Are they correct.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Even its not getting deployed says an error while deploying.


Well, its definately a problem. I'd fix the deployment issue before trying to look anything up.

But its not the cause of your lookup issue. That is a ClassNotFoundException, which means your classpath is wrong, or your initial context factory property contains an invalid value. Once you have fixed your deployment issue you will need to double check your classpath and the value you use for this property.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Are they correct.


What does the deployment error say?
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the deployement error:
Incompletely deployed packages:
org.jboss.deployment.DeploymentInfo@33eb170 { url=file:/C:/jboss-3.2.6/server/default/deploy/stateless.jar/ }
deployer: org.jboss.ejb.EJBDeployer@6295eb
status: null
state: FAILED
watch: file:/C:/jboss-3.2.6/server/default/deploy/stateless.jar/META-INF/ejb-jar.xml
lastDeployed: 1217499161571
lastModified: 1217488956532
mbeans:

15:42:42,461 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0-8080
15:42:42,555 INFO [ChannelSocket] JK2: ajp13 listening on /0.0.0.0:8009
15:42:42,555 INFO [JkMain] Jk running ID=0 time=0/31 config=null
15:42:42,555 INFO [Server] JBoss (MX MicroKernel) [3.2.6 (build: CVSTag=JBoss_3
_2_6 date=200410140106)] Started in 9s:921ms
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look back in the log. That is the message that a deployment has failed, somewhere else there will be a stacktrace or error message telling you why it failed.
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could not exactly get the error from logs.
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could deploy the application successfully.

Still getting the same error stating. Cann't instantiate the class, jnp.interfaces.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


jnp.interfaces


This not a valid class. Re-read my post above. And check your classpath.
[ July 31, 2008: Message edited by: Paul Sturrock ]
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I have in my classpath:

C:\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\bin>echo %classpath%
.;D:\Work2008\OTCEIH\build;.;C:\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\client;C:\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\lib;;C:\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\client\jbossall-client.jar

Here is the error:

Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jboss.naming rg.jnp.interfaces [Root exception is java.lang.ClassNotFoundException: org.jboss.naming rg.jnp.interfaces]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at mypack2.Client.main(Client.java:19)
Caused by: java.lang.ClassNotFoundException: org.jboss.naming rg.jnp.interfaces
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could resolve the previous error.

Now am getting the exception stating:

Exception in thread "main" javax.naming.NameNotFoundException: HelloBean not bound

Where HelloBean is the JNDI name. Where I might be wrong.
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul what you said was right, properties which I am passing were wrong.

Could resolve it.

Properties p=new Properties();
p.put(Context.PROVIDER_URL,"localhost:1099");
p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces");

Class path which I have set:

C:\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\client\jbossall-client.jar;C:\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\client\jnp-client.jar

Still do I have to add any other .jar files.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


C:\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\client\jbossall-client.jar;C:\jboss-4.2.3.GA-jdk6\jboss-4.2.3.GA\client\jnp-client.jar


I would be surprised if you needed both jbossall-client.jar and jnp-client.jar in your classpath. jbossall-client.jar should include everything you need.

In my test (see my earlier post) my classpath only included jbossall-client.jar.
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all you support Pual and Vijitha... I could do it.

Thanks. I am good at using weblogic. But JBoss is new to me so sturggled a lot.

But could get it atlast only with your support and cooperation.

Thanks for being patient.

Cheers.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are more than welcome. Glad you got it working.
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You.
 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic