5 Replies Latest reply on Jan 28, 2010 3:40 PM by marius.bogoevici

    ClassNotFound error for classes in spring archives lib directory

      Dear Community

       

      I have created a .spring archive with the following format:

       

      myarchive.spring

         META-INF

         myclasses/p1/p2/my.class

         lib

            mycommon.jar

       

       

      When I deploy the myarchive.spring in to the deploy it fails with ClassNotFound for classes that are located in the mycommon.jar.

      Is this a valid format for the spring deployment archive? (I use the jboss-packaging-maven-plugin to create it.) Or is there something else I need to configure to get it to load these classes?

       

      Thanks

      MIke

        • 1. Re: ClassNotFound error for classes in spring archives lib directory
          alesj

          Which AS are you using?

           

          .spring is treated as a plain .jar -- I think in both AS versions (I wrote both handlings, just forgot a bit about 4, on how I did it )

          (a) for 5+ it's handled by JarStructure

          (b) for 4 it's handled by SpringDeployer

          and as such doesn't understand lib/ as a classpath entry.

           

          On 5 the fix is easy, just use jboss-structure.xml.

          On 4 it will not be that easy, you will have to re-structure your deployment.

          • 2. Re: ClassNotFound error for classes in spring archives lib directory

            Thanks for the help Ales.

             

            I'm using AS 5.1.0.GA with the jboss-spring-3.2.deployer.

             

            So after I wrote this I thought that maybe I should package everything in an EAR but when I do that the mavnen-ear-plugin packager converts my .spring to .jar and then can't resolve the spring context.

             

            DEPLOYMENTS IN ERROR:
              Deployment "vfszip:/C:/Applications/jboss-5.1.0.GA/server/default/deploy/avm-ear.ear/" is in error due to the following reason(s): org.xml.sax.S
            AXParseException: The prefix "context" for element "context:annotation-config" is not bound.

             

            The maven-ear-plugin puts the my .spring archive in as a .jar.

            Does it need to be a .spring in the ear to deploy correctly or is it a configuration problem?

             

            Thanks,

            Mike

            • 3. Re: ClassNotFound error for classes in spring archives lib directory
              marius.bogoevici

              Mike,

               

              No, the ear file should be alright.

              What's the name of your Spring configuration file, where is it placed. Can you just attach it (after removing sensitive bits. etc). I would just like to look at the header.

               

              Thanks,

              Marius

              • 4. Re: ClassNotFound error for classes in spring archives lib directory

                Marius

                 

                After what you said I looked at the jboss-spring.xml that was in the deployed ear and it was wrong. I had to clear my Maven local repository before it would include the correct version. But anyway that is a Maven problem.

                 

                But now I get the following error at deployment.

                 

                DEPLOYMENTS IN ERROR:
                  Deployment "vfszip:/C:/Applications/jboss-5.1.0.GA/server/default/deploy/avm-ear.ear/" is in error due to the following reason(s): org.xml.sax.S
                AXParseException: cvc-complex-type.3.2.2: Attribute 'weaverclass' is not allowed to appear in element 'context:load-time-weaver'.

                 

                I have included the top my jboss-spring.xml file. I am actually not sure how to use the JBoss5LoadTimeWeaver so I'm not even sure if this is the correct way or situation to use it. Can you give any insight into how and when to use the JBoss5LoadTimeWeaver?

                 

                Thanks in advance,

                Mike

                 

                 

                <?xml version="1.0" encoding="UTF-8"?>
                <beans xmlns="http://www.springframework.org/schema/beans"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xmlns:aop="http://www.springframework.org/schema/aop"
                       xmlns:context="http://www.springframework.org/schema/context"
                       xmlns:tx="http://www.springframework.org/schema/tx"
                       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                                           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
                 
                   <!-- post-processors for all standard config annotations -->
                   <context:annotation-config />
                   <context:component-scan base-package="ngc.avm" />
                  
                   <tx:annotation-driven />
                   
                   <context:load-time-weaver weaverclass="org.jboss.instrument.classloading.JBoss5LoadTimeWeaver"/>
                  
                
                
                • 5. Re: ClassNotFound error for classes in spring archives lib directory
                  marius.bogoevici

                  Hey Mike,

                   

                  Docs are on the Snowdrop web page, specifically here.

                   

                  You have a minor typo, that's all (weaver-class should be used instead of weaverclass).

                   

                  That should be it.