14 Replies Latest reply on Jul 13, 2009 4:50 AM by jaikiran

    Deployment Descriptor Overriding Not Working?

    javidjamae

      I'm playing around with JBoss 5.0.0 CR2.

      I have tried binding EJB Stateless session beans using annotations and using deployment descriptors, and they both seem to work fine separately. But, when I define a bean with the @LocalBinding and @RemoteBinding annotations and then try to override the bindings in the jboss.xml file, the remote binding defined in the deployment descriptor cannot be found.

      It was my assumption that the deployment descriptor takes precedence, am I incorrect?

      Here is my jboss.xml:

      <jboss xmlns="http://www.jboss.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee
       http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
       version="3.0">
      
       <enterprise-beans>
       <session>
       <ejb-name>OverridePrinterBean</ejb-name>
       <jndi-name>OverriddenGlobally</jndi-name>
       <local-jndi-name>OverriddenLocally</local-jndi-name>
       </session>
       </enterprise-beans>
      </jboss>
      


      Here is the first part of my bean:
      @Stateless
      @LocalBinding(jndiBinding = "MyLocalOverridePrinter")
      @RemoteBinding(jndiBinding = "MyOverridePrinter")
      public class OverridePrinterBean implements MessagePrinterRemote,
       MessagePrinterLocal {
      


      When I look in the JndiView I see that:
      - MyLocalOverridePrinter (from local annotation) is not bound at all
      - MyOverridePrinter (from remove annotation) is bound as follows:
      MyOverridePrinter (class: Proxy for: com.manning.jbia.jndibinding.MessagePrinterRemote)
      - OverriddenGlobally (from remote in descriptor) is not bound at all
      - OverriddenLocally (from local in descriptor) is bound as follows:
      OverriddenLocally (class: Proxy for: com.manning.jbia.jndibinding.MessagePrinterLocal)

      So, it looks like its picking up the Local binding from the jboss.xml and the remote binding from the annotations.

      Any ideas? Is this a bug?

        • 1. Re: Deployment Descriptor Overriding Not Working?
          alrubinger

          I'm working on some related issues now.

          Thanks for bringing this up; we've got to get a handle on what constitutes an override, and what makes for an additive property when it comes to @RemoteBinding.jndiBinding and the XML equivalents (as @RemoteBindings may be applied more than once).

          This discussion is also on the dev forums at: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=142416

          S,
          ALR

          • 2. Re: Deployment Descriptor Overriding Not Working?
            wolfgangknauf

            I found that JNDI names from jboss.xml are totally ignored. I tried to build an app without annotations, just XML. The server log contained entries about processing the JNDI bindings, but absolutely nothing was done for the bean. I can provide you with a small sample if needed.

            Best regards

            Wolfgang Knauf

            • 3. Re: Deployment Descriptor Overriding Not Working?
              wolfgangknauf

              Hi Andrew,

              any news on this binding problem? As this blocks me from using pure annotations, it is quite a major problem :-(.

              Thanks

              Wolfgang

              • 4. Re: Deployment Descriptor Overriding Not Working?
                wolfgangknauf

                I have a annotation-free sample here. If deployed, the log shows that the JNDI bindings are processed, but JNDIView does not list anything for the session bean.
                The sample can be found here:
                http://www.informatik.fh-wiesbaden.de/~knauf/KomponentenArchitekturen2008/stateless/StatelessNoAnnotation.ear

                Hope it is not a trivial error of mine, but with 4.2 it worked.

                Wolfgang

                • 5. Re: Deployment Descriptor Overriding Not Working?
                  jaikiran

                  Try this- In your ejb-jar.xml, change:

                  <remote>de.fhw.komponentenarchitekturen.knauf.stateless.GeometricModelRemote</remote>
                  <local>de.fhw.komponentenarchitekturen.knauf.stateless.GeometricModelLocal</local>
                  


                  to (in this order)

                  <business-local>de.fhw.komponentenarchitekturen.knauf.stateless.GeometricModelLocal</business-local>
                  <business-remote>de.fhw.komponentenarchitekturen.knauf.stateless.GeometricModelRemote</business-remote>


                  • 6. Re: Deployment Descriptor Overriding Not Working?
                    alrubinger

                    Wolfgang:

                    Just catching up with the User Forum now :)

                    In trunk I've even just added some extra processing to make errors of this nature painfully obvious:

                    http://anonsvn.jboss.org/repos/jbossas/projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/validator/ejb/jboss/CompleteEjb2xViewValidator.java

                    So your EAR (when deployed in trunk) shows me:

                    org.jboss.metadata.validation.chain.ValidatorChainException: Validation has failed due to the following ValidationException(s) raised:
                    * EJB GeometricModelBean has defined EJB2.x remote component interface of de.fhw.komponentenarchitekturen.knauf.stateless.GeometricModelRemote but has no home; ; Incomplete EJB2.x View [JBMETA-130]


                    ...meaning Jaikiran looks correct, assuming it's the XML that's your problem.

                    "ejb-jar.xml Schema" wrote:
                    Either both the local-home and the local elements or both the home and the remote elements must be specified for the session bean.


                    S,
                    ALR



                    • 7. Re: Deployment Descriptor Overriding Not Working?
                      alrubinger

                      PS, the spec is stupid.

                      @Remote and @Local denote "Business Remote" and "Business Local" interfaces, EJB3 Views.

                      XML "remote" and "local" denote EJB2.x Component Remote and Local Views.

                      We don't support any annotation-based declaration of EJB2.x Component Views; we read in "Remote" and "Local" interfaces from the return values of the Home and LocalHome Classes.

                      S,
                      ALR

                      • 8. Re: Deployment Descriptor Overriding Not Working?
                        wolfgangknauf

                        Thanks to you two for your help! Now my sample works like a charm, the link of my previous post is updated. Unfortunately the java.util.logging Logger is not working, maybe because of some error messages about interceptors.

                        Are you sure about not supporting "local"/"remote" for EJB3 views any longer? My EJB book ("Enterprise JavaBeans 3.0" by Richard Monson-Haefel + Bill Burke) always uses "local"/"remote" in its ejb-jar.xml samples (page 224 for example), and in the spec I did not find anything about the EJB2.1/3.0 distinction of the xml elements.

                        Best regards

                        Wolfgang

                        PS: Sorry for hijacking this thread, I thought that my problem was related to the original posters problem.

                        • 9. Re: Deployment Descriptor Overriding Not Working?
                          alrubinger

                          Though the spec may *imply* this, it's really not too clearly defined. In fact, Burke had interpreted @Local/@Remote to work as either view initially.

                          Eventually we uncovered that to support all of the spec's tests for EJBContext, this was the only way things could be drawn. Further bolstering the handling I outlined is the XSD for ejb-jar.xml:

                          "ejb-jar.xsd" wrote:
                          Either both the local-home and the local elements or both the home and the remote elements must be specified.


                          ...check the comments in http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd

                          S,
                          ALR

                          • 10. Re: Deployment Descriptor Overriding Not Working?
                            alrubinger

                            Javid:

                            I believe your case should be handled as expected (@RemoteBindings) in the current AS trunk if you'd like to build it and give a spin.

                            S,
                            ALR

                            • 11. Re: Deployment Descriptor Overriding Not Working?

                              hi.
                              i am also got the same problem when i use remote and local tags in ejb-jar.xml. but i followed your way and i added business-local and business-remote tags and now that error is gone. but it is not still deployed in jboss. i didn't use jboss.xml to bind jndi name, even i use jboss. i am using jboss 5. should i use jboss.xml for this case to bind jndi. i got error is

                              DEPLOYMENTS IN ERROR:
                              Deployment "vfszip:/C:/WORK_SPACE/MyJboss5/jboss-5.1.0.GA/server/default/deploy/JavaEEwithMyJboss5.ear/" is in error due to the following reason(s): java.lang.ClassNotFoundException: NewSession2Local from BaseClassLoader@1de3998{VFSClassLoaderPolicy@974bf0{name=vfszip:/C:/WORK_SPACE/MyJboss5/jboss-5.1.0.GA/server/default/deploy/JavaEEwithMyJboss5.ear/ domain=ClassLoaderDomain@d8ca48{name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.bootstrap.NoAnnotationURLClassLoader@186db54} roots=[MemoryContextHandler@16428328[path= context=vfsmemory://5c4o145-1rjfkg-fwuo5h4z-1-fwuo8n55-9o real=vfsmemory://5c4o145-1rjfkg-fwuo5h4z-1-fwuo8n55-9o], DelegatingHandler@25043379[path=JavaEEwithMyJboss5.ear context=file:/C:/WORK_SPACE/MyJboss5/jboss-5.1.0.GA/server/default/deploy/ real=file:/C:/WORK_SPACE/MyJboss5/jboss-5.1.0.GA/server/default/deploy/JavaEEwithMyJboss5.ear], DelegatingHandler@30830472[path=JavaEEwithMyJboss5.ear/JavaEEwithMyJboss5-ejb.jar context=file:/C:/WORK_SPACE/MyJboss5/jboss-5.1.0.GA/server/default/deploy/ real=file:/C:/WORK_SPACE/MyJboss5/jboss-5.1.0.GA/server/default/deploy/JavaEEwithMyJboss5.ear/JavaEEwithMyJboss5-ejb.jar]] delegates=null exported=[META-INF, ejb] <IMPORT-ALL>NON_EMPTY}}


                              my ejb-jar.xml like this


                              <?xml version="1.0" encoding="UTF-8"?>
                              <ejb-jar
                              xmlns="http://java.sun.com/xml/ns/javaee"
                              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                              http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
                              version="3.0">
                              <enterprise-beans>

                              <ejb-name>NewSessionBean</ejb-name>
                              <business-local>ejb.NewSessionLocal</business-local>
                              <business-remote>ejb.NewSessionRemote</business-remote>
                              <ejb-class>ejb.NewSessionBean</ejb-class>
                              <session-type>Stateless</session-type>

                              <env-entry>
                              <env-entry-name>min2</env-entry-name>
                              <env-entry-type>java.lang.Integer</env-entry-type>
                              <env-entry-value>10</env-entry-value>
                              <injection-target>
                              <injection-target-class>
                              ejb.NewSessionBean
                              </injection-target-class>
                              <injection-target-name>minCheckNumber</injection-target-name>
                              </injection-target>
                              </env-entry>
                              <ejb-local-ref>
                              <ejb-ref-name>ejb/NewSession2Local</ejb-ref-name>
                              <ejb-ref-type>Session</ejb-ref-type>
                              NewSession2Local
                              <injection-target>
                              <injection-target-class>
                              ejb.NewSessionBean
                              </injection-target-class>
                              <injection-target-name>newSession2Bean</injection-target-name>
                              </injection-target>
                              </ejb-local-ref>

                              </enterprise-beans>
                              </ejb-jar>

                              pls help me


                              • 12. Re: Deployment Descriptor Overriding Not Working?
                                jaikiran

                                 

                                java.lang.ClassNotFoundException: NewSession2Local


                                Are you sure you have packaged the class in your application?

                                <business-local>ejb.NewSessionLocal</business-local>

                                Hmm, the strange thing about that exception is that it does not mention the package name. Are you sure this ejb-jar.xml is being picked up?


                                • 13. Re: Deployment Descriptor Overriding Not Working?

                                  Hi,

                                  what solution can you propose for overiding setting in XML ?

                                  Thanks before,

                                  Ichai

                                  • 14. Re: Deployment Descriptor Overriding Not Working?
                                    jaikiran

                                    Ichai,

                                    Please start a new thread to discuss your question. Also please provide details like which version of JBoss AS you are using and what version of EJB. Also which setting do you want to override using the xmls? And just to get you started, here's the EJB3 tutorial which might help you find what you are looking for http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html/index.html