1 2 Previous Next 20 Replies Latest reply on Nov 9, 2005 7:48 AM by oliver_zzx

    JNDI in Jboss AOP

    oliver_zzx

      Hey,

      i have a SessionFacade that works on plain JBoss (deployed as Jar).
      I added AOP-Interceptors and deployed the very same as AOP (as aop-file).

      Now i receive this:
      javax.naming.NameNotFoundException: Facade not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
      ...


      Does the Jndi-names of the aop-deploys are different ?
      Here is the code-snippet:
      [CODE]
      Hashtable props = new Hashtable();
      props.put(Context.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      props.put(Context.URL_PKG_PREFIXES,
      "org.jboss.naming:org.jnp.interfaces");
      props.put(Context.PROVIDER_URL, "jnp://" + server + ":1099");
      Context ctx = new InitialContext(props);
      // checks wether the server is reachable
      Socket socket = new Socket(server, 1099);
      Object oStud = ctx.lookup("Facade");
      this.facHome = (FacadeHome) PortableRemoteObject.narrow(oStud, FacadeHome.class);

      [/CODE]

      The SessionBean is called Facade. And it works as standard-deploy but not as aop-deploy ?


      Can somebody help me with this ?


      thanks alot,
      oliver

        • 1. Re: JNDI in Jboss AOP
          kabirkhan

          I'm not sure I have got you correctly, but it looks like your bean is not getting bound. Have you tried the injboss tutorial example, it shows a few different packaging options for J2EE.

          • 2. Re: JNDI in Jboss AOP
            oliver_zzx

             

            "kabir.khan@jboss.com" wrote:
            I'm not sure I have got you correctly, but it looks like your bean is not getting bound. Have you tried the injboss tutorial example, it shows a few different packaging options for J2EE.


            hmm i dont know what tutorial you mean.

            but the main thing is, that the Package with the facade actually WORKS when i export it as jar. The client can bind the remote objects correctly etc.

            I only export if then with AOP-file-Extension (no other changes were made) and it doesnt work anymore.

            So the binding should work...i actually suggest that the JNDI-names are maybe different on AOP-Packages ?! Or are the Conextlookup for Jar-Packages should also work for AOP-packages ?


            thanks for the help!
            oliver


            • 3. Re: JNDI in Jboss AOP
              kabirkhan

               

              "oliver_zzx" wrote:

              hmm i dont know what tutorial you mean.


              Download the latest aop release, then look in docs/aspect-framework/examples/injboss. It explains different packaging methods that work


              • 4. Re: JNDI in Jboss AOP
                oliver_zzx

                 

                "kabir.khan@jboss.com" wrote:
                "oliver_zzx" wrote:

                hmm i dont know what tutorial you mean.


                Download the latest aop release, then look in docs/aspect-framework/examples/injboss. It explains different packaging methods that work


                thanks for this...i took a look through but wasnt able to see any relevance to mine. I only found a sessionbean and servlet-classes. How may that help me with my problem ?

                The packagin/deployment of mine runs without exceptions. Just the connection to the facade doesnt work. But it works as jar - so without aop-extension.

                Is there more to configure before ? I read its all running out-of-the-box. :/

                • 5. Re: JNDI in Jboss AOP
                  oliver_zzx

                   

                  Hashtable props = new Hashtable();
                   props.put(Context.INITIAL_CONTEXT_FACTORY,
                   "org.jnp.interfaces.NamingContextFactory");
                   props.put(Context.URL_PKG_PREFIXES,
                   "org.jboss.naming:org.jnp.interfaces");
                   props.put(Context.PROVIDER_URL, "jnp://" + server + ":1099");
                   Context ctx = new InitialContext(props);


                  This snipped is part of the client that connects to the jboss. It work fine for *.jar packages. If i turn to *.aop packages it doesnt.

                  Are these "adresses" still right when using aop ?
                  "org.jnp.interfaces.NamingContextFactory"
                  "org.jboss.naming:org.jnp.interfaces"


                  or do they change ?


                  thanks,
                  oliver

                  • 6. Re: JNDI in Jboss AOP
                    kabirkhan

                    The naming does not change when using aop.

                    For your session bean to get installed as an EJB, you need a jar file, with a META-INF/ejb-jar.xml file somewhere in your deployment. If you don't have this, your classes will still get deployed/loaded, but not taken to be an ejb, and thus not bound in JNDI.

                    Please look at the injboss example again, as it shows you both how to make sure your beans get installed and bound properly, and also woven for AOP.

                    • 7. Re: JNDI in Jboss AOP
                      oliver_zzx

                      btw, my META-INF/ejb-jar.xml

                      <?xml version="1.0" encoding="UTF-8"?>
                      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
                      <ejb-jar id="ejb-jar_ID">
                      <display-name>AOPTest</display-name>
                      <enterprise-beans>
                      <session id="Facade">
                      <ejb-name>Facade</ejb-name>
                      <home>beans.FacadeHome</home>
                      <remote>beans.Facade</remote>
                      <local-home>beans.FacadeLocalHome</local-home>
                      <local>beans.FacadeLocal</local>
                      <ejb-class>beans.FacadeBean</ejb-class>
                      <session-type>Stateless</session-type>
                      <transaction-type>Container</transaction-type>
                      </session>
                      </enterprise-beans>
                      </ejb-jar>


                      • 8. Re: JNDI in Jboss AOP
                        oliver_zzx

                        ah sorry...quote wasnt the right choice (Admin, feel free to delete that one)

                        <?xml version="1.0" encoding="UTF-8"?>
                        <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
                        <ejb-jar id="ejb-jar_ID">
                         <display-name>AOPTest</display-name>
                         <enterprise-beans>
                         <session id="Facade">
                         <ejb-name>Facade</ejb-name>
                         <home>beans.FacadeHome</home>
                         <remote>beans.Facade</remote>
                         <local-home>beans.FacadeLocalHome</local-home>
                         <local>beans.FacadeLocal</local>
                         <ejb-class>beans.FacadeBean</ejb-class>
                         <session-type>Stateless</session-type>
                         <transaction-type>Container</transaction-type>
                         </session>
                         </enterprise-beans>
                        </ejb-jar>


                        • 9. Re: JNDI in Jboss AOP
                          kabirkhan

                          OK, so I meant you need a jar file, with the .jar extension and META-INF/ejb-jar.xml file somewhere in your deployment for it to be picked up by the EJB deployer, which then creates the bean container and bind the home interfaces into JNDI.

                          Then as shown in the AOP example, either deploy a separate jboss-aop.xml file OR include an .aop archive in your deployment bundle. If you cannot get it to work, use the injboss example as a starting point for your worl

                          • 10. Re: JNDI in Jboss AOP
                            kabirkhan

                            (I deleted the post you mentioned, but it deleted the wrong one - for completeness)

                            "oliver_zzx" wrote:

                            well i have such an ejb-jar.xml for sure. If not the package names as facade.jar wouldnt work too, but it does. It must be something different cause i only rename facade.jar to facade.aop and copy it into the deploy-directory. He opens it with aop-deployer but doesnt bind the facade like he did when its a jar :/

                            you say it should have worked this way ? i mean it should work to rename *.jar to *.aop and he still should be able to bind it too ? Any idea what may be the reason ?


                            • 11. Re: JNDI in Jboss AOP
                              oliver_zzx

                               

                              "kabir.khan@jboss.com" wrote:
                              OK, so I meant you need a jar file, with the .jar extension and META-INF/ejb-jar.xml file somewhere in your deployment for it to be picked up by the EJB deployer, which then creates the bean container and bind the home interfaces into JNDI.


                              ok i have one....and he binds correctly. My client can remotely invoke on the sessionFacade.


                              "kabir.khan@jboss.com" wrote:

                              Then as shown in the AOP example, either deploy a separate jboss-aop.xml file OR include an .aop archive in your deployment bundle. If you cannot get it to work, use the injboss example as a starting point for your worl


                              "deplayment bundle" means the deply-directory of the used profile i guess ?!

                              well i think i got you now. My jboss is running, got the facade bound over the *.jar file and i copied the jboss-aop.xml into the deploy-dir. he also included it:
                              11:38:11,078 INFO [AspectDeployer] Deployed AOP: file:/C:/Programme/jboss-4.0.1
                              RC2/server/default/deploy/jboss-aop.xml

                              But the interceptor class still doesnt acts. If i call the aop-app from eclipse it works. My interceptor lies within the *.jar file right on the package of the bean itself.

                              <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                              <aop>
                               <bind pointcut="execution(public java.lang.String beans.FacadeBean-&gt;sayHello())">
                               <interceptor class="beans.FacadeInterceptor"/>
                               </bind>
                              </aop>
                              



                              forgot something again ?


                              thanks alot for the help kabir!

                              • 12. Re: JNDI in Jboss AOP
                                kabirkhan

                                Have you enabled loadtime weaving in JBoss?

                                http://docs.jboss.com/aop/1.3/aspect-framework/reference/en/html/running.html#jboss

                                Also
                                http://www.jboss.com/index.html?module=bb&op=search
                                and enter EnableLoadtimeWeaving to see answers to others who had problems

                                As I say for all these cases, get the injboss example to work with loadtime weaving before you try anything else, it will work - any problems there are to do with your setup. Once you get that working, try the your own stuff

                                • 13. Re: JNDI in Jboss AOP
                                  oliver_zzx

                                   

                                  "kabir.khan@jboss.com" wrote:
                                  Have you enabled loadtime weaving in JBoss?

                                  http://docs.jboss.com/aop/1.3/aspect-framework/reference/en/html/running.html#jboss

                                  Also
                                  http://www.jboss.com/index.html?module=bb&op=search
                                  and enter EnableLoadtimeWeaving to see answers to others who had problems


                                  ahm no i hadnt as i read it works out of the box. I had made the changes now. Can i somewhere check if its all enabled on running jboss ? Where in the jmx-console i may find that? Cause my app still dont make it...


                                  "kabir.khan@jboss.com" wrote:

                                  As I say for all these cases, get the injboss example to work with loadtime weaving before you try anything else, it will work - any problems there are to do with your setup. Once you get that working, try the your own stuff


                                  i actually try...i need to get into that ant. never used it before...there isnt a precompiled version, is it ?

                                  • 14. Re: JNDI in Jboss AOP
                                    oliver_zzx

                                    hmm i get plenty of error on compile with ant

                                    [javac] symbol : class HttpServletRequest
                                     [javac] location: class org.jboss.injbossaop.web.EarExampleServlet
                                     [javac] public void service(HttpServletRequest request, HttpServletRespon
                                    se response)
                                     [javac] ^
                                     [javac] C:\Programme\jboss-aop_1.3.4\docs\aspect-framework\examples\injboss\
                                    src\main\org\jboss\injbossaop\web\EarExampleServlet.java:32: cannot resolve symb
                                    ol
                                     [javac] symbol : class HttpServletResponse
                                     [javac] location: class org.jboss.injbossaop.web.EarExampleServlet
                                     [javac] public void service(HttpServletRequest request, HttpServletRespon
                                    se response)
                                     [javac] ^
                                     [javac] C:\Programme\jboss-aop_1.3.4\docs\aspect-framework\examples\injboss\
                                    src\main\org\jboss\injbossaop\web\EarExampleServlet.java:33: cannot resolve symb
                                    ol
                                     [javac] symbol : class ServletException
                                     [javac] location: class org.jboss.injbossaop.web.EarExampleServlet
                                     [javac] throws ServletException, IOException {
                                     [javac] ^
                                     [javac] C:\Programme\jboss-aop_1.3.4\docs\aspect-framework\examples\injboss\
                                    src\main\org\jboss\injbossaop\web\EarExampleServlet.java:51: cannot resolve symb
                                    ol
                                     [javac] symbol : class ServletException
                                     [javac] location: class org.jboss.injbossaop.web.EarExampleServlet
                                     [javac] throw new ServletException(e);
                                     [javac] ^
                                     [javac] 34 errors
                                    



                                    but the imports should be fine:

                                    path="${jboss.dir}/server/default/lib/javax.servlet.jar"/>


                                    1 2 Previous Next