• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
}
}
}
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daphne
You can try my start level guide ,which can be downloaded here.
 
Ranch Hand
Posts: 1072
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't find the org/jboss/logging/Logger while trying to initialize the context. Is jboss-
j2ee.jar on your classpath?
 
Daphne Dojo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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. :-)
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic