WAS Liberty - EJB - bean does not have a public co

2019-07-27 02:11发布

I am experiencing issue when migrating from WAS 7.0 to WAS Liberty Base. I have deployed EAR file in WAS Liberty Base. When I add the mdb-3.2 to server.xml for JMS Messaging, I get the following run-time error on EJB MDB Bean.

[ERROR   ] CNTR5007E: The com.companyname.appname.AdminMDBBean bean class for the AppEAR#AppEJB.jar#AdminMDBBean bean does not have a public constructor that does not take parameters.
[ERROR   ] CNTR4002E: The AppEJB.jar EJB module in the AppEAR application failed to start. Exception: com.ibm.ws.exception.RuntimeError: com.ibm.ejs.container.EJBConfigurationException: EJB class com.companyname.appname.AdminMDBBean must have a public constructor that takes no parameters : AppEAR#AppEJB.jar#AdminMDBBean
    at com.ibm.ws.ejbcontainer.runtime.AbstractEJBRuntime.startModule(AbstractEJBRuntime.java:641)
    at [internal classes]
Caused by: com.ibm.ejs.container.EJBConfigurationException: EJB class com.companyname.appname.AdminMDBBean must have a public constructor that takes no parameters : AppEAR#AppEJB.jar#AdminMDBBean
    at com.ibm.ws.ejbcontainer.jitdeploy.EJBUtils.validateEjbClass(EJBUtils.java:350)
    ... 1 more
Caused by: java.lang.NoClassDefFoundError: com.companyname.appname.domain.HealthMonitorMessage
    at java.lang.J9VMInternals.prepareClassImpl(Native Method)
    at java.lang.J9VMInternals.prepare(J9VMInternals.java:291)
    at java.lang.Class.getConstructor(Class.java:531)
    at com.ibm.ws.ejbcontainer.jitdeploy.EJBUtils.validateEjbClass(EJBUtils.java:341)
    ... 1 more

Server.xml

<server description="new server">
    <featureManager>
        <feature>jsp-2.3</feature>
        <feature>adminCenter-1.0</feature>
        <feature>jdbc-4.1</feature>
        <feature>jndi-1.0</feature>
        <feature>wasJmsServer-1.0</feature>
        <feature>wasJmsClient-2.0</feature>
        <feature>mdb-3.2</feature>
    </featureManager>

AdminMDBBean.Java

@MessageDriven(name = "AdminMDBBean", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class AdminMDBBean implements MessageListener {
    private Logger logger;
    public AdminMDBBean()
    {
        logger = Logger.getLogger(this.getClass().getName());
    }

    /**
     * Method to receive and process the messages from the queue.
     */

public void onMessage(Message message) {....}

1条回答
Melony?
2楼-- · 2019-07-27 02:48

This issue solved. The Solution provided here Maven EJB packaging with dependent libraries

This is working by adding

 <defaultLibBundleDir>lib</defaultLibBundleDir>

to the EAR POM.XML

Thanks.

查看更多
登录 后发表回答