0 Replies Latest reply: Apr 25, 2012 8:35 AM by jazb RSS

    JBoss 5.1: Entity classes not found (vfszip)

    jazb Newbie

      I am using JBoss 5.1 with Hibernate 3.6, **JPA 2.0** and Spring 3.0.5.

      I use maven to build the EAR file which looks like :



          -------> META-INF

          --------------> application.xml

          --------------> jboss-app.xml

          --------------> MANIFEST.MF

          -------> AutoTrader.war



      if I deploy this ear file in JBoss 5.1, i get the error



          org.springframework.dao.InvalidDataAccessApiUsageException: Not an entity: class uk.co.aol.shipmanager.domain.Manager; nested exception is ja

          va.lang.IllegalArgumentException: Not an entity: class uk.co.aol.shipmanager.domain.Subscription

                  at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:286) ~[at_war-1.0.war:3


                  at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:104) ~[at_war-1.0.war:3.0.5.RELEASE


                  at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:368) ~[at_war-1.


                  at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58

          ) ~[at_war-1.0.war:3.0.5.RELEASE]




      However, if I deploy the war file exploded, it works fine.

      Any suggestions are welcome.







      I have added a ResourceScanner which extends NativeScanner:


         public class ResourceScanner extends NativeScanner {



              public Set<Class<?>> getClassesInJar(final URL jarToScan,

                      final Set<Class<? extends Annotation>> annotationsToLookFor) {

                  return super.getClassesInJar(patchUrl(jarToScan), annotationsToLookFor);




              public Set<NamedInputStream> getFilesInJar(final URL jarToScan, final Set<String> filePatterns) {

                  return super.getFilesInJar(patchUrl(jarToScan), filePatterns);




              public Set<Package> getPackagesInJar(final URL jarToScan,

                      final Set<Class<? extends Annotation>> annotationsToLookFor) {

                  return super.getPackagesInJar(patchUrl(jarToScan), annotationsToLookFor);




              public String getUnqualifiedJarName(final URL jarToScan) {

                  return super.getUnqualifiedJarName(patchUrl(jarToScan));




               * Patch the VFS URL to a FILE protocol URL.


               * @param url

               *            original URL.

               * @return either the original, either the corresponding FILE protocol of given VFS URL.


              protected URL patchUrl(final URL url) {

                  String protocol = url.getProtocol();


                  if (protocol.equals("vfs")) {

                      try {

                          File file = new File(url.getFile());

                          return file.toURI().toURL();

                      } catch (final MalformedURLException e) {

                          return url;

                      } catch (IOException e) {


                          return url;




                  return url;





      and, in spring-persistence.xml,


          <property name="hibernate.ejb.resource_scanner" value="uk.co.aol.shipmanager.ResourceScanner"/>



      This again works in the exploded war file.



      **But in case of a *EAR* file, the protocol is *vfszip* not *vfs*.**


      Please tell what to do???