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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Running the headfirst ejb 1st chapter

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am trying to run the HEadfirst ejb 1st chapter, but i was not, i tried the solutions already give in this site, pls tell me how to run teh examples.

I have my all java files here:
D:\j2ee\ejb\projects\advice\src\headfirst directory.
clssfiles are in D:\j2ee\ejb\projects\advice\classes dir.
and i deployed the app also successfully.
but i tried to run like

java -cp D:\work\examples\j2sdkee1.3.1\lib\j2ee.jar AdviceAppClient.jar AdviceClient
the following
Exception in thread "main" java.lang.NoClassDefFoundError: AdviceAppClient/jar

is coming.Pls help me to solve this problem.

My jdk is in C:\j2sdk1.4.2_01
and j2ee is

D:\work\examples\j2sdkee1.3.1.
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi vijay,

On windows you should separate your libraries specified in the classpath using semicolons (not space):



In your case the jvm believed that AdviceAppClient.jar is the full name of the class that needs to be loadded.
Regards

was led to believe that the class to run is AdviceAppClient.jar
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Well I m having a similar problem . The use of the semicolon didint solve the problem. now I get the error:
NoClassDefFoundErrror: AdviceClient
Urgent help will be appreciated.
Regards,
Saurabh
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi singhi,

This is a classpath issue. If the AdviceAppClient.jar is in the current folder, then you need to add the current folder to the classpath using a . (dot):


Otherwise you need to specify the full path in order for this library to be loaded.
Regards.
 
saurabh singhi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This is the situation:

C:\projects\advice> java -cp .;c:\Sun\AppServer\lib\j2ee.jar; AdviceAppClient.jar AdviceClient

Both AdviceAppClient.jar and AdviceClient.class &.java are in C:\projects\advice

Still that error: NoClassDefFoundError:AdviceClient is coming
Please help me out.
Regards.
 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am in a different kind of situation. I can compile and run. But it throws an error when I run it. The error I am getting follows:
C:\projects\advice>java AdviceClient
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at AdviceClient.go(AdviceClient.java:15)
at AdviceClient.main(AdviceClient.java:9)
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Singhi,


This is the situation:

C:\projects\advice> java -cp .;c:\Sun\AppServer\lib\j2ee.jar; AdviceAppClient.jar AdviceClient

Both AdviceAppClient.jar and AdviceClient.class &.java are in C:\projects\advice

Still that error: NoClassDefFoundError:AdviceClient is coming


I hope you don�t have a space between c:\Sun\AppServer\lib\j2ee.jar; and AdviceAppClient.jar. I guess not, otherwise you�ll get an error message about not being able to find the AdviceAppClient/jar class.
One piece of advice I can give you though. Open the AdviceAppClient.jar archive and look for the AdviceClient class inside. Probably this class has a package name as well and then this could be the root cause of your problem. You need to specify your class' full name on the command line.

Hi Pradeep,


I am in a different kind of situation. I can compile and run. But it throws an error when I run it. The error I am getting follows:
C:\projects\advice>java AdviceClient
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial


You need to initialize your environment, setting at least two properties: java.naming.factory.initial and java.naming.provider.url. These values differ from container to container and you should check your container's documentation in order to find out the appropriate values. For WebLogic, one can use these settings:

Next you can use several techniques for configuring your runtime environment. The simple one is to add these values to a file named jndi.properties and copy the file to a folder that is part of your classpath. By default the InitialContext will always load the values from jndi.properties if the file is found in the classpath. This should fix your problem.
Regards.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thank you. I am using Sun app server for this ejb.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Where should I put this code though?
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Pradeep,

