glassfish
  1. glassfish
  2. GLASSFISH-17378

Deploying a .ear with a single MDB throws Exception "Invalid ejb jar [...]: it contains zero ejb. "

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: v3.0.1
    • Fix Version/s: None
    • Component/s: ejb_container
    • Labels:
      None
    • Environment:

      Winows 7 64-bit, JDK 1.6.0_27-b07

      Description

      Deploying a .ear with a single MDB in it gives the following Exception. Lots of other people have seen this and there doesn't seem to be any consistency to when it occurs.

      My .ear contains a .jar that contains jms.mdb.ReplyToTest.class. All files have the correct timestamps on them.

      My MDB code is below the Exception.

      java.lang.IllegalArgumentException: Invalid ejb jar [reply-to.test.consumer-ejb-1.0-SNAPSHOT.jar]: it contains zero ejb.
      Note:
      1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean.
      2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
      3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.
      at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:72)

      package jms.mdb;

      import ...

      @Startup
      @MessageDriven(mappedName = "jms/ReplyToTestQueue", activationConfig = {
      @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
      @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue")
      })
      public class ReplyToTest implements MessageListener {

      static Logger logger = Logger.getLogger(ReplyToTest.class);
      public ReplyToTest()

      { logger.info("Ctor "); }

      @Override
      public void onMessage(Message message)

      { logger.info("Got mesage: " + message); }

      }

        Activity

        Hide
        dwschulze added a comment -

        I don't know if this is related, but when I deploy another .ear file that contains a single session bean that will be the producer for messages for the MDB in the first .ear file I get the following Exception. My SessionBean code is below the Exception.

        WARNING: PWC4011: Unable to set request character encoding to UTF-8 from context , because request parameters have already been read, or ServletRequest.getReader() has already been called
        SEVERE: The annotation symbol defined in super-class is not compatible with Session ejb ReplyToTestProducer.
        symbol: TYPE location: class services.ReplyToTestProducer

        SEVERE: Annotations processing failed for file:/C:/dean/bin/glassfish-3.0.1/glassfishv3/glassfish/domains/domain1/applications/reply-to.test.producer-ear-1.0-SNAPSHOT/reply-to.test.producer-ejb-1.0-SNAPSHOT_jar/
        INFO: Portable JNDI names for EJB ReplyToTestProducer : [java:global/reply-to.test.producer-ear-1.0-SNAPSHOT/reply-to.test.producer-ejb-1.0-SNAPSHOT/ReplyToTestProducer!services.ReplyToTestProducer, java:global/reply-to.test.producer-ear-1.0-SNAPSHOT/reply-to.test.producer-ejb-1.0-SNAPSHOT/ReplyToTestProducer]
        INFO: reply-to.test.producer-ear-1.0-SNAPSHOT was successfully deployed in 530 milliseconds.

        package services;

        import ...;

        @Singleton
        @Startup
        @Stateless
        public class ReplyToTestProducer {

        static final Logger logger = Logger.getLogger(ReplyToTestProducer.class);

        private static final String CONNECTION_FACTORY_NAME = "jms/ConnectionFactory";
        private static final String REPLY_TO_TEST_QUEUE = "jms/ReplyToTestQueue";
        private Connection connection;
        private Session session;
        // private Destination replyQueue;
        private MessageProducer requestProducer;
        // private MessageConsumer replyConsumer;
        @Resource(name = "jms/ConnectionFactory")
        private ConnectionFactory connectionFactory;
        @Resource(name = "jms/ReplyToTestQueue")
        private Queue replyToTestQueue;
        // @Resource(name="jms/Topic")
        // private static Topic topic;

        @PostConstruct
        public void setUp() {

        try

        { logger.info("Creating connection"); connection = connectionFactory.createConnection(); logger.info("Creating session"); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); requestProducer = session.createProducer(replyToTestQueue); // Enable receipt of messages on this connection // connection.start(); sendMessageWithReplyTo(); }


        catch (JMSException ex)

        { logger.error(ex); }
        }

        public void sendMessageWithReplyTo() throws JMSException { TextMessage tm = session.createTextMessage(); tm.setText("Test Message"); requestProducer.send(tm); }

        @PreDestroy
        public void tearDown() {
        try { requestProducer.close(); }
        catch (JMSException ex) { logger.error(ex); }

        }
        }

        Show
        dwschulze added a comment - I don't know if this is related, but when I deploy another .ear file that contains a single session bean that will be the producer for messages for the MDB in the first .ear file I get the following Exception. My SessionBean code is below the Exception. WARNING: PWC4011: Unable to set request character encoding to UTF-8 from context , because request parameters have already been read, or ServletRequest.getReader() has already been called SEVERE: The annotation symbol defined in super-class is not compatible with Session ejb ReplyToTestProducer. symbol: TYPE location: class services.ReplyToTestProducer SEVERE: Annotations processing failed for file:/C:/dean/bin/glassfish-3.0.1/glassfishv3/glassfish/domains/domain1/applications/reply-to.test.producer-ear-1.0-SNAPSHOT/reply-to.test.producer-ejb-1.0-SNAPSHOT_jar/ INFO: Portable JNDI names for EJB ReplyToTestProducer : [java:global/reply-to.test.producer-ear-1.0-SNAPSHOT/reply-to.test.producer-ejb-1.0-SNAPSHOT/ReplyToTestProducer!services.ReplyToTestProducer, java:global/reply-to.test.producer-ear-1.0-SNAPSHOT/reply-to.test.producer-ejb-1.0-SNAPSHOT/ReplyToTestProducer] INFO: reply-to.test.producer-ear-1.0-SNAPSHOT was successfully deployed in 530 milliseconds. package services; import ...; @Singleton @Startup @Stateless public class ReplyToTestProducer { static final Logger logger = Logger.getLogger(ReplyToTestProducer.class); private static final String CONNECTION_FACTORY_NAME = "jms/ConnectionFactory"; private static final String REPLY_TO_TEST_QUEUE = "jms/ReplyToTestQueue"; private Connection connection; private Session session; // private Destination replyQueue; private MessageProducer requestProducer; // private MessageConsumer replyConsumer; @Resource(name = "jms/ConnectionFactory") private ConnectionFactory connectionFactory; @Resource(name = "jms/ReplyToTestQueue") private Queue replyToTestQueue; // @Resource(name="jms/Topic") // private static Topic topic; @PostConstruct public void setUp() { try { logger.info("Creating connection"); connection = connectionFactory.createConnection(); logger.info("Creating session"); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); requestProducer = session.createProducer(replyToTestQueue); // Enable receipt of messages on this connection // connection.start(); sendMessageWithReplyTo(); } catch (JMSException ex) { logger.error(ex); } } public void sendMessageWithReplyTo() throws JMSException { TextMessage tm = session.createTextMessage(); tm.setText("Test Message"); requestProducer.send(tm); } @PreDestroy public void tearDown() { try { requestProducer.close(); } catch (JMSException ex) { logger.error(ex); } } }
        Hide
        Hong Zhang added a comment -

        Yes, this error could be caused by a few different things as indicated by the hints in the error message. In this case, it seems the component annotations were not processed properly (the SEVERE message from your server.log). I am not familar enough with the ejb scemantics to provide a suggested fix for you code, I will assign the bug to ejb team for them to provide some suggestions to you.

        Show
        Hong Zhang added a comment - Yes, this error could be caused by a few different things as indicated by the hints in the error message. In this case, it seems the component annotations were not processed properly (the SEVERE message from your server.log). I am not familar enough with the ejb scemantics to provide a suggested fix for you code, I will assign the bug to ejb team for them to provide some suggestions to you.
        Hide
        Cheng Fang added a comment -

        Some of the problems I noticed in your app:
        javax.ejb.Startup can only be applied to singleton session bean.

        A bean class can be annotated with @Stateless or @Singleton, but not both.

        Show
        Cheng Fang added a comment - Some of the problems I noticed in your app: javax.ejb.Startup can only be applied to singleton session bean. A bean class can be annotated with @Stateless or @Singleton, but not both.
        Hide
        Cheng Fang added a comment -

        Close it for now. If you still see the problem, please reopen with a reproducible test.

        Show
        Cheng Fang added a comment - Close it for now. If you still see the problem, please reopen with a reproducible test.
        Hide
        dwschulze added a comment -

        I moved the source code to Ubuntu 11.04 64-bit and tried it on Glassfish 3.1. The MDB worked as it was shown above. In my SessionBean I had to change the 2 @Resource parameters from "name = ..." to "mappedName = ...".

        (I have to use Glassfish 3.0.1 on 64-bit Windows 7 because Glassfish 3.1 won't run on 64-bit Windows 7: http://java.net/jira/browse/GLASSFISH-17312)

        Cheng - your comment is difficult to understand. If @Startup can only be applied to singleton SessionBeans it doesn't make any sense to say that you can't use both @Stateless and @Singleton.

        I use all 3

        @Singleton
        @Startup
        @Stateless

        and it works (at least under 64-bit Ubuntu).

        Glassfish has some serious issues on 64-bit Windows 7.

        Show
        dwschulze added a comment - I moved the source code to Ubuntu 11.04 64-bit and tried it on Glassfish 3.1. The MDB worked as it was shown above. In my SessionBean I had to change the 2 @Resource parameters from "name = ..." to "mappedName = ...". (I have to use Glassfish 3.0.1 on 64-bit Windows 7 because Glassfish 3.1 won't run on 64-bit Windows 7: http://java.net/jira/browse/GLASSFISH-17312 ) Cheng - your comment is difficult to understand. If @Startup can only be applied to singleton SessionBeans it doesn't make any sense to say that you can't use both @Stateless and @Singleton. I use all 3 @Singleton @Startup @Stateless and it works (at least under 64-bit Ubuntu). Glassfish has some serious issues on 64-bit Windows 7.
        Hide
        Cheng Fang added a comment -

        @Singleton is a type of session bean, and @Stateless is another type of session bean. You cannot annotate a bean to be both.

        @Startup in EJB 3.1 can only be used on @Singleton EJB.

        Show
        Cheng Fang added a comment - @Singleton is a type of session bean, and @Stateless is another type of session bean. You cannot annotate a bean to be both. @Startup in EJB 3.1 can only be used on @Singleton EJB.

          People

          • Assignee:
            Cheng Fang
            Reporter:
            dwschulze
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: