wood burning stoves*
The moose likes JBoss/WildFly and the fly likes What am i doing wrong.  I copied word for word ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "What am i doing wrong.  I copied word for word ..." Watch "What am i doing wrong.  I copied word for word ..." New topic
Author

What am i doing wrong. I copied word for word ...

Daphne Dojo
Greenhorn

Joined: Jan 20, 2003
Posts: 3
I am following the tutorial posted on fawcette by Budi Kurniawan. http://www.fawcette.com/javapro/2003_01/online/j2ee_bkurniawan_01_09_03/
All the program should do is turn the client input to uppercase - sheesh. Anyway, I followed the example step by step and yet I get this error when i run the program on jboss-3.0.4_tomcat-4.1.12:
///////////////////////////////////////////
java.lang.NoClassDefFoundError: org/jboss/logging/Logger
at org.jnp.interfaces.NamingContext.<clinit>(NamingContext.java:92)
at org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingContextFactory.java:42)
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:195)
at Client.main(Client.java:39)
Exception in thread "main"
/////////////////////////////////////////////
This is the client code:
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.util.Properties;
import com.javapro.ejb.StringProcessor;
import com.javapro.ejb.StringProcessorHome;
public class Client {
public static void main(String[] args) {
// first argument must be the input
if (args.length==0) {
System.out.println("Please specify the input to convert to upper case.");
return;
}
String input = args[0];
// preparing properties for constructing an InitialContext object
Properties properties = new Properties();
// properties = (Properties)properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
// properties = (Properties)properties.setProperty(Context.PROVIDER_URL, "localhost:1099");
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost:1099");


try {
// Get an initial context
InitialContext jndiContext = new InitialContext(properties);
System.out.println("Got context");
// Get a reference to the Bean
Object ref = jndiContext.lookup("StringProcessor");
System.out.println("Got reference");
// Get a reference from this to the Bean's Home interface
StringProcessorHome home = (StringProcessorHome)
PortableRemoteObject.narrow (ref, StringProcessorHome.class);
// Create an Adder object from the Home interface
StringProcessor sp = home.create();
System.out.println ("Uppercase of '" + input + "' is " +
sp.toUpperCase(input));
}
catch(Exception e) {
System.out.println(e.toString());
}
}
}
arun sahni
Ranch Hand

Joined: Jan 16, 2002
Posts: 91
Daphne
You can try my start level guide ,which can be downloaded here.


Arun Sahni<br />SCJP2,SWCD,<br />BEA Certified Specialist: Server <br />JCert Enterprise Developer for BEA.
ersin eser
Ranch Hand

Joined: Feb 22, 2001
Posts: 1072
Can't find the org/jboss/logging/Logger while trying to initialize the context. Is jboss-
j2ee.jar on your classpath?
Daphne Dojo
Greenhorn

Joined: Jan 20, 2003
Posts: 3
Thanks for responding.
Arun. I will check out your tutorial.
Ersin. Yes, i have the jboss-j2ee.jar in my ide's classpath. Do I need to configure anything else with JBoss?
Daphne Dojo
Greenhorn

Joined: Jan 20, 2003
Posts: 3
I got it!!!
I added a few more jars to the classpath and it works.
jboss-common.jar
log4j.jar
jboss-client.jar
jbossall-client.jar
Thanks everyone for your help.
Marty Speck
Greenhorn

Joined: Jan 21, 2003
Posts: 4
Here's a post from another forum that may help. (I wrote the original post so I'm reprinting here)
NoClassDefFoundError
An interesting problem I solved just now.
I am just starting using EJB's and created a Sequence bean for my application. Originally this was in my application package within the .war the I learned I should move it to the \server\default\deploy directory in it's own package. Within that package was an exception class that extended an ApplicationException class I had written in the application package.
On deploy this would produce the afore mentioned error. I decided to add the Application.jar file to the classpath. The bean deployed fine however suddenly I was getting the same error on HTTPServlet.
After much hairpulling and searching I found the statement on a post "...the classes within a .war file are not accessable from outside the .war file." I changed the exception class to inherit from java.lang.Exception and removed my classpath modifications and presto that problem went away.
What I found interesting about this is that adding the Application.jar file to the classpath caused the rest of the packages to be inaccessable.
Re: NoClassDefFoundError
Posted: Jan 16, 2003 8:07 PM
Classloaders are hierarchical.
Wars
UnifiedClassLoaders
BootClassLoader
Classpath
You can only look above, if you are loading classes
dynamically using the thread's application classloader.
Thread.currentThread().getContextClassLoader().loadClass()

This will fail.
import InTheWar;
public class InTheClassPath
{
}
so will
import InTheWar;
public class InAnEJB // UnifiedClassLoader
{
}
The only things in jboss's classpath are run.jar
and the jre, so you won't be able to import
very much. :-)
Tiffany Sun
Greenhorn

Joined: Oct 02, 2001
Posts: 26
I got the same "Can't find the org/jboss/logging/Logger" error, but after I added all the jar files that Daphne mentioned to classpath, I still got the same error,is there anything else I missed? please help me out!


SCJP, SCWCD, IBM-XML
Andrew Richards
Greenhorn

Joined: Nov 28, 2002
Posts: 12
I,m glad you solved your problem. I have not had any luck so far...
I had a go at a simple HelloWorld tutorial. I got the bean deployed in JBoss-3.0.4 fine but I've been having problems with the application client.
It compiles ok but I can't get it to run. Here is the error message:
Exception in thread "main"java.lang.NoClassDefFoundError: HelloWorldClient (wrong name: com/mastertech/sample/HelloWorldClient)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
.....
The NoClassDefFoundError sugests there is something missing from the class path.
Here is my current class path:
C:\j2sdkee1.3.1\lib\j2ee.jar;
C:\jboss-3.0.4\client\log4j.jar;
C:\jboss-3.0.4\client\jboss-common-client.jar;
C:\jboss-3.0.4\client\jboss-system-client.jar;
C:\jboss-3.0.4\client\jnp-client.jar;
C:\jboss-3.0.4\client\jboss-client.jar;
C:\jboss-3.0.4\client\jbosssx-client.jar;
C:\jboss-3.0.4\client\jboss-j2ee.jar;
C:\jboss-3.0.4\client\jbossall-client.jar
C:\Andrew\BuildExamplesUsingAnt\HelloWorld\dist\lib\HelloWorld.jar
As you can see I have added a few extra jar files just in case, but to no avail.
Any ideas?
Andrew
Wayne Rousey
Greenhorn

Joined: Feb 09, 2003
Posts: 10
Andrew,
You might want to make sure the JNDI name in your jboss-web.xml matches up with the JNDI name you specified in your jboss.xml file for the EJB itself.
e.g. In the jboss-web.xml file you might have something like:
<ejb-ref>
<ejb-ref-name>ejb/webtest/HelloWorld</ejb-ref-name>
<jndi-name>ejb/test/HelloWorld</jndi-name>
</ejb-ref>

and in the jboss.xml file something like:
<session>
<ejb-name>test/HelloWorld</ejb-name>
<jndi-name>ejb/test/HelloWorld</jndi-name>
</session>
The first part of the error log looks more like an environment naming context problem. Hope this helps.
Wayne
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: What am i doing wrong. I copied word for word ...