Results 1 to 5 of 5

Thread: Problem with JDeveloper and Spring Tests

  1. #1
    Join Date
    Dec 2009
    Posts
    20

    Default Problem with JDeveloper and Spring Tests

    I've searched high and low all over the Internet trying to find a solution to this problem. I found a few different solutions that worked for some people, but none of them have worked for me. I've installed the JUnit extension for JDeveloper 11.1, so that I can now run a test class as such. I verified that this functionality works without Spring. I have a very simple test class with Spring where I am simply trying to kick off an app context and inject an object:

    Code:
    @ContextConfiguration(locations = {"applicationContext-test.xml"})
    public class ConfidentialAccessTypeCodeEntityTest extends AbstractJUnit4SpringContextTests {
        
        @Autowired
        @Qualifier("basicDataSource")
        private DriverManagerDataSource ds;
        
        @Test
        public void junkTest() throws Exception {
            assertNotNull(ds.getConnection());
        }
        
    }
    When attempting to run this test class in JDeveloper, I get the following error:

    Code:
    java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.findAnnotationDeclaringClass(Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Class;
         org.springframework.test.context.TestContext.retrieveContextLocations(TestContext.java:144)
         org.springframework.test.context.TestContext.<init>(TestContext.java:110)
         org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:103)
         org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:120)
         org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:80)
         sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         org.junit.internal.requests.ClassRequest.buildRunner(ClassRequest.java:33)
         org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:28)
    I've tried several things, including messing around with my dependencies. I have a feeling it may be the way that JDeveloper is executing the test class, but I'm not sure. I'm using Spring 2.5.6 with JUnit 4.4 I'm at a complete loss as to what I should try next.

    Any ideas?

    Thanks

  2. #2
    Join Date
    Dec 2009
    Posts
    20

    Default

    Another little tidbit of information. It looks like JDeveloper uses the following class to invoke a test:

    oracle.jdevimpl.junit.runner.JUnitTestRunner

    Basically, when you right click on a test class in JDeveloper and click "run", it looks like it just invokes a javaw.exe, sets the classpath to all the jars listed as libraries in your project, and runs the TestRunner. I didn't include the entire list for the classpath because it exceeds the limit for a thread post.

    Code:
    C:\Oracle\Middleware\jdk160_18\bin\javaw.exe -client -classpath ...........C:\projects\branch\2.1.2\services\test-lib\testng.jar;C:\Oracle\Middleware\jdeveloper\jdev\extensions\oracle.jdeveloper.junit\junit4.5\junit-4.5.jar;C:\Oracle\Middleware\jdeveloper\jdev\extensions\oracle.jdeveloper.junit.jar;C:\Oracle\Middleware\jdeveloper\jdev\lib\junit4-rt.jar;C:\Oracle\Middleware\jdeveloper\jdev\lib\junit3-rt.jar 
    -Djavax.net.ssl.trustStore=C:\Oracle\Middleware\wlserver_10.3\server\lib\DemoTrust.jks oracle.jdevimpl.junit.runner.JUnitTestRunner -port 3012 -v4Tests test.junit.com.mycompany.domain.ConfidentialAccessTypeCodeEntityTest

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    Judging from the stack trace there are different spring versions at play...Also looking at the part you posted you seem to be using junit 4.5... At least your class path seems to be screwed...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4
    Join Date
    Dec 2009
    Posts
    20

    Default

    The more I use JDeveloper, the more I absolutely hate it. You can configure your dependencies in the project settings, but it doesn't appear to stick to them. Unfortunately, my company isn't using Maven right now; this is the kind of nightmare you can run into when you do your own dep. management. I am at a complete loss here. I've been trying JUnit3, JUnit4, tried the Oracle Spring dependencies, downloaded my own Spring jar dependencies and tried those....I dunno. I have a mavenized version of this services module that I converted to Maven and imported into Eclipse, and I have it running the tests no problem. Unfortunately, I have to get this working with JDeveloper, which is proving to be an extremely difficult task.

  5. #5
    Join Date
    May 2012
    Posts
    4

    Default

    Quote Originally Posted by jwglista View Post
    The more I use JDeveloper, the more I absolutely hate it. You can configure your dependencies in the project settings, but it doesn't appear to stick to them. Unfortunately, my company isn't using Maven right now; this is the kind of nightmare you can run into when you do your own dep. management. I am at a complete loss here. I've been trying JUnit3, JUnit4, tried the Oracle Spring dependencies, downloaded my own Spring jar dependencies and tried those....I dunno. I have a mavenized version of this services module that I converted to Maven and imported into Eclipse, and I have it running the tests no problem. Unfortunately, I have to get this working with JDeveloper, which is proving to be an extremely difficult task.
    Did you have any luck resolving this? I'm having a similar issue and would be interested to find out what you did to get around this error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •