• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Injection Problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,

I am have been working on a project and have converted it from Spring Services 1.5.6 to 2.0. I am using JAXB to generate types from NIEM Schemas. I am getting an error when I test. If I don't have any test classes it generates the WSDL with no problems and appears to work.

Has anyone seen this problem and what am I missing?

Here is the error message.



My confusion is from this in the error: org.companyname.jailroster.ws.NameSearchEndpoint.jailRosterImpl. Why does it nest it under my endpoint?
It should be org.companyname.jailroster.business.JailRosterImpl

To add another level of complication I have a statement in my POM.xml to force the NIEM schemas to generate classes in a specific location.



Any help or insight would be greatly appreciated.

Thank you,

Dave
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well its hard to tell to much from what you have posted other than you are autowiring the following dependency:



And apparently there is no spring bean of that type defined.

If you need more help you are going to have to show us more of your configuration and perhaps a portion of the code causing the exception.
 
David Ratliff
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are the code snippets....

applicationContext.xml



test-applicationContext.xml



NameSearchEnpoint Class



NameSearchEnpoint Test Class



Please let me know if I should post more.

Thank you,

Dave
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well a couple things in your application-xml having this:



can be reduced to just this:


All the rest are redundant as sub packages are scanned. But that is not your problem. Your problem is your test-applicationContext.xml loads your context for you test case as you have specified below:



This is good to have a separate context for tests but you forgot to define JailrosterImpl in your test context it should probably look something like below:
Note that you do not need to manually wire dependencies into your test class you do not even need to define DependencyInjectionTestExecutionListener anymore as it should be done by default. You can just autowire your dependencies in to your test classes. I also removed the depends-on this is already accounted for when you use the ref attribute. You would use depends-on for the more indirect cases like if you needed to trigger a static initializer in another class that the bean you are creating depends on etc. You can also take out the getter and setter for NameSearchEndpoint in your test class.

test-applicationContext.xml


Don't forget to make use of the below packages they are useful for testing your services.




Hope that helped good luck








 
David Ratliff
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Bill. That worked. Now on to another problem. Believe it or not, this was working with an older version of Spring. I have moved it to the latest version of Spring, Hibernate and Spring-ws.

The error I am getting (research appears that it might be a Spring/hibernate conflict, I have set my version information in the pom.xml)




Error:



Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class is the problem I believe.


applicationConfiguration.xml/test-applicationConfiguration.xml






SearchDAOImpl.java





Again, thank you everyone for the help and patience. I know it is probably a configuration issue but I am just not seeing it.

Dave
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes your SessionFactoryBean class you used in your configuration is for Hibernate 3 not 4. You would need to change that to the LocalSessionFactoryBean in springs Hibernate4 package.

Also HibernateTemplate is deprecated and removed I using with Hibernate4.

You actually should never use it unless you are using A really old version of Hibernate before Hibernate version 3.1

Since 3.1 HibernateTemplate gives you no benefits whatsoever and I will go further and say it harms your code instead of using core Hibernate code.

You should be injecting the sessionFactory into your Repository/dao classes and calling getCurrentSession() for contextual sessions, which HibernateTemplate doesn't have.

Mark
 
David Ratliff
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Mark. I have been reading about that. I am refactoring my code to use the session factory.

 
You don't like waffles? Well, do you like this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic