473,498 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Client JNDI lookup (vs. JBoss), ClassNotFoundException

I'm running on Win2000 and JRE 1.4.1....

I've got a small client trying to do get an InitialContext() and talk
to the local JBoss server running on same machine (different VM of
course).

When I run the client using the -D parameters to specify the JNDI
properties, it works fine.

Example command line:
-----------------------------
java -cp C:\pathTo\jbossall-client.jar;C:\pathTo\app.jar
-Djava.naming.provider.url=jnp://localhost:1099
-Djava.naming.factory.initial=org.jnp.interfaces.Na mingContextFactory
my.app.ClientClass
-----------------------------

That works fine. When I use the same command line but remove the -D
JNDI properties, and specify these in a jndi.properties file (by
adding to CLASSPATH), I get a ClassNotFoundException.

Example command line:
-----------------------------
%JAVA_HOME%\bin\java -cp
C:\pathTo\jbossall-client.jar;C:\pathTo\app.jar;C:\pathTo
my.app.ClientClass
-----------------------------
(the jndi.properties file is in the C:\pathTo dir, and it IS getting
picked up - that is, ClassLoader.getSystemResources("jndi.properties")
picks it up fine).

NOTE THAT THE CLASSPATH IS THE SAME IN BOTH CASES. THE ONLY DIFFERENCE
is that one uses the -D properties and the other does not.

If I screw up the jndi.properties file so it can't be found, I get a
different error (the "please provide JNDI properties" standard error).
So I really think I have JNDI properties, just the JVM is having
ClassLoader issues.

Here's my stack trace for reference:
-----------------------------
Exception in thread "main" javax.naming.NoInitialContextException:
Cannot instantiate class: org.jnp.interfaces.NamingContextFactory .
Root exception is java.lang.ClassNotFoundException:
org/jnp/interfaces/NamingContextFactory
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass( Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(U nknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unkn own Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at com.g1440.hasp.util.jms.QueueClient.initComm(Queue Client.java:159)
at com.g1440.hasp.util.jms.QueueClient.init(QueueClie nt.java:70)
at com.g1440.hasp.util.jms.QueueClient.<init>(QueueCl ient.java:50)
-----------------------------

I've worked this for a while, and can find nothing useful at JBoss,
Sun or otherwise. Perhaps I'm doing something stupid.

I've tried a bunch of things like:
+ defining my classpath as a SYSTEM env var
+ using different JAR combinations of jbossall-client.jar,
jnp-client.jar, jboss-j2ee.jar, etc. etc.
+ putting the jbossall-client.jar into %JAVA_HOME%\jre\lib\ext
+ placing my jndi.properties next to my .class inside of my JAR, and
various other places (referenced via a CLASSPATH entry pointing to the
directory)
+ specifying ClassPath in my Manifest (desperation only - I'm not
running as java -jar...)
+ reading the contents of my jndi.properties myself and populating
the System.properties with this (before getting the InitialContext)

At this point it looks like a weird ClassLoader situation.

Anybody see this as well? Thanks -
Jul 17 '05 #1
1 25420
Kent wrote:
I'm running on Win2000 and JRE 1.4.1....

I've got a small client trying to do get an InitialContext() and talk
to the local JBoss server running on same machine (different VM of
course).

When I run the client using the -D parameters to specify the JNDI
properties, it works fine.

That works fine. When I use the same command line but remove the -D
JNDI properties, and specify these in a jndi.properties file (by
adding to CLASSPATH), I get a ClassNotFoundException.


Kent,

I'm not sure the problem is, but here's some things to try:

1. Pass the contents of your jndi.properties file to the
InitialContext(Hashtable) constructor and see if that works.
2. Try doing a Class.forName() on the offending class as the first thing
in your app. Try it under both scenarios. Print out the result of
getSystemClassLoader().getResource("class/name/here") under both
circumstances.
3. Verify that none of the other jar files in the classpath contain a
jndi.properties file.
4. Verify that a jndi.properties file does not exist in your JRE's
lib/ext directory (or anywhere in your JRE installation).
5. Try running the app from jar with java -jar. Put the jndi.properties
in the jar.

Be sure to let us know what the problem ultimately turned out to be.

HTH,
Ray

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2368
by: Unbreakable | last post by:
I am using the nusoap client and nusoap server without any problem. However, once I change the client to the excel, I am not sure how to call the nusoap server. Especially the nusoap server only...
0
8573
by: Steffen | last post by:
Hi! I'm trying to access a EntityBean from a servlet via the bean's local home interface. The EJB and the Servlet are together in one .ear file and I'm using JBoss 3.2.3. I think the...
1
6196
by: slurper | last post by:
i have problems understanding jndi. i'm this far: i deployed the sun application server and i'm working through the examples (Duke bookstore, ...). Sometimes i see code which does a lookup to a...
3
2686
by: Jacky Zhu | last post by:
Hi all, I am having a problem trying to consume a webservice that is developed on ..Net. I can access it without any problem using a .net client, but when I use a java client (based on Axis...
2
1574
by: Hi5 | last post by:
Hi, I am working on a project in access 2000, Whilst I already have a table called client and seems to be related with other tables ,I tried making TBL client as lookup too, I ended up having...
0
1781
by: nuhu jibrin | last post by:
Good day all, Please, i can't compile my ejb classes in JBoss-4.0.5.GA or JBoss-4.0.2 after proper installation (because i can log on to the server via http://localhost:8080/ after using ...
1
1018
by: sajithamol | last post by:
What’s the difference between JNDI lookup(), list(), listBindings(), and search()?
0
3258
by: sajithamol | last post by:
I am getting the following error when I am invoke my ejb from webservice method. BTW I am using EJB3.0, jboss-4.0.5, Myeclipse5.5 M2.Please let me know what might be the issue...
9
2642
dmjpro
by: dmjpro | last post by:
I thought that when the connection gets closed then all resources get closed . I also included the ResultSet and Statement ;) . But if the Statement closed then only ResultSet closed. But now i got...
0
7121
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.