1 2 Previous Next 18 Replies Latest reply on Mar 26, 2008 6:59 PM by starksm64

    @RunAs annotations on Servlet Classes

    anil.saldhana

      We need to pick the @RunAs annotations (also @DeclareRoles) on the servlet classes and need to populate them in the metadata.

      I would welcome directions/pointers from Scott.

        • 1. Re: @RunAs annotations on Servlet Classes
          anil.saldhana

          Scott says:

          This should be showing up in the JBossWebMetaData after AnnotationMetaDataDeployer, however, the equivalent of the MergedJBossMetaDataDeployer for JBossWebMetaData has not been created yet.
          


          • 2. Re: @RunAs annotations on Servlet Classes
            starksm64

            I added a org.jboss.web.deployers.MergedJBossWebMetaDataDeployer to the server module. It needs the http://jira.jboss.com/jira/browse/JBMETA-7 completed.

            • 3. Re: @RunAs annotations on Servlet Classes
              starksm64

              I added a stub org.jboss.metadata.web.spec.AnnotationMergedView to metadata. I can't work on this right now so if you want to try be my guest.

              • 4. Re: @RunAs annotations on Servlet Classes
                anil.saldhana

                Sure, Scott. If that is what is needed to end the rollercoaster ride of JBCTS-593, then there will I be. :)

                • 5. Re: @RunAs annotations on Servlet Classes
                  anil.saldhana

                  Scott, I need some guidance here.

                  The servlet class defines the @RunAs annotation. Hence the web.xml servlet definition has no need for an explicit run-as element. Now the JBossWebMetaData merge fails with the following RTE.

                   // Update the run-as indentity to use the principal name
                   if (webXmlRunAs == null)
                   {
                   throw new IllegalStateException("run-as-principal: " + principalName + " found in jboss-web.xml but there was no run-as in web.xml");
                   }
                  


                  This is because the webxml metadata is not aware of the annotation. Shouldn't Carlo's annotation deployer kick in before the webmetadata parse?

                  • 6. Re: @RunAs annotations on Servlet Classes
                    anil.saldhana

                    Maybe I need to figure out how to merge the annotation metadata and the webxml metadata before we hit the jbosswebmetadata parse/merge.

                    • 7. Re: @RunAs annotations on Servlet Classes
                      anil.saldhana

                      The AnnotationMetaDataDeployer should be running before the web parsing deployers. It is running after. If not, we will need to create a separate deployer just to parse the web annotations.

                      • 8. Re: @RunAs annotations on Servlet Classes
                        anil.saldhana

                        This is what I am trying.

                        I am reusing some code from the existing AnnotationMetaDataDeployer to create a parsing deployer that parses the web deployment for annotations and creates a web meta data (annotations view). This parsing deployer runs before the WebAppParsingDeployer. Then in the JBossWebAppParsing Deployer, I am going to create a merged spec view (AnnotationMergedView between xml and annotation). This merged spec view will be merged with the JBossWebMetaData.

                        • 9. Re: @RunAs annotations on Servlet Classes
                          anil.saldhana

                          Looks like until the PostClassloader phase, we have no classloaders. That means my current parsing deployer approach will not work.

                          Plan B:
                          In the JBossWebMetaData merge, I am going to pull out the run as processing and push that to the post classloader deployer that exists now, AnnotationMetaDataDeployer.

                          • 10. Re: @RunAs annotations on Servlet Classes
                            anil.saldhana

                            http://jira.jboss.com/jira/browse/JBMETA-10

                            I have made JBossWebMetaData merge to ignore the web xml runas. A final merge done by the AnnotationMetaDatadeployer is the complete merge. The metadata project test case has been updated to test this.

                            • 11. Re: @RunAs annotations on Servlet Classes
                              starksm64

                              The annotation deployer has to run after parsing deployer as it needs the deployment class loader. We need to get rid of the old xml only based assertions to allow for web.xml, jboss-web.xml and annotations (possibly other deployers) providing metadata input.
                              So, you came to the right solution.

                              • 12. Re: @RunAs annotations on Servlet Classes
                                anil.saldhana

                                 

                                =====================================================
                                Caused by: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
                                 at java.lang.ClassLoader.defineClass1(Native Method)
                                 at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
                                 at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLo
                                ader.java:63)
                                 at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.
                                java:502)
                                 at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.
                                java:462)
                                 at java.security.AccessController.doPrivileged(Native Method)
                                 at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseC
                                lassLoader.java:460)
                                 at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseC
                                lassLoader.java:437)
                                .....
                                 at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
                                 at org.jboss.wsf.container.jboss50.JAXWSDeployerHookPreJSE.getRelevantSe
                                rvlets(JAXWSDeployerHookPreJSE.java:122)
                                 at org.jboss.wsf.container.jboss50.JAXWSDeployerHookPreJSE.isWebServiceD
                                eployment(JAXWSDeployerHookPreJSE.java:98)
                                 at org.jboss.wsf.container.jboss50.ArchiveDeployerHook.deploy(ArchiveDep
                                loyerHook.java:84)
                                ===============================
                                
                                


                                Does this ring any bells, Scott?

                                I need to verify the ejb3 security integration code a little bit further before I commit my ejb3 project changes.

                                • 13. Re: @RunAs annotations on Servlet Classes
                                  starksm64

                                  Seems familiar, but would need to validate the unit class loader. I thought I saw this when there was a destroyed class loader being used.

                                  • 14. Re: @RunAs annotations on Servlet Classes
                                    starksm64

                                    I'm not seeing the AnnotationMergedView in the current jboss-metadata.jar, so the MergedJBossWebMetaDataDeployer is not compiling. I'm going to update it.

                                    1 2 Previous Next