3 Replies Latest reply on Jan 4, 2013 3:38 AM by Nicklas Karlsson

    Spring 3, OpenJPA 2 and Commons-fileupload.

    Sudhi SDK Newbie

      Hi All,



      i am using Spring 3.1, with OpenJPA 2.1 in JBOSS 7 . As per discussions and few articles, i have created new module for OpenJPA 2.1and used in application. Application worked fine until a functional requirement came for uploading files wherein we were supposed to use commons-fileupload.


      Firstly while creating module for OpenJPA, server failed to start until i added Commons-fileupload jar. Below shows the module.xml that i used for OpenJPA 2, So question is not sure why OpenJPA is refering to fileupload.


      <module xmlns="urn:jboss:module:1.1" name="org.apache.openjpa">


              <resource-root path="openjpa-all-2.2.0.jar"/>

              <resource-root path="serp-1.13.1.jar"/>

              <resource-root path="commons-fileupload-1.2.2.jar"/>




                  <module name="javax.persistence.api"/>

                  <module name="javax.transaction.api"/>

                  <module name="javax.validation.api"/>

                  <module name="org.apache.log4j"/>






      Secondly, after above conf, when i wanted to implement upload functionality, i created a controller in Spring and multipart request was sent.

      But runtime i get NoClassDefFound excpetion for HttpServletRequest


      java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest











      Can anyone please tell me where i am going wrong or guide me for right class loading approach that needs to be followed in Jboss 7





        • 1. Re: Spring 3, OpenJPA 2 and Commons-fileupload.
          Nicklas Karlsson Master

          Hmm, the server should be giving you the HttpServletRequest automatically. Can you do a jar -tf of your jar to make sure you don't package any extra javax.* (e.g. the servlet api jar) that might confuse the classloader?

          • 2. Re: Spring 3, OpenJPA 2 and Commons-fileupload.
            Sudhi SDK Newbie



            i verified that no servlet-api.jars are available in application lib,


            Just to test, i removed spring multipart configuration then i wont get above exception but i wont be able to use common-fileupload.

            Does adding Commons-fileupload in OpenJPA module make difference ?


            <!-- Multipart conf -->

            <bean id="multipartResolver" 


                    <property name="maxUploadSize"> 



                    <property name="maxInMemorySize"> 








            • 3. Re: Spring 3, OpenJPA 2 and Commons-fileupload.
              Nicklas Karlsson Master

              I don't think OpenJPA has anything to do with commons-fileupload. I think Spring uses commons-fileupload and commons-fileupload uses the HttpServletRequest. If you package Spring with your application, you should also package commons-fileupload with the app (and take away it from the OpenJPA module). What is the stacktrace then?