【问题标题】:EJB - EJBTransactionRolledbackException argument type mismatch - overloaded methodEJB - EJBTransactionRolledbackException 参数类型不匹配 - 重载方法
【发布时间】:2023-03-06 16:52:01
【问题描述】:

我真的需要帮助!通过调用具有方法重载的 EJB,我遇到了以下异常:javax.ejb.EJBTransactionRolledbackException: argument type mismatch

有趣的是,这种情况是随机发生的,并且只在这个重载的方法中发生。看下面的结构:

// superclass
public abstract class GenericService<T> {

    public void update(T object) throws Exception {
        // some logic
    }

}

// subclass
@Stateless
public class TableService extends GenericService<Table> implements ITableService {

    @Override
    public void update(Table table) throws Exception {
        /*
         * some logic
         */

        // call super
        super.update(table);
    }
}

如果我调用包含 super.update(table) 语句的 TableService.update,则会发生错误。但是,如果我从 TableService.update 中删除 super.update(table) 语句,直接调用 DAO(跳过 super),它就可以工作.

更糟糕的是,这种情况并不经常发生。只有当我有时重新启动 jboss wildfly 时。

显然没有任何问题,应该完全包含 super.update(table) 语句。你能帮忙吗?

【问题讨论】:

    标签: ejb jboss7.x ejb-3.0 illegalstateexception wildfly-8


    【解决方案1】:

    由容器 (JBOSS) 提供的 EJB 代理传递对象类型为相应方法的参数。 因此,如果存在重载方法,则代理可能无法解析要调用的方法

        @Stateless
    public class TableService extends GenericService<Table> implements ITableService {
    
        @Override
        public void update(Table table) throws Exception {
            /*
             * some logic
             */
    
            // call super
            super.update(table);
        }
    
        @Override
        public void update(List<Table> table) throws Exception {
            /*
             * some logic
             */
    
            // call super
            super.update(table);
        }
    }
    

    proxy.update(Object obj)... 参数类型不匹配

    【讨论】:

    • 我不知道为什么 jboss 会这样做,但我认为你是对的。在这种情况下,我只是重命名了该方法。谢谢!
    猜你喜欢
    • 2016-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 1970-01-01
    相关资源
    最近更新 更多