This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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

Daphne Dojo

Joined: Jan 20, 2003
Posts: 3
I am following the tutorial posted on fawcette by Budi Kurniawan.
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>(
at org.jnp.interfaces.NamingContextFactory.getInitialContext(
at javax.naming.spi.NamingManager.getInitialContext(
at javax.naming.InitialContext.getDefaultInitCtx(
at javax.naming.InitialContext.init(
at javax.naming.InitialContext.<init>(
at Client.main(
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.");
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 " +
catch(Exception e) {
arun sahni
Ranch Hand

Joined: Jan 16, 2002
Posts: 91
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

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

Joined: Jan 20, 2003
Posts: 3
I got it!!!
I added a few more jars to the classpath and it works.
Thanks everyone for your help.
Marty Speck

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)
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.
You can only look above, if you are loading classes
dynamically using the thread's application classloader.

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

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!

Andrew Richards

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(
The NoClassDefFoundError sugests there is something missing from the class path.
Here is my current class path:
As you can see I have added a few extra jar files just in case, but to no avail.
Any ideas?
Wayne Rousey

Joined: Feb 09, 2003
Posts: 10
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:

and in the jboss.xml file something like:
The first part of the error log looks more like an environment naming context problem. Hope this helps.
I agree. Here's the link:
subject: What am i doing wrong. I copied word for word ...
It's not a secret anymore!