11 Replies Latest reply on Jun 3, 2009 10:37 PM by deanhiller2000

    Deploying separate jar with seam components

    gav_on_rails

      Could anyone tell me whether or not the following scenario is supported by seam?


      I have deployed an ear containing a war and ejb-jar. This has the usual seam architecture with jsf and ejb3. I now want to deploy an ejb-jar externally from the aforementioned ear. This archive also contains seam components, specifically ejb3's. What I want to do is access these from within the ear using the seam component names, so in effect extend the set of jsf event handlers in the application. I understand that seam requires seam.properties in the root of an archive as notification that it should scan that archive for seam components. Is there some way of asking seam to scan an external archive and so support this requirement?

        • 1. Re: Deploying separate jar with seam components
          gav_on_rails

          Having looked at the code it would seem that this is not supported. Seam can be reinitialises, as done in the seam servlet context listener, but this causes the seam contexts to be reset. It would be nice to be able to specify a new url to be scanned for seam components and for these to be added to the current set of components.

          • 2. Re: Deploying separate jar with seam components
            gav_on_rails

            Manually adding components to the application context also works:


            component = new Component(this.getClass().forName("com.company.MyComponent"),
                                          "myComponent");
            
            Contexts.getApplicationContext().set("myComponent.component", component);
            



            but could circumvent important initialisation, which I don't have time to check...

            • 3. Re: Deploying separate jar with seam components
              pmuir

              Not supported.

              • 4. Re: Deploying separate jar with seam components
                gav_on_rails

                Any plans to in the future?

                • 5. Re: Deploying separate jar with seam components
                  pmuir

                  Actually, maybe if you add the external EJB jar to the classpath of the EAR it might get picked up as Seam - give it a go.


                  It's not on the roadmap, but add an issue to JIRA and we can see if it gets many votes.

                  • 6. Re: Deploying separate jar with seam components
                    gav_on_rails

                    An external EJB jar is picked up if the jar is already on the classpath at the time when seam is being initialised, but won't be if you deploy a jar after initialisation is complete.


                    I shall add this issue to JIRA.


                    Thanks.

                    • 7. Re: Deploying separate jar with seam components
                      pmuir

                      Ok. I think then it's even further down the list of priorities, as it would require a big change to the way seam boots.


                      Maybe Web Beans will support this...

                      • 8. Re: Deploying separate jar with seam components
                        deanhiller2000

                        hmmmm, you keep saying have it on the classpath which is confusing....do you mean have it in the same classloader really?  and if so, on jboss, how do I make sure an external jar is in the same classloader as my jar with my EJB's.....my app already gets the EntityManagerFactory through JNDI, but it can't seem to load the beans in that same external jar..it can only use them as EJBs just fine...just doesn't load the seam components in the external jar.  Is there a way to do this as we are sharing this one jar between 10 different applications and it is a jar of lots of classes....we can't deploy that jar 10 times or the memory is ridiculous.
                        thanks,
                        Dean

                        • 9. Re: Deploying separate jar with seam components
                          gav_on_rails

                          Maybe we need something along the lines of:


                          Component.addComponent(newComponent.getClass());


                          then components could perhaps be added programmatically.


                          Or some way of rescanning the classpath for new components again using the seam.properties identifier.

                          • 10. Re: Deploying separate jar with seam components
                            deanhiller2000

                            What do you mean classpath?  I am in an AppServer...not much classpath to deal with but plenty of classloaders to deal with.


                            I could have sworn I was involved with a post that had this solved.  I have a war and jar(not an ear) and just want the war and jar to be in same classloader but I thought they would be if I didn't specify a unified classloader, but it doesn't pick up the seam components :(.


                            We have this jar being successfully used by many JBoss applications(MBeans deployed inside jars), and our seam webapp is loading the beans as EJB's just fine, but is just not loading the seam stuff...why would the EntityManager stuff work but not the seam components :(.

                            • 11. Re: Deploying separate jar with seam components
                              deanhiller2000

                              I DEBUGGED it and found out something very interesting.  Seam picks up all my annotated classes just fine but then fails on this check...


                                       if ( scannedClass.isAnnotationPresent(Name.class) )
                                       {


                              That seems a bit bizarre.  It is like seam has a classloadeer problem and my name annotation is not being picked up BUT the ones with Name annotation showed up in the classes list while other entities where skipped so at one point scanning for these annotations in seam startup succeeded!!!!


                              Dean