9 Replies Latest reply on Feb 23, 2010 3:34 PM by Peter Johnson

    Sharing class in 2 war applications

    mr han Newbie

      I have one application deployed on the jboss 4.2.2 server.  Now I needto create a new project, which also be deploying on the same jb server. Myquestion is. How would I make use of the classes in the old working projectwith out making copy of them into the new one? In eclipse its working fine if Igive the reference, but when I deploy it. It’s not working. Saying class notfound exception, application failed to load.

       

      Thanks

      MH

        • 1. Re: Sharing class in 2 war applications
          Peter Johnson Master
          You cannot share classes within a WAR with any other applications - this is according to the spec. What you need to do is place the shared classes into a JAR. You cna then place the JAR into the server's lib directory, or place both your WARs and the JAR into an exploded EAR (that is what I would do).
          1 of 1 people found this helpful
          • 2. Re: Sharing class in 2 war applications
            mr han Newbie

            Hi,

             

            Thanks for reply, I did loaded the applications with EAR and in exploded form,

            but the new web application is still not using the old web applications classes.

            Is there a special setting I am missing. It would be nice to have a reference of

            loading the applications with EAR.  I am using jboss 4.2.2

            • 3. Re: Sharing class in 2 war applications
              Peter Johnson Master

              I am not sure what you have done. I do not know what this statement:

               

              "I did loaded the applications with EAR and in exploded form,"

               

              has to do with what I posted previously. Did you include the old classes in your app or did you not? Also, it would help if you were specific. In other words, which class is not being found by the new app, and exactly where is the class located within the EAR. I assume that the EAR is the new app.

              • 4. Re: Sharing class in 2 war applications
                mr han Newbie

                I created a new EAR app and add both new and old web applications to EAR.

                In eclipse I give the old application as ference to the new one and

                its not giving any errors, but when I deploy them (in EAR) the new app

                is not find the classes in the old one.

                 

                new app:

                     import com.xx.yy.data.Values;

                     public class PServlet extends ServletBase  {

                     }

                 

                Old apps has the class

                     com.xx.yy.data.Values;

                 

                Thanks

                • 5. Re: Sharing class in 2 war applications
                  Peter Johnson Master

                  You never posted this:


                  "exactly where is the class located within the EAR"

                   

                  Also, please post the full contents of the EAR. Since you have an exploded EAR, use dir or ls to get a file listing including subdirectories.

                  • 6. Re: Sharing class in 2 war applications
                    mr han Newbie

                    testEAR.ear

                       abOld.war

                         public

                         WEB-INF

                           classes

                             com

                               xx

                                 yy

                                   data

                                      Values

                             lib
                       abNew.war

                         help

                         WEB-INF

                           classes

                             com

                               xx

                                 yy

                                    servlets

                           lib
                       META-INF

                         application.xml

                    • 7. Re: Sharing class in 2 war applications
                      Peter Johnson Master

                      As I stated in my first post:

                       

                      "You cannot share classes within a WAR with any other applications"

                      1 of 1 people found this helpful
                      • 8. Re: Sharing class in 2 war applications
                        mr han Newbie

                        I guess there is no real solution to this problem other then making the

                        common jar between to war.  does enterprise version of jboss supports

                        the sharing of resouces? It would be good to have this feature controlled

                        by user/developer. Thanks for all your help.

                        • 9. Re: Sharing class in 2 war applications
                          Peter Johnson Master
                          As I said in my first post, the inability to share classes between WARs is part of the Java EE spec. Paying for the enterprise version will not change that. The correct way to share classes is to place them in a JAR within the EAR; I menitoned that in my first post also.