Since you don�t specify the classpath when running the client, the jvm will use the system classpath. Run echo %CLASSPATH% and see your system classpath. If it contains the current folder (check for the . you can copy the jndi.properties to the current folder (C:\projects\advice). Otherwise you can copy the file to any folder specified in the system classpath.
Regards.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thank you.
But if I dont specify the classpath, I would set it before I execute the command. I get the same error even if I specify the classpath.

C:\projects\advice>java -cp .;C:\Sun\AppServer\lib\j2ee.jar;AdviceAppClient.jar AdviceClient
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at AdviceClient.go(AdviceClient.java:15)
at AdviceClient.main(AdviceClient.java:9)
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Valentin,
What did you say about copying jndi properties? I didn't understand that.
Thank you.
 
saurabh singhi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Still getting the same error:
I tried this: AdviceAppClient.jar didint open with javaw so I opened it with wordpad and didnt find AdviceClient anywhere.
Cant get it to work..

Actually I 'm trying to test run thos application for a project.
I have to run the project on AFS(Andrew File System). It require creating a domain and then starting the domain and then verifying that the server is running. I did the first two things but still I still cant get the server to get up and running !!!
Here is a snapshot of my domain running:

alizarin-43 ss532>: /usr/site/bin/asadmin start-domain --domaindir ~/domains 604Project
Starting Domain 604Project, please wait.
Log redirected to /afs/cad/u/s/s/ss532/domains/604Project/logs/server.log.
Domain 604Project is ready to receive client requests. Additional services are b
eing started in background.
alizarin-44 ss532>:
My instanceport is 13001 and adminport is 13000 : but when I log onto http://alizarin.njit.edu:13000 I get the error"Cannnot find server"
Can somebody please help me ...its very urgent.
Regards.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Pradeep,

Look at the javadoc for the InitialContext class. Let me know if you have any more questions.
Regards.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thank you verymuch Valentin for helping me always. I am confused somewhere. I looked at the API docs and still don't understand what the problem is.
I am posting my code here. "AdviceBean" is the JNDI name I specified in the deployment tool.


import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;

public class AdviceClient{
public static void main(String[] args) {
new AdviceClient().go();
}

public void go() {
try{
Context ic = new InitialContext();
Object o = ic.lookup("AdviceBean");

AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);
Advice advisor = home.create();
System.out.println( advisor.getAdvice() );

} catch (Exception ex) {
ex.printStackTrace();
}
}//go

}
[ November 29, 2005: Message edited by: PradeepPillai Pradeep ]
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Pradeep,

Ok then, let me try making things clear to you. All the time you create a new context, some properties are required. Couple of them are java.naming.factory.initial and java.naming.provider.url[/b]. The InitialContext will basically search for these properties within its environment in this order: it will look first if the properties are passed to its constructor. This could be easily achieved using code like this:

You might try changing your code and see it working. However my initial thought was that you cannot change your code and you have only the classes but no source files. In that case if the required properties are not passed programmatically to the InitialContext through its constructor, it will be searching the environment in order to find them (basically will make calls to the System.getProperty("java.naming.factory.initial")) If you want to set your environment you can use �D option when starting the jvm:

This should make your code working too. Finally if none of the above works, then the InitialContext will search the classpath for a file named jndi.properties. If the file is found the properties are loaded and everything should be just fine. Otherwise you�ll get the error message you�ve got.
I hope this will help.
Regards.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am using 2 servers
1. Sun App server (as recommented by HF) and
2. WebLogic.

That is why I post different requests for help in different ways. I can change the bean class, and interfaces(component and home) I developed for Sun App server (I use deploy tool for creating .jar and deploy).
But I can change only the .ejb file (AdviceBean.ejb) I created for WebLogic server. The other files created by the tool are read only.

I thank you for your advice. I will modify the code and let you know what happened. If that doesn't work I will execute the command with -D option as you instructed.
So if I change the code for the client it will look like:

import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;

public class AdviceClient{
public static void main(String[] args) {
new AdviceClient().go();
}

public void go() {
try{

Properties props=new Properties();props.setProperty(Context.INITIAL_CONTEXT_FACTORY," weblogic.jndi.WLInitialContextFactory");
props.setProperty(Context.PROVIDER_URL,"t3://localhost:7001");


Context ic = new InitialContext(props);
Object o = ic.lookup("AdviceBean");

AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);
Advice advisor = home.create();
System.out.println( advisor.getAdvice() );

} catch (Exception ex) {
ex.printStackTrace();
}
}//go

}

But I need this code basically for Sun App server. So I would have to change it to suit Sun App server.

I thank you again for your effort and time.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
After executing the command I got the following result. Only difference from last time is that this time the jar file name is adviceEJB.jar


C:\projectsWLW\advice\AdviceClient>java -D java.naming.factory.initial weblogic.jndi.WLInitialContextFactory -D java.naming.provider.url t3://localhost:7001 -cp .;c:\Sun\AppServer\lib\j2ee.jar; adviceEJB.jar AdviceClient
Exception in thread "main" java.lang.NoClassDefFoundError: java/naming/factory/initial
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Pradeep,

There is a typo there. Don't leave any space between -D and the property name:



Regards.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I have a whole bunch of things in my classpath now.

CLASSPATH=C:\bea\JDK141~1\lib\tools.jar;C:\bea\WEBLOG~1\server\lib\weblogic_sp.jar;C:\bea\WEBLOG~1\server\lib\weblogic.jar;C:\bea\WEBLOG~1\server\lib\ojdbc14.jar;C:\J2EE;C:\j2sdk1.4.2_07;.
;C:\Program Files\Altova\xmlspy\XMLSpyInterface.jar;C:\bea\weblogic81\ server\lib\weblogic.jar;C:\bea\weblogic81\server\lib\weblogic.jar;C:\bea\weblogic81\server\lib\weblogic.jar;C:\projectsWLW\Advice
ClientJava\adviceEJB.jar;C:\bea\JDK141~1\lib\tools.jar;C:\bea\WEBLOG~1\server\lib\weblogic_sp.jar;C:\bea\WEBLOG~1\server\lib\weblogic.jar;C:\bea\WEBLOG~1\server\lib\ojdbc14.jar
CommonProgramFiles=C:\Program Files\Common Files

