Nov 19th, 2010, 12:41 PM
context:component-scan of packages that belong inside a JAR
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 :
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?
Nov 20th, 2010, 03:06 AM
@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.
Nov 20th, 2010, 08:45 AM
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.
Nov 20th, 2010, 01:54 PM
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...