本文介绍了WAS Liberty - EJB - bean没有不带参数的公共构造函数& java.lang.NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从WAS 7.0迁移到WAS Liberty Base时遇到问题。我在WAS Liberty Base中部署了EAR文件。当我将mdb-3.2添加到server.xml以进行JMS消息传递时,我在EJB MDB Bean上收到以下运行时错误。

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.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

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) {....}


推荐答案

这个问题解决了。此处提供的解决方案

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

这是通过添加

 <defaultLibBundleDir>lib</defaultLibBundleDir>

到EAR POM.XML

to the EAR POM.XML

谢谢。

这篇关于WAS Liberty - EJB - bean没有不带参数的公共构造函数&amp; java.lang.NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 01:12