Announcement Announcement Module
No announcement yet.
context:component-scan of packages that belong inside a JAR Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?


  • #2
    @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.


    • #3
      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
        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...