11 Replies Latest reply on Jun 12, 2009 8:24 AM by Sam Wan

    EJB tutorial

    Sam Wan Newbie

      Hi,

      I am new to EJB development for JBOSS (5.0)
      Can anyone point me to a site that contains EJB tutorial for JBOSS 5?

      Thanks

        • 2. Re: EJB tutorial
          Sam Wan Newbie

           

          "jaikiran" wrote:
          Here http://www.jboss.org/ejb3/docs/

          Hi, thanks for the link.
          Is there a similar tutorial but in eclipse base JBOSS EJB3?
          I have my JBOSS 5.0 installed in FreeBSD and I want to start a JBoss EJB project from Windows Eclipse 3.4.2. Thus, I may need to IMPORT some files from JBOSS in FreeBSD, but I am not sure what should I do when I come to that import stage.

          Thanks
          Sam

          • 3. Re: EJB tutorial
            Sam Wan Newbie

            Hi,

            I take an easy step.
            I tried to following the EJB3.0 tutorial here:
            http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html_single/index.html#EJB3_TUTORIAL_HOME

            but I couldn't find source for org.jboss.tutorial in my JBOSS 5.0 installation directory.

            Can anyone tell me where can I download org.jboss.tutorial (with svn co to check)?

            thanks heaps.

            • 4. Re: EJB tutorial
              jaikiran pai Master

               

              "samwan808" wrote:

              but I couldn't find source for org.jboss.tutorial in my JBOSS 5.0 installation directory.

              Can anyone tell me where can I download org.jboss.tutorial (with svn co to check)?



              The source is available at the same location that i pointed earlier http://www.jboss.org/ejb3/docs/. There's a "Tutorial (Source)" row in that table

              • 5. Re: EJB tutorial
                Sam Wan Newbie

                Hi,

                I tried to build the bean example CaculatorBean, but there is no build.xml in the directory.
                twp1:stateless # pwd
                /usr/java-source/ejb3-tutorial/source/stateless/src/org/jboss/tutorial/stateless
                twp1:stateless # ls
                ./ ../ bean/ client/
                twp1:stateless # ant
                Buildfile: build.xml does not exist!
                Build failed
                twp1:stateless #

                The tutorial page doesn't say anything about how to setup the build process.
                http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html_single/index.html#EJB3_TUTORIAL_HOME
                It only says:
                Make sure your JBossAS-5.x is running
                $ ant
                $ ant run

                Any more instruction?

                Thanks

                • 6. Re: EJB tutorial
                  jaikiran pai Master

                   

                  /usr/java-source/ejb3-tutorial/source/stateless/src/org/jboss/tutorial/stateless


                  You are in the wrong folder. You should be in:

                  /usr/java-source/ejb3-tutorial/source/stateless/



                  The tutorial page doesn't say anything about how to setup the build process


                  It does have a Building and Running section http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html/Stateless_Beans.html which says:

                  From the command prompt, move to the "stateless" folder under the EJB3_TUTORIAL_HOME ...


                  • 7. Re: EJB tutorial
                    Sam Wan Newbie

                     

                    "jaikiran" wrote:
                    /usr/java-source/ejb3-tutorial/source/stateless/src/org/jboss/tutorial/stateless


                    You are in the wrong folder. You should be in:

                    /usr/java-source/ejb3-tutorial/source/stateless/



                    The tutorial page doesn't say anything about how to setup the build process


                    It does have a Building and Running section http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html/Stateless_Beans.html which says:

                    From the command prompt, move to the "stateless" folder under the EJB3_TUTORIAL_HOME ...

                    OK, after set the tutorial home directory , moved to the stateless folder, and type ant, I got the following error:
                    twp1:ejb3-tutorial # cd source/stateless
                    ./ ../ build.xml jndi.properties log4j.xml pom.xml src/
                    twp1:stateless # ant
                    Buildfile: build.xml

                    BUILD FAILED
                    /usr/java-source/ejb3-tutorial/source/stateless/build.xml:33: /usr/java-source/ejb3-tutorial/source/stateless/${env.JBOSS_HOME}/client not found.

                    Total time: 0 seconds
                    twp1:stateless #

                    Here is where I executed the ant command:
                    twp1:stateless # pwd
                    /usr/java-source/ejb3-tutorial/source/stateless
                    twp1:stateless #

                    Thanks

                    • 8. Re: EJB tutorial
                      jaikiran pai Master

                       

                      BUILD FAILED
                      /usr/java-source/ejb3-tutorial/source/stateless/build.xml:33: /usr/java-source/ejb3-tutorial/source/stateless/${env.JBOSS_HOME}/client not found.


                      See this http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html/JBossAS5.html

                      • 9. Re: EJB tutorial
                        Sam Wan Newbie

                         

                        "jaikiran" wrote:
                        BUILD FAILED
                        /usr/java-source/ejb3-tutorial/source/stateless/build.xml:33: /usr/java-source/ejb3-tutorial/source/stateless/${env.JBOSS_HOME}/client not found.


                        See this http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html/JBossAS5.html

                        Thanks for the help.
                        I have it compiled with ant, but failed when it is trying to do the binding:
                        twp1:stateless # ant
                        Buildfile: build.xml

                        prepare:
                        [mkdir] Created dir: /usr/java-source/ejb3-tutorial/source/stateless/build
                        [mkdir] Created dir: /usr/java-source/ejb3-tutorial/source/stateless/build/classes

                        compile:
                        [javac] Compiling 5 source files to /usr/java-source/ejb3-tutorial/source/stateless/build/classes

                        ejbjar:
                        [jar] Building jar: /usr/java-source/ejb3-tutorial/source/stateless/build/jboss-ejb3-tutorial-stateless.jar
                        [copy] Copying 1 file to /usr/local/jboss5/server/default/deploy

                        BUILD SUCCESSFUL
                        Total time: 3 seconds
                        twp1:stateless # ant run
                        Buildfile: build.xml

                        prepare:

                        compile:

                        ejbjar:

                        run:
                        [java] Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost and discovery failed with error: javax.naming.Communication
                        Exception: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1
                        099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]]]
                        [java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1727)
                        [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:680)
                        [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
                        [java] at javax.naming.InitialContext.lookup(InitialContext.java:392)
                        [java] at org.jboss.tutorial.stateless.client.Client.main(Client.java:34)
                        [java] Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server loc
                        alhost:1099 [Root exception is java.net.ConnectException: Connection refused]]
                        [java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:311)
                        [java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1698)
                        [java] ... 4 more
                        [java] Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]
                        [java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:281)
                        [java] ... 5 more
                        [java] Caused by: java.net.ConnectException: Connection refused
                        [java] at java.net.PlainSocketImpl.socketConnect(Native Method)
                        [java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
                        [java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
                        [java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
                        [java] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
                        [java] at java.net.Socket.connect(Socket.java:519)
                        [java] at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)
                        [java] at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)
                        [java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:277)
                        [java] ... 5 more
                        [java] Java Result: 1

                        BUILD SUCCESSFUL
                        Total time: 6 seconds

                        JBOSS is with version 5.0 GA and listening on port 8080.

                        Thanks heaps


                        • 10. Re: EJB tutorial
                          jaikiran pai Master

                          Make sure your JBossAS-5.x is running

                          • 11. Re: EJB tutorial
                            Sam Wan Newbie

                            I found out a problem.
                            Initially I started Jboss5.0 GA with the following command
                            /usr/local/jboss5/bin/run.sh -b 192.168.1.246

                            After I restart jboss with /usr/local/jboss5/bin/run.sh (without any argument),
                            it listen to localhost 1099.

                            Then the command "ant run" was executed successfully.
                            May I ask how to instruct ant to run on 192.168.1.246 instead localhost? or setup JBOSS to listening on 192.168.1.246 AND localhost?

                            Thanks