5 Replies Latest reply on Dec 16, 2005 3:21 PM by yantriki

    Correct Syntax for Service Bean

    majohnst

      I have seen a lot of different examples of creating a @Service bean. The current EJB3 Trail tutorial is not correct (it doesn't work as printed). I have tried to create a service bean using

      @Service
      @Management(Indexing.class)
      
      public class IndexingBean implements Indexing {
      
      public void start() throws Exception
      {
       log.info("IndexerService - Starting");
      }
      }
      


      But my start() method is never called. I am not using a jboss-service.xml file. If someone has a working example they can post, I would be very thankful.

        • 1. Re: Correct Syntax for Service Bean
          majohnst

          anyone?

          • 2. Re: Correct Syntax for Service Bean

             

            @Service
            @Management(value = MyClass.class)
            public class Blah implements MyClass {
             private Blah() {
             System.out.println("Blah Service Loaded");
             }
            }
            
            
            


            • 3. Re: Correct Syntax for Service Bean
              majohnst

              It still doesn't seem to be acknowledging that this is a service bean. I can see from the jboss log that the bean is loaded, but the start() or create() lifecycle functions are not called.

              • 4. Re: Correct Syntax for Service Bean
                majohnst

                I think I figured out my problem. My interface class did not have a start() function defined in it. Once I added that, the service started correctly.

                • 5. Re: Correct Syntax for Service Bean

                  I am having the same problem with my EJB 3.0 Service.

                  1. When I package my Service classes as .ejb3 and deploy it. There is no error, however the lifecycle methods are never called, so I am not sure if my service is getting deployed at all.

                  2 . When I package the Service classes as .sar file and deploy it, it expects the jboss-service.xml file and if defined it throws the following exception.

                  Caused by: java.lang.Error: Unresolved compilation problems:
                  Type mismatch: cannot convert from Service to Annotation
                  Management cannot be resolved to a type

                  Don't know what extension to use and how to deploy the EJB 3 Service application. Appreciate any help.