I compile it as follows:

C:\projectsWLW\AdviceClientJava>javac AdviceClient.java

C:\projectsWLW\AdviceClientJava>

It worked, the class file is created.

Then I run it.

C:\projectsWLW\AdviceClientJava>java AdviceClient
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at AdviceClient.go(AdviceClient.java:23)
at AdviceClient.main(AdviceClient.java:10)

The I run it after including the options.

C:\projectsWLW\AdviceClientJava>java -Djava.naming.factory.initial weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url t3://localhost:7001 -cp .;adviceEJB.jar AdviceClient
Exception in thread "main" java.lang.NoSuchMethodError: main

I am missing something here.

I am posting the code of the client here

import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import java.util.Properties;
import javax.ejb.*;

public class AdviceClient{
public static void main(String[] args) {
new AdviceClient().go();
}

public void go() {
try{

//Properties props=new Properties();
//props.setProperty(Context.INITIAL_CONTEXT_FACTORY," weblogic.jndi.WLInitialContextFactory");
//props.setProperty(Context.PROVIDER_URL,"t3://localhost:7777");
//Context ctx=new IntitialContext(props);


Context ic = new InitialContext();
Object o = ic.lookup("ejb.AdviceLocalHome");

AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);
Advice advisor = home.create();
System.out.println( advisor.getAdvice() );

} catch (Exception ex) {
ex.printStackTrace();
}
}//go

}


Valentin I thank you so much for helping me out and I thank others who helped me.
It is frustrating to me and I know it is frusrating to all the people who are helping me.
But I am optimistic.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I think you are almost there. Just add = while specifying system properties.

 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I got the following result for the commend "java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7001 -cp .;adviceEJB.jar AdviceClient"

C:\projectsWLW\AdviceClientJava>java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7001 -cp .;adviceEJB.jar AdviceClient
javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory. Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:272)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at AdviceClient.go(AdviceClient.java:22)
at AdviceClient.main(AdviceClient.java:10)

C:\projectsWLW\AdviceClientJava>

I slightly changed it (I changed the url and got rid off -cp option). Then I got the following result.


C:\projectsWLW\AdviceClientJava>java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7778 AdviceClient
javax.naming.CommunicationException. Root exception is java.net.ConnectException: t3://localhost:7778: Destination unreachable; nested exception is:
java.io.IOException: Empty server reply; No available router to destination
at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:199)
at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:125)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:296)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:239)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:135)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at AdviceClient.go(AdviceClient.java:22)
at AdviceClient.main(AdviceClient.java:10)

C:\projectsWLW\AdviceClientJava>


Also after I changed it and executed the above command, in the "Start server" window (the window that opens up when the server starts)
I got the following line added.


<Nov 30, 2005 2:05:43 PM EST> <Warning> <Security> <BEA-090475> <Plaintext data
for protocol T3 was received from peer localhost - 127.0.0.1 instead of an SSL h
andshake.>

Does that mean anything?
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Pradeep,

It looks like you are one step closer. You need to make sure that your server instance is running and listening at the port number you�ve specified. One easy way is to open the config.xml file and search for ListenPort. Make sure it is 7778, otherwise change your url accordingly. Another even better way of checking the server availability is to PING the instance using the weblogic Admin tool. Open a command window and type:

You should expect a similar result:

Otherwise you�ll get an error message like this:

Regards.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
C:\projectsWLW\AdviceClientJava>java -classpath C:\bea\weblogic81\server\lib\weblogic.jar weblogic.Admin -username admin -password admin -url t3://localhost:7777 PING
Sending 1 ping of 100 bytes.

RTT = ~15 milliseconds, or ~15 milliseconds/packet


So the port is 7777.

Then I executed the command as before.

C:\projectsWLW\AdviceClientJava>java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7777 -cp .;adviceEJB.jar AdviceClient
javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory. Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:272)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at AdviceClient.go(AdviceClient.java:22)
at AdviceClient.main(AdviceClient.java:10)

C:\projectsWLW\AdviceClientJava>

Then I got rid off -cp option and gave it a try


C:\projectsWLW\AdviceClientJava>java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7777 AdviceCl
javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException: remaining name: /app/ejb/adviceEJB.jar#Advice/local-home
at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:39)
at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:57)
at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:62)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)
at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:96)
at weblogic.jndi.internal.ServerNamingNode.resolveObject(ServerNamingNode.java:265)
at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:732)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:196)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
at java.lang.Thread.startThreadFromVM(Unknown Source)

