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 :

 

    AutoTrader.ear

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

 

{code}

    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

    .0.5.RELEASE]

            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.

    0.war:3.0.5.RELEASE]

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

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

{code}

 

 

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

Any suggestions are welcome.

 

Thanks,

Adi

 

**UPDATE:**

 

I have added a ResourceScanner which extends NativeScanner:

{code}

   public class ResourceScanner extends NativeScanner {

 

        @Override

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

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

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

        }

 

        @Override

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

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

        }

 

        @Override

        public Set<Package> getPackagesInJar(final URL jarToScan,

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

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

        }

 

        @Override

        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) {

                    e.printStackTrace();

                    return url;

                }

 

            }

            return url;

        }

    }

 

{code}

and, in spring-persistence.xml,

{code}

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

{code}

 

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