12 Replies Latest reply on Dec 31, 2006 9:29 AM by dvuday

    Getting Syntax error with EJB 3.0.

    dvuday

      Hi every body I'm Uday...

      I am new to EJB 3.0 and I am getting the following Error in the Satateless Session Bean program given below..This is the example given in the JBoss trialblazer. I have put the necessary jar files in the classpath of the project.

      Eclipse is showing Syntax error at "@Stateless"..saying @Stateless cannot be resolved...

      Can any body please help me

      package trail.slsb;

      import org.jboss.annotation.ejb.LocalBinding;
      import javax.ejb.*;

      @Stateless
      // @LocalBinding (jndiBinding="EJB3Trail/slsb/Calculator")
      public class StatelessCalculator implements Calculator {

      public double calculate (int start, int end, double growthrate, double saving) {
      double tmp = Math.pow(1. + growthrate / 12., 12. * (end - start) + 1);
      return saving * 12. * (tmp - 1) / growthrate;
      }
      }

      Thanks in advance
      Uday

        • 1. Re: Getting Syntax error with EJB 3.0.
          alrubinger

          java.ejb.Stateless is in $JBOSS_HOME/client/jboss-ejb3-client.jar ...you sure that's in your classpath?

          If you're sure of that, what version of EJB3 are you using?

          S,
          ALR

          • 2. Re: Getting Syntax error with EJB 3.0.
            dvuday

            Thank you ALR for your response...

            jboss-ejb3-client.jar is not there in the path $JBOSS_HOME/client/...I tried to download the jar file but I could not be able to find it. I will be very much thankful to you if you tell me where can I get that jar file.

            And the other thing I don't know how to find out the version of the EJB 3.0 which I am using...Are there any versions like EJB 3.1, EJB 3.2...

            If yes where can I know that in my system/configuration ?

            configuration:

            JDK: 1.5.0
            JBOSS: 4.0.3SP1
            Eclipse: 3.1


            Thanks in Advance
            Uday

            • 3. Re: Getting Syntax error with EJB 3.0.
              alrubinger

               

              "dvuday" wrote:
              configuration:

              JDK: 1.5.0
              JBOSS: 4.0.3SP1
              Eclipse: 3.1



              Ah. I can't remember what versions of which, and where the JARs were from that far back...

              JBoss 4.0.4-GA (I believe) shipped w/ EJB3 RC7, and 4.0.5 has RC9. I'd recommend wither upgrading JBoss AS using the visual installer, and selecting the "EJB3" profile, or patching your existing by obtaining only EJB3 RC9 (current release). That should have a patch installer in it to give you what you need.

              S,
              ALR

              • 4. Re: Getting Syntax error with EJB 3.0.
                dvuday

                Thanks...

                I didnt find any seperate link like patch1 or patch2 or RC7 or RC9 for downloading. I am trying with the link

                jboss-4.0.4.GA-Patch1-installer.jar at

                http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=16942&release_id=416591

                will that jar file be there in that patch1??

                Thanks and Regards
                Uday

                • 5. Re: Getting Syntax error with EJB 3.0.
                  alrubinger

                  Sorry; by "RC9" I was referring to RC9 of the EJB3 Project, available as a separate component from JBoss AS:

                  http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=132063

                  ...or by using the JBossAS JNLP Installer for JBossAS 4.0.5, and selecting the EJB3 profile when prompted.

                  S,
                  ALR

                  • 6. Re: Getting Syntax error with EJB 3.0.
                    dvuday

                    Thanks for your valuable replies..You really saved my time in fixing this. But one thing as I am getting the syntax error in the eclipse I may need to put the jar file in the classpath of the project. And that to the file jboss-ejb3-client.jar didn't worked. I have downloaded the RC3 of jboss and tried putting the file jboss-ejb3x.jar in the class path of the project. And interestingly the syntax error was gone. And now I need to package the Bean and access it from the client.

                    My doubt is that don't we need to have an xml descriptor for ejb3 deployement in the server?

                    If yes will it be the same as the one used for EJB 2.0 ?

                    Pleas let me know as soon as possible.

                    Thanks in advance
                    Uday

                    • 7. Re: Getting Syntax error with EJB 3.0.
                      alrubinger

                       

                      My doubt is that don't we need to have an xml descriptor for ejb3 deployement in the server?


                      If you're using annotations on your beans, you won't need the XML descriptor. Just throw into a JAR and deploy.

                      S,
                      ALR

                      • 8. Re: Getting Syntax error with EJB 3.0.
                        dvuday

                        Thanks for the reply...

                        I have packaged the bean and deployed in the server. But when I tried to access the calculator.jsp and hit 'calculate' button...getting an exception....

                        12:39:13,162 ERROR [STDERR] javax.naming.NameNotFoundException: EJB3Trail not bound
                        12:39:13,162 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                        12:39:13,162 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                        12:39:13,162 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                        12:39:13,162 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
                        12:39:13,162 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
                        12:39:13,162 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
                        12:39:13,162 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:351)
                        12:39:13,162 ERROR [STDERR] at org.apache.jsp.calculator_jsp.jspInit(calculator_jsp.java:19)
                        12:39:13,162 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:78)
                        12:39:13,162 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:155)
                        ...........
                        ...........

                        Extra lines not included


                        Where are we actually binding the EJB to a JNDI name ?

                        Thanks and Regards
                        Uday

                        • 9. Re: Getting Syntax error with EJB 3.0.
                          alrubinger
                          • 10. Re: Getting Syntax error with EJB 3.0.
                            dvuday

                             

                            http://docs.jboss.org/ejb3/app-server/tutorial/jndibinding/jndi.html

                            When in doubt, check the docs. :)


                            Thanks alot...

                            uday

                            • 11. Re: Getting Syntax error with EJB 3.0.
                              dvuday

                              Hi...

                              I am unable to access the EJB deployed in the server....I followed the same thing which was given in the documentaion (link sent by ALR) ..but couldnt succeeded...

                              I even tried deploying the EJB3Trail.ear (which was given in the JBoss TrailBlazer) in the server and tried to access the ...Bean...
                              But getting the same exception saying


                              17:22:06,776 INFO [EARDeployer] Init J2EE application: file:/D:/Program Files/jboss-4.0.4.GA/server/default/deploy/EJB3Trail.ear
                              17:22:08,260 INFO [TomcatDeployer] deploy, ctxPath=/EJB3Trail, warUrl=.../tmp/deploy/tmp41708EJB3Trail.ear-contents/web-exp.war/
                              17:22:08,729 INFO [EARDeployer] Started J2EE application: file:/D:/Program Files/jboss-4.0.4.GA/server/default/deploy/EJB3Trail.ear
                              17:22:23,948 ERROR [STDERR] javax.naming.NameNotFoundException: EJB3Trail not bound
                              17:22:23,948 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                              17:22:23,948 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                              17:22:23,948 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                              17:22:23,948 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
                              17:22:23,948 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
                              17:22:23,948 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)


                              is it because of the server i am using???
                              The server i am using is - jboss-4.0.4.GA (JEMS Installer)
                              prior to this version i used JBOSS: 4.0.3SP1


                              any body please help me out..

                              Thanks in advanse
                              Uday

                              • 12. Re: Getting Syntax error with EJB 3.0.
                                dvuday

                                Ah! At last...able to access the EJB...

                                Installed jboss 4.0.4 GA (JEMS Installer) by selecting only ejb3 support when prompted....Last time I selected all when prompted.. :)

                                Regards
                                Uday