Announcement Announcement Module
No announcement yet.
Cannot get Java Config to work properly Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot get Java Config to work properly

    I have taken and exisitng and working eclipse/spring 2.56/xml configed application and migrated it to STS/Spring 3.0/Java Config application. Through this I have lost my ability to get my Junit4 test runing due to unsatified DI.
    I have read the forums and all the blogs on this stuff - there is not that much out there.
    The project compiles fine and my logs show it is finding the components (through the component-scan) but the junit test runs fails. I have a few tests that do not require DI (utils) and they test fine as they always have. but all DI based objects fail the @Required validation. This includes such infrastructure based DI like DataSource bean not found.
    I am under no illusions that this is not a spring issue but some lack of or over configuration on my part. I have spent crazy amounts of time commenting things out, recreating the project in STS and copying source over and rebuilding confgurations - to no avail.

    Any suggestions? This is driving me to drink and I usually like to walk to my drinks

    The application config simply has Spring-annotations, tx annotation, LTW and component scan in it as well as a bean def for the main (and only) java config bean.
    I can't believe it but I am thinking about learning Netbeans just to try some other path - this is not a threat just a result of my lack of ability to get past this
    Thanks in advance for any support, Phill

  • #2
    Please attach some minimal setup that exhibits the failure, and we'll check it out. Creating a JIRA would probably be a better route at this point. Just paste the JIRA issue URL here, thanks.


    • #3
      Jira link to posted issue


      • #4
        Resolved, see comments inline.


        • #5
          still misconfigured

          I have made the changes you suggested (thank you for your time) and the same problem persists
          The important part of the context file now looks like this

          <context:spring-configured />
          <context:component-scan base-package="ca.BidSpec" />

          Removed javaconfig from maven file
          added OXM 3.0 to maven file dependencies section
          clean, build, run debug results in same error


          • #6
            Hm, okay. Post the new stuff in a zip that I can run 'mvn clean test' on, and reopen the bug.


            • #7
              Updated Jar file


              I had also read that I should remove any dependency on Junit in the forums. Doing that though means that I get compile errors for all test cases (Assert class not found). Changed the scope to be compile to no avail, errors persists
              Anyway here is the updated zip with the two files in it, any advice is greatly appreciated



              • #8

                Not to be difficult, but at this point, I'm not sure what the issue is. Can you provide me with a standalone, runnable via maven (or ant) project? Ideally, I'd like to unzip your project and run 'mvn clean test'. Without that, it's a little hard to assess your issue. Include a pom, or build.xml if you must use ant. Thanks. See how far you can pare down the issue. What if you take out all the JPA bits, for example? Make sure, whatever you do, to include information about all the jars that are on your classpath (this is why a Maven pom will be very useful).


                • #9
                  will try backing out changes

                  I understand the difficulty in assessing a problem pretty much blind. Not sure what to do as sending everything is prohibitive and paring down would take a awfully long time. I may try to see if passing it through ROO will identify anything. If not I will start the back up process of removing java config first then back up to spring 2.5.8.
                  Of course if that fails I may be back with more data and a need for help. In the meantime thank you for your help


                  • #10
                    Update - problem solved

                    The problem seemed to be my config.xml files were not being found. I had moved them from META-INF dir (both regular and test). Once I moved them back this error cleared up. Another showed up but that will be in a different thread.

                    Thanks for everyones help