1 2 Previous Next 18 Replies Latest reply on Apr 6, 2007 1:22 PM by shupingchen

    Deploying a simple HelloWorld EJB3 under JBoss

    balde

      I'm trying to deploy a basic EJB 3.0 under JBoss 4.0.5. Can anyone tell me how to configure JBoss (maybe using the EJB 3 module) to be able to deploy EJB3? I'm trying the HelloWorld example from "MasteringEJB 4th ed.".
      Thanks.

        • 1. Re: Deploying a simple HelloWorld EJB3 under JBoss
          bdecoste

          How did you install 4.0.5? There is an installer option that will install 4.0.5 with ejb3 or clustered-ejb3. If you are installing ejb3 onto a pre-existing, non-ejb3 4.0.5, download EJB3 RC9 Patch 1 from http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=132063

          Follow the instructions - there is an ant script to install ejb3 onto your existing installation

          • 2. Re: Deploying a simple HelloWorld EJB3 under JBoss
            wolfgangknauf

            Hi !

            did you unzip the JBoss 4.0.5 zip, or did you use the installer jar ?
            If you unzipped it: Did you install EJB3 RC9 into the JBoss 4.0.5 server ?
            http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=132063
            If you used the installer: did you install the EJB3 profile ?

            If yes and deployment does not work: give some more details about your package structure (EAR file, JAR file ?).

            Best regards

            Wolfgang

            • 3. Re: Deploying a simple HelloWorld EJB3 under JBoss
              balde

              I re-installed JBoss 4.0.5 with the installer and option EJB3. I'm getting the error:

              javax.naming.NameNotFoundException: org.os.ejb3.Hello not bound

              Seams like the reflection lookup doesn't work like it should be for EJB3.
              - my Interface:
              package org.os.ejb3;
              public interface Hello {
               public String hello();
              }
              

              - My Bean:
              package org.os.ejb3;
              
              import javax.ejb.Remote;
              import javax.ejb.Stateless;
              
              
              @Stateless
              @Remote(Hello.class)
              public class HelloBean implements Hello {
              
               public String hello() {
               return "Hi there this is JBoss server side";
               }
              
              }
              


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


              - my client:
              package org.os.ejb3;
              
              import javax.naming.Context;
              import javax.naming.InitialContext;
              import javax.naming.NamingException;
              
              public class HelloClient {
              
               /**
               * @param args
               */
               public static void main(String[] args) {
               System.out.println("STARTING HelloClient ... ");
              
               try {
               Context ctx = new InitialContext();
              
               Hello h = (Hello)ctx.lookup("org.os.ejb3.Hello");
               String s = h.hello();
              
               System.out.println("HelloClient -- received from server > " + s);
              
               } catch (NamingException e) {
               e.printStackTrace();
               }
              
               }
              
              }
              


              • 4. Re: Deploying a simple HelloWorld EJB3 under JBoss
                bdecoste

                The default JNDI bindgs for an EJB3 are ejbName/remote and ejbName/local for the remote and local business interfaces. If the EJB3 is deployed in an .ear, the default jndi bindings are earName/ejbName/remote and earName/ejbName/local. You can override the default with the @RemoteBinding and @LocalBinding annotations or the <jndi-name> and <local-jndi-name> in jboss.xml.

                • 5. Re: Deploying a simple HelloWorld EJB3 under JBoss
                  balde

                  Hello and sorry for the delay ;-),
                  I used both the installation with the installer and the patch, but I get the same error:

                  javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb3.remoting.IsLocalInterceptor; local class incompatible: stream classdesc serialVersionUID = -3758782076801249473, local class serialVersionUID = 7152865575974097694]
                  

                  It seams like an internal JBoss error. A class being retrieved by the client but having a different version id on the server... Do u know a workaround?
                  Thanks for your help.

                  balde
                  -------

                  • 6. Re: Deploying a simple HelloWorld EJB3 under JBoss
                    bdecoste

                    Looks like you have the wrong classes in your client's classpath - you have a different version running on the server vs the client.

                    • 7. Re: Deploying a simple HelloWorld EJB3 under JBoss
                      balde

                      That's right. This is also what I was saying.
                      Questions :
                      1/ - Do anyone know a work around?
                      2/ - Would EB3 work without any problem (just deploy under server/default/deploy) with JBoss 4.2.0 RC1?
                      Thanks

                      • 8. Re: Deploying a simple HelloWorld EJB3 under JBoss
                        balde

                        So the only thing that works for me with EJB3 is JBoss 4.2.0 RC1. So I'll stick with it..

                        • 9. Re: Deploying a simple HelloWorld EJB3 under JBoss
                          bdecoste

                          4.0.5 is only compatible with EJB3 RC9 Patch 1. Our initial release of the 4.0.5 installer with the EJB3 option had problems. We then released a corrected, non-installer version of EJB3 and shortly thereafter a corrected installer version.

                          So if you want to run 4.0.5 with EJB3, you need to make sure you have the latest installer or manually install the non-installer version of EJB3.

                          • 10. Re: Deploying a simple HelloWorld EJB3 under JBoss
                            shupingchen

                            I am reading the Mastering EJB 3.0 , and I have encountered the same problem when I deploy the Helloworld example. I am using the jboss-4.0.5.GA. When I deploy the EJB to JBoss, the client code throws an exception showing that the examples.session.stateless.Hello is not bound. Do you have solved this problem?
                            Does anyone can tell me how to let the helloworld example work in JBoss?

                            • 11. Re: Deploying a simple HelloWorld EJB3 under JBoss
                              shupingchen

                               

                              "shupingChen" wrote:
                              I am reading the Mastering EJB 3.0 , and I have encountered the same problem when I deploy the Helloworld example. I am using the jboss-4.0.5.GA. When I deploy the EJB to JBoss, the client code throws an exception showing that the examples.session.stateless.Hello is not bound. Have you solved this problem yet?
                              Does anyone can tell me how to let the helloworld example work in JBoss?


                              • 12. Re: Deploying a simple HelloWorld EJB3 under JBoss
                                bdecoste

                                The default jndi bindings have probably changed

                                The default JNDI bindgs for an EJB3 are ejbName/remote and ejbName/local for the remote and local business interfaces. If the EJB3 is deployed in an .ear, the default jndi bindings are earName/ejbName/remote and earName/ejbName/local. You can override the default with the @RemoteBinding and @LocalBinding annotations or the <jndi-name> and <local-jndi-name> in jboss.xml

                                • 13. Re: Deploying a simple HelloWorld EJB3 under JBoss
                                  shupingchen

                                  I copy my EJB jar to the server\default\deploy directory directly, and there is no ejb-jar.xml in the jar. The client code:
                                  Context ctx = new InitialContext(System.getProperties());
                                  Hello hello = (Hello) ctx.lookup(Hello.class.getName());
                                  System.out.println(hello.hello());
                                  Must I change my client code?

                                  • 14. Re: Deploying a simple HelloWorld EJB3 under JBoss
                                    shupingchen

                                    My EJB hasn't home interface. It just has a business interface, namingly Hello. How can I configure the <jndi-name> in jboss.xml?

                                    1 2 Previous Next