Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Simple Weblogic JNDI -- Problem

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
Hey,
I am stuck in a very simple example of JNDI, I have a simple Class file called "Timer". In this file, I have two methods to set the time and to get the time. I have another class file "TimerClient" which, first binds an object of Timer Class to the JNDI and then tries to retrieve the same from JNDI, and finally executing it's two method. The Whole source code is given below:
============= START TIMER.JAVA ================
import java.io.*;
import java.util.*;
public class Timer implements Serializable
{
public Date dateObj=null;
public void setCallTimer(Date dateObj)
{
this.dateObj = dateObj;
}
public Date getCallTimer()
{
return dateObj;
}
}

============= STOP TIMER.JAVA =================
========== START TIMERCLIENT.JAVA =============

import java.io.*;
import java.util.*;
import javax.naming.*;
public class TimerClient implements Serializable
{
public static void main(String args[])
{
Context ctx = null;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
try
{
ctx = new InitialContext(env);
ctx.rebind("Timer-JNDI", new TimerClient());
Timer RetrievedTimer = (Timer)ctx.lookup("Timer-JNDI");
RetrievedTimer.setCallTimer(new Date(System.currentTimeMillis()));
System.out.println("Time Retrieved from JNDI Tree is : "+RetrievedTimer.getCallTimer());
}
catch(Exception ex)
{
System.out.println("TK Exception Occured while Dealing with JNDI: "+ex);
ex.printStackTrace();
}
finally
{
if(ctx!=null)
{
try
{
ctx.close();
}
catch(Exception ex)
{
System.out.println("Exception While Closing Context: "+ex);
ex.printStackTrace();
}
}
}
}
}
========== STOP TIMERCLIENT.JAVA ==============
========== START EXCEPTION STACK ==============
C:\myapps\Timer>java TimerClient
TK Exception Occured while Dealing with JNDI: javax.naming.CommunicationExceptio
n [Root exception is java.rmi.UnmarshalException: error unmarshalling arguments;
nested exception is:
java.lang.ClassNotFoundException: TimerClient
Start server side stack trace:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: TimerClient
java.lang.ClassNotFoundException: TimerClient
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:11
0)
at weblogic.rjvm.MsgAbbrevInputStream.readClassDescriptor(MsgAbbrevInput
Stream.java:211)
at weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputSt
ream.readClassDescriptor(ChunkedObjectInputStream.java:290)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java
:906)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:107)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:115)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:265)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
End server side stack trace
; nested exception is:
java.lang.ClassNotFoundException: TimerClient
Start server side stack trace:
java.lang.ClassNotFoundException: TimerClient
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:11
0)
at weblogic.rjvm.MsgAbbrevInputStream.readClassDescriptor(MsgAbbrevInput
Stream.java:211)
at weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputSt
ream.readClassDescriptor(ChunkedObjectInputStream.java:290)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java
:906)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:107)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:115)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:265)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
End server side stack trace
]
javax.naming.CommunicationException. Root exception is java.rmi.UnmarshalExcept
ion: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: TimerClient
Start server side stack trace:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: TimerClient
java.lang.ClassNotFoundException: TimerClient
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:11
0)
at weblogic.rjvm.MsgAbbrevInputStream.readClassDescriptor(MsgAbbrevInput
Stream.java:211)
at weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputSt
ream.readClassDescriptor(ChunkedObjectInputStream.java:290)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java
:906)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:107)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:115)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:265)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
End server side stack trace
; nested exception is:
java.lang.ClassNotFoundException: TimerClient
Start server side stack trace:
java.lang.ClassNotFoundException: TimerClient
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:11
0)
at weblogic.rjvm.MsgAbbrevInputStream.readClassDescriptor(MsgAbbrevInput
Stream.java:211)
at weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputSt
ream.readClassDescriptor(ChunkedObjectInputStream.java:290)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java
:906)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:107)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:115)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:265)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
End server side stack trace
java.lang.ClassNotFoundException: TimerClient
Start server side stack trace:
java.lang.ClassNotFoundException: TimerClient
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:11
0)
at weblogic.rjvm.MsgAbbrevInputStream.readClassDescriptor(MsgAbbrevInput
Stream.java:211)
at weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputSt
ream.readClassDescriptor(ChunkedObjectInputStream.java:290)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java
:906)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:107)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:115)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:265)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
End server side stack trace
<<no stack trace available>>
C:\myapps\Timer>
========== STOP EXCEPTION STACK ==============
My Development Environment is:
OS: Windows 2000 Prof Ed
Bea Weblogic Server 6.1
JDK 1.3.1 (Built in Bea)

Can anobody help me with it?
Thanks in advance,
Tualha Khan
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The problem seems to be in setting up the CLASSPATH. Check your CLASSPATH. Also check whether your class is accessibale using javap option.

Regards,
Milind
 
Tualha Khan
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Milind,
The javap option on Timer gives me:
C:\myapps\Timer>javap Timer
Compiled from Timer.java
public class Timer extends java.lang.Object implements java.io.Serializable {
public java.util.Date dateObj;
public Timer();
public void setCallTimer(java.util.Date);
public java.util.Date getCallTimer();
}
And the same on TimerClient gives me:
C:\myapps\Timer>javap TimerClient
Compiled from TimerClient.java
public class TimerClient extends java.lang.Object implements java.io.Serializabl
e {
public TimerClient();
public static void main(java.lang.String[]);
}

What should my class include, apart from the current working directory where both the classes are present?

Thanks in advance,
Tualha Khan
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ClassNotFoundException
usually it is a classpath exception .. try to move move your .class file and run from where your jdk/javac is and see if you have the same problem
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tualha,
I think you are trying to bind the Timer class not the TimerClient.
If i am right, then you should change the following from:
ctx.rebind("Timer-JNDI", new TimerClient());
to:
ctx.rebind("Timer-JNDI", new Timer());
Or am i missing something?
SteveC
 
Tualha Khan
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Steve,
I think you are right, I will check & try it once again in the evening as soon as I reach my home. I just gave a carefull thought on what you wrote, is correct. Anyways, lets hope that things get working now...
Thanks & Bye,
Tualha Khan
reply
    Bookmark Topic Watch Topic
  • New Topic