Hi Lukasz,
Thanks for the reply. About my test logic (which I'm starting to
believe that it's wrong) is this:

I want to test my Hibernate DAO (let's call it UserDAO) which extends
GWT's RemoteService, so my project looks like this:

   - GWT
        - com.gwt.client
           - interface userDAO
           - interface userDAOAsync

       -  com.gwt.server
           - class userDAOImpl

And the actual DAO code is

public class UserDAOImpl extends RemoteServiceServlet implements
UserDAO {

        @Override
        public User getUserByNick(String nick) {
                Session session =
HibernateUtil.getSessionFactory().getCurrentSession();
                session.beginTransaction();
                User res =
(User)session.createCriteria(User.class).add(Restrictions.eq("nickname",
nick)).uniqueResult();
                session.getTransaction().commit();
                return res;
        }
}

That's the reason I need to go through the GWT Servlets to test my
DAO, because they are the same thing (which is why I think I made a
mistake somewhere).

Do you think there is a better way to do the same thing? Like, maybe I
should make a DAO in its own class in the server package and call it
via a new RPC class.

Thanks for the time.

On Oct 8, 12:41 pm, Lukasz <[email protected]> wrote:
> Can you post your actual test logic? I don't understand why do you
> need to go through the GWT servlets to do some unit testing of your
> DAO. It would be better to test the DAO logic separately.
>
> On 8 Okt., 04:33, VrmpX <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I'm currently using GWT 2.0.4 with Hibernate3, on Eclipse Helios, to
> > create a simple web application. So far, I'm able to reach the
> > database and do some RPC's to the server perfectly without any
> > problem.
>
> > The problem arises whenever I try to test out my server classes (the
> > data access objects) with a JUnit test case. I've added the JUnit.jar
> > (JUnit 3) and modified the "Run As..." properties to include the /src
> > and /test folders in the classpath. Whenever I call my class methods I
> > get the following exception:
>
> > Initial SessionFactory creation failed.java.lang.NoClassDefFoundError:
> > org/slf4j/impl/StaticLoggerBinder
> >         at
> > com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(Abstract 
> > RemoteServiceServlet.java:
> > 62)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> > ...
> > Caused by: java.lang.ExceptionInInitializerError
> >         at com.ingsoftw.chat.util.HibernateUtil.<clinit>(HibernateUtil.java:
> > 16)
> >         at
> > com.ingsoftw.chat.server.UserDAOImpl.getUserByNick(UserDAOImpl.java:
> > 15)
> > ...
> > Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/
> > StaticLoggerBinder
> >         at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223)
> >         at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120)
> >         at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:
> > 111)
> > ...
> > Caused by: java.lang.ClassNotFoundException:
> > org.slf4j.impl.StaticLoggerBinder
> >         at java.net.URLClassLoader$1.run(Unknown Source)
> >         at java.security.AccessController.doPrivileged(Native Method)
>
> > The HibernateUtil.java code is:
>
> > public class HibernateUtil {
>
> >   private static final SessionFactory sessionFactory;
>
> >   static {
> >     try {
> >       // Create the SessionFactory from hibernate.cfg.xml
> >       sessionFactory = new
> > Configuration().configure().buildSessionFactory();
> >     } catch (Throwable ex) {
> >       // Make sure you log the exception, as it might be swallowed
> >       System.err.println("Initial SessionFactory creation failed." +
> > ex);
> >       throw new ExceptionInInitializerError(ex);
> >     }
> >   }
>
> >   public static SessionFactory getSessionFactory() {
> >     return sessionFactory;
> >   }
>
> > }
>
> > From what I understand, the problem lies on the fact that I haven't
> > added the sl4j.jar to the test server. Is the any way to do that?
>
> > Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to