-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Hibernate demo adminapp testcase exception...
PostPosted: Wed Jan 21, 2004 2:24 pm 
Newbie

Joined: Wed Jan 21, 2004 2:18 pm
Posts: 4
Location: Melbourne.Australia
Dear all

i download the hibernate demo adminapp(ww2 + hibernate)
and when i run the test case of src code,i got exception
(the demo app works fine in my tomcat/resin)


here is the stack info.i pasted here.any one could help?so confused, TIA!

Code:
C:\JBuilder8\jdk1.4\bin\javaw.exe -classpath C:\IntelliJ-IDEA-3.0.2\lib\junit.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\WEB-INF\classes;C:\JBuilder8\jdk1.4\jre\lib\charsets.jar;C:\JBuilder8\jdk1.4\jre\lib\jaws.jar;C:\JBuilder8\jdk1.4\jre\lib\jce.jar;C:\JBuilder8\jdk1.4\jre\lib\jsse.jar;C:\JBuilder8\jdk1.4\jre\lib\rt.jar;C:\JBuilder8\jdk1.4\jre\lib\sunrsasign.jar;C:\JBuilder8\jdk1.4\jre\lib\ext\dnsns.jar;C:\JBuilder8\jdk1.4\jre\lib\ext\ldapsec.jar;C:\JBuilder8\jdk1.4\jre\lib\ext\localedata.jar;C:\JBuilder8\jdk1.4\jre\lib\ext\sunjce_provider.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\cglib2.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\commons-collections.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\commons-logging.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\dom4j.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\ehcache.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\hibernate2.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\java2html.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\jcs.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\jta.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\junit.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\mysql-connector-java-3.0.9-stable-bin.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\odmg.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\ognl-2.6.3.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\oscore-2.2.1.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\velocity-dep-1.3.1.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\webwork-2.0-beta.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\xwork-1.0-beta.jar;D:\ext-code\adminapp-0.9\adminapp-0.9\lib\commons-lang-1.0.1.jar;C:\IntelliJ-IDEA-3.0.2\lib\idea_rt.jar com.intellij.rt.execution.junit.ui.SwingTestRunner org.hibernate.admin.test.TestCase
java.lang.ExceptionInInitializerError
   at org.hibernate.admin.component.HibernateSessionFactory.init(HibernateSessionFactory.java:32)
   at org.hibernate.admin.test.TestCase.<clinit>(TestCase.java:22)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
   at junit.framework.TestSuite.createTest(TestSuite.java:131)
   at junit.framework.TestSuite.addTestMethod(TestSuite.java:114)
   at junit.framework.TestSuite.<init>(TestSuite.java:75)
   at com.intellij.rt.execution.junit.TestRunnerUtil.getTestImpl(TestRunnerUtil.java:111)
   at com.intellij.rt.execution.junit.ui.SwingTestRunner.getTest(SwingTestRunner.java:19)
   at junit.swingui.TestRunner.runSuite(TestRunner.java:591)
   at junit.swingui.TestRunner.start(TestRunner.java:708)
   at com.intellij.rt.execution.junit.ui.SwingTestRunner.main(SwingTestRunner.java:11)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log
   at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532)
   at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272)
   at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:246)
   at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395)
   at net.sf.hibernate.cfg.Configuration.<clinit>(Configuration.java:91)
   ... 14 more
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log
   at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:416)
   at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525)
   ... 18 more
Caused by: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log
   at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:412)
   ... 19 more



PS.I have commeted all code of LOGGING
THANKS AGAIN


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 2:28 pm 
Newbie

Joined: Wed Jan 21, 2004 2:18 pm
Posts: 4
Location: Melbourne.Australia
the TestCase.java

I think maybe i got mistake in my configuration?Code should be fine,its done by gavin. ;)


Quote:
Code:
//$Id: TestCase.java,v 1.2 2003/12/17 17:37:41 turin Exp $
package org.hibernate.admin.test;

import java.util.HashMap;

import org.hibernate.admin.action.*;
import org.hibernate.admin.component.*;
import org.hibernate.admin.model.*;

import com.opensymphony.xwork.ActionContext;
import net.sf.hibernate.HibernateException;

/**
* @author Gavin King
*/
public class TestCase extends junit.framework.TestCase {
   
   private HibernateSession hs;
   private static final HibernateSessionFactory hsf;
   static {
      hsf = new HibernateSessionFactory();
      hsf.init();
   }
   
   public void init(HibernateSessionAware action) throws HibernateException {
      hs = new HibernateSession();   
      hs.setHibernateSessionFactory(hsf);
      action.setHibernateSession(hs);
      if ( ActionContext.getContext().getSession()==null )
         ActionContext.getContext().setSession( new HashMap() );
   }
   
   public void dispose() throws Exception {
      hs.disposeSession();
   }
   
   public void testSearchUsers() throws Exception {
      SearchUsersAction su = new SearchUsersAction();
      init(su);
      //su.getUserExampleName().setFirstName("Foo");
      su.getUserExample().setEmail("foo%");
      su.getUserExampleName().setInitial( new Character('F') );
      su.setRoleName("A Role");
      su.setMaxUsers(5);
      su.execute();
      assertTrue( su.getUsers()!=null );
      dispose();
   }

   public void testCreateUser() throws Exception {
      CreateUserAction cu = new CreateUserAction();
      init(cu);
      User u = cu.getUser();
      u.setEmail("foo@bar.com");
      u.setHandle("foonew");
      u.setPassword("bar");
      u.getName().setFirstName("Foo");
      cu.execute();
      dispose();
   }
   
   public void testCreateRole() throws Exception {
      CreateRoleAction cr = new CreateRoleAction();
      init(cr);
      Role r = cr.getRole();
      r.setName("A Role");
      r.setDescription("A role for testing");
      cr.execute();
      dispose();
   }

   public void testListRoles() throws Exception {
      ListRolesAction lr = new ListRolesAction();
      init(lr);
      lr.execute();
      assertTrue( lr.getRoles()!=null );
      dispose();
   }

   public void testCreateUserRole() throws Exception {
      CreateUserAction cu = new CreateUserAction();
      init(cu);
      User u = cu.getUser();
      u.setEmail("foo@bar.com");
      u.setHandle("fooBar");
      u.setPassword("bar");
      u.getName().setFirstName("Foo");
      cu.execute();
      dispose();
      CreateRoleAction cr = new CreateRoleAction();
      init(cr);
      Role r = cr.getRole();
      r.setName("Another Role");
      r.setDescription("A role for testing");
      cr.execute();
      dispose();
   }

}
[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 24, 2004 12:48 pm 
Newbie

Joined: Wed Jan 21, 2004 2:18 pm
Posts: 4
Location: Melbourne.Australia
sorry everyone,i got answer in the hibernate website


http://www.hibernate.org/119.html#A3

Unit Testing
I get a ClassCastException (or another "weird" exceptioin) when I try to call Hibernate from inside JUnit.

Fix 1 (Gareth Cronin)

Anyone using log4j/commons and JUnit should change the junit/runner/excluded.properties file inside junit.jar to look like this (it will get rid of all annoying Jakarta issues):

excluded.0=sun.*
excluded.1=com.sun.*
excluded.2=org.omg.*
excluded.3=javax.*
excluded.4=sunw.*
excluded.5=java.*
excluded.6=org.xml.sax.*
excluded.7=org.w3c.dom.*
excluded.8=org.apache.log4j.*
excluded.9=org.apache.commons.*

Fix 2 (Eric Everman)

Another fix for this is to turn off class reloading in JUnit.


and btw,what diff about adminapp 0.9 and 0.92?any change log available?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.