Search code examples
javamessage-driven-beanopenejb

Tell OpenEJB to ignore MDB


I wrote an unit-test for an activity which finally puts a message into a queue. As soon as a message is put into that queue, a message driven bean starts processing. But I don't want to test MDBs in a unit test. How can I tell OpenEJB to ignore them?

I set up OpenEJB with several properties:

    p.setProperty(Context.INITIAL_CONTEXT_FACTORY,
            "org.apache.openejb.client.LocalInitialContextFactory");
    p.setProperty("openejb.deployments.classpath.include", ".*");
    p.setProperty("openejb.localcopy", "false");

    // Messaging
    p.put("MyJmsResourceAdapter",
            "new://Resource?type=ActiveMQResourceAdapter");
    // Do not start the ActiveMQ broker
    p.put("MyJmsResourceAdapter.BrokerXmlConfig", "");
    p.put("MyJmsConnectionFactory",
            "new://Resource?type=javax.jms.ConnectionFactory");
    p.put("MyJmsConnectionFactory.ResourceAdapter", "MyJmsResourceAdapter");
    p.put("queue/MyQueue",
            "new://Resource?type=javax.jms.Queue");

I know I must set openejb.deployments.classpath.exclude, but I can't figure out the right value:

    p.setProperty("openejb.deployments.classpath.exclude", "org.example.mdb.*");

For example my class is named org.example.mdb.MyMDB.


Solution

  • just my 2 cents:

    • try ".*org/example/mdb.*" or ".*org.example.mdb.*"
    • from Loading Deployments from the Classpath:

      Note by default these settings will only affect which jars OpenEJB will scan for annotated components when no descriptor is found. If you would like to use these settings to also filter out jars that do contain descriptors, set the

      openejb.deployments.classpath.filter.descriptors

      property to true. The default is false