Results 1 to 4 of 4

Thread: context:component-scan of packages that belong inside a JAR

  1. #1
    Join Date
    Jan 2008
    Posts
    9

    Default context:component-scan of packages that belong inside a JAR

    Hi all,

    Iīm using Spring 2.5.6 and iīve a EAR that contains a WAR and several JARs, inside some JARs are packages that i want to do a component-scan, in this case @Entity annotation, but this donīt work.

    I know that if i put all the classes of my packages inside my persistence.xml (inside the WAR) the thing work, but this is stupid. The JARs are inside my classpath so why Spring donīt locate the components?

    The applicationContext.xml are inside my WAR with this configuration :
    <context:component-scan base-package="org.xml.model"/>

    Iīve searched many forums but none have the solution for this case. But this is obvious for JEE applications to have a EAR with libs inside.

    Any one have any idea to solve this?

    Cheers

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    @Entity isn't a component, so you can scan all you want...

    You really have to register them in your persistence.xml spring isn't going to help you out there.
    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

  3. #3
    Join Date
    Jan 2008
    Posts
    9

    Default

    Hi Martin,

    So how do you explain when the @Entity is inside the WAR (in classes), without register in the persistence.xml the Spring can detect the @Entity??

    The only difference that i want to do is placing the @Entities in a JAR in my EAR to be available to more than a WAR of my EAR.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    As I stated spring isn't detecting your entities as @Entity isn't a @Component (I suggest a read of the reference guide/javadoc). It might be that hibernate has some detection going on although I doubt that.

    SO as I stated the scanning pickup isn't and will not be done by spring...
    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

Posting Permissions

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