1

I'm developing an application using GXT and Hibernate. Here is the code, this is an "EJB site" method:

Query query = em.createNamedQuery("PrinterSite.findByIdandSite");
query.setParameter("abc", printer);
query.setParameter("def", site);
List<PrinterSite> printerSite = query.getResultList();
List<Printer> stm = new ArrayList<Printer>();
for(PrinterSite ps: printerSite) {
  stm.add(ps.getPrinter());
}
return stm;

The List<Printer> stm object is correctly filled. The problem come when the object is returned to the "GWT site". I got this exception:

...
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:106)
    at org.hibernate.proxy.pojo.javassist.SerializableProxy.readResolve(SerializableProxy.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
...

I can't figure out what's going wrong with my code. Why I can't pass correctly the List to the application's "GWT site"? Why java.lang.NoClassDefFoundError? I use Maven and the jar is in the classpath. TIA.

Francesco

Francesco
  • 1,742
  • 5
  • 44
  • 78
  • You need slf4j-api.jar file on your classpath. Download it here: http://slf4j.org/download.html – Peter Štibraný Dec 05 '11 at 15:26
  • Hello Peter. I got slf4j-api-1.6.4.jar, slf4j-log4j12-1.6.4 and slf4j-jboss-logging-1.0.2.GA.jar. I can see them listed as MavenDependencies in Eclipse's Project Explorer. They should be in the classpath. Am I right? – Francesco Dec 05 '11 at 15:41
  • 2
    I'm not sure about the others (e.g. slf4j-log4j only if you use log4j), and also you probably need only one of slf4j-jboss or slf4j-log4j, but you will certainly need slf4j-api.jar. At least that is one that is missing according to your exception. – Peter Štibraný Dec 05 '11 at 16:23
  • @PeterŠtibraný, `NoClassDefFound` does not mean a class is missing in the classpath, in contrary - the class is found, but could not be defined properly (most likely that some class dependencies such as static classes defined as fields are missing). – Eliran Malka Mar 06 '13 at 10:23
  • @EliranMalka, thanks. You learn something new every day :-) [Here](http://stackoverflow.com/a/5756989/47190) is explanation saying that NoClassDefFound may be result of previous ClassNotFoundException. – Peter Štibraný Mar 06 '13 at 11:45
  • @PeterŠtibraný, thanks man, that's interesting as well. – Eliran Malka Mar 06 '13 at 14:54

0 Answers0