C:\projectsWLW\AdviceClientJava>

No luck.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Pradeep,

Add the weblogic.jar to your classpath and everything should be fine:



Regards.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Weblogic.jar is already in CLASSPATH. Anyway I added that to the command


C:\projectsWLW\AdviceClientJava>java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7777 -cp C:\bea\weblogic81\server\lib\weblogic.jar;.;
adviceEJB.jar AdviceClient
javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException: remaining name: /app/ejb/adviceEJB.jar#Advice/local-home
at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:39)
at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:57)
at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:62)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)
at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:96)
at weblogic.jndi.internal.ServerNamingNode.resolveObject(ServerNamingNode.java:265)
at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:732)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:196)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
at java.lang.Thread.startThreadFromVM(Unknown Source)

C:\projectsWLW\AdviceClientJava>

No luck.

I am just posting my ejb-jar and weblogic-ejb-jar. I don't know if that is going to help. But just incase.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>


<!--
** This file was automatically generated by EJBGen 2.16
** Build: 20031001-1049
-->
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Advice</ejb-name>
<home>headfirst.AdviceHome</home>
<remote>headfirst.Advice</remote>
<local-home>headfirst.AdviceLocalHome</local-home>
<local>headfirst.AdviceLocal</local>
<ejb-class>headfirst.AdviceBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN" "http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd" >

<!--
** This file was automatically generated by EJBGen 2.16
** Build: 20031001-1049
-->
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Advice</ejb-name>
<stateless-session-descriptor>
</stateless-session-descriptor>
<jndi-name>ejb.AdviceRemoteHome</jndi-name>
<local-jndi-name>ejb.AdviceLocalHome</local-jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Pradeep,


Weblogic.jar is already in CLASSPATH. Anyway I added that to the command


C:\projectsWLW\AdviceClientJava>java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7777 -cp C:\bea\weblogic81\server\lib\weblogic.jar;.;
adviceEJB.jar AdviceClient
javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException: remaining name: /app/ejb/adviceEJB.jar#Advice/local-home


It actually makes a lot of difference though. You were able to build the initial context, but your client failed to lookup the bean. This is mostly because a wrong jndi name was used. As I�m looking at your client (if this is not the latest version you need to re-posted it) one thing chaught my attention:


Do the changes and recompile and re-run your client.
Regards.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
BINGO

C:\projectsWLW\AdviceClientJava>javac AdviceClient.java

C:\projectsWLW\AdviceClientJava>java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7777 -cp C:\bea\weblogic81\server\lib\weblogic.jar;.;
adviceEJB.jar AdviceClient
One Word: Inappropriate

C:\projectsWLW\AdviceClientJava>java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7777 -cp C:\bea\weblogic81\server\lib\weblogic.jar;.;
adviceEJB.jar AdviceClient
Your boss will respect him if you tell him the truth.


It worked at last. You don't know how happy I am.
Thank you so much to all of you who put so much effort to help me.
THANK YOU...THANK YOU!!
[ November 30, 2005: Message edited by: PradeepPillai Pradeep ]
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I was also able to do it programatically and get the following result


C:\projectsWLW\AdviceClientJava>javac AdviceClient.java

C:\projectsWLW\AdviceClientJava>java -cp C:\bea\weblogic81\server\lib\weblogic.jar;.;adviceEJB.jar AdviceClient
You might want to rethink that hair cut

C:\projectsWLW\AdviceClientJava>java -cp C:\bea\weblogic81\server\lib\weblogic.jar;.;adviceEJB.jar AdviceClient
Your boss will respect him if you tell him the truth.

C:\projectsWLW\AdviceClientJava>java -cp C:\bea\weblogic81\server\lib\weblogic.jar;.;adviceEJB.jar AdviceClient
You might want to rethink that hair cut
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Congratualations
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am very beginner both to java and j2ee.

Head firt created thick client (java application) to communicate with advice ejb.

I have tried out creating jsp useBean tag and creating a bean to communicate with ejb-bean and give the results to jsp.

I have also created servlet as client to ejb-bean.

Important thing to note is "don't forget to import the class you are using".
This is where i got frustrated a lot while trying to make my codes work.

all this i saw some servlet code and assumed what will i have to write for using advice ejb bean.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Sri,

Even i am a begginer like you were
can you send me your code and other helpful material at <XYZ>



[Edited by Jaikiran: Removed email id]
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Shashank,

Welcome to JavaRanch

We encourage people to discuss their issues in the forums instead of mails. As such i have removed the mail id from your reply. Please create a new topic if you have any specific questions.
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    Bookmark Topic Watch Topic
  • New Topic