Announcement Announcement Module
Collapse
No announcement yet.
Problem config spring and Junit Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem config spring and Junit

    i dont how to wotk Junit and spring o dp it before but its not working for my new project

    i use spring 2.5 core and test + junit4

    i use a service implementation
    Code:
    public class Service implements ServiceInterface{
    
    	public double carre(double n1) {
    		
    		return n1*n1;
    	}
    
    }
    and my test classe is
    Code:
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = { "classpath:META-INF/spring/spring.xml" })
    public class carreTest extends TestCase {
    
    	@Resource
    	private Service service;
    
    	@Test
    	public void testcarre() {
    		assertNotNull(service);
    		assertEquals(49., service.carre(7.0));
    
    	}
    }
    when i use maven test
    the error is
    Code:
    java.lang.NoClassDefFoundError: org/springframework/beans/BeanUtils
    	at org.springframework.test.context.TestContext.<init>(TestContext.java:109)
    	at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:103)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:120)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:80)
    	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:513)
    	at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
    	at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
    	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    	at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33)
    	at org.junit.internal.requests.SortingRequest.getRunner(SortingRequest.java:21)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.<init>(JUnit4TestMethodReference.java:25)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:54)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Caused by: java.lang.ClassNotFoundException: org.springframework.beans.BeanUtils
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    	... 24 more
    qomebody help me please

  • #2
    Well have you looked/read the stack trace?

    Code:
    Caused by: java.lang.ClassNotFoundException: org.springframework.beans.BeanUtils
    Judging from this exception you are either mixing spring versions or are missing the spring-beans.jar.

    Comment


    • #3
      yahoo
      i forget
      bean and context
      tx man you save my day ^^

      Comment

      Working...
      X