无法编组 EJB 参数?

Posted

技术标签:

【中文标题】无法编组 EJB 参数?【英文标题】:Failed to marshal EJB parameters? 【发布时间】:2021-04-12 03:36:37 【问题描述】:

我向EJB3 添加了一个新方法,但出现以下错误。我知道这是由于可序列化问题,但我无法更改对象,因为它来自外部库 org.apache.commons.beanutils

此外,我使用 Wildfly 11 作为服务器,使用 Vaadin 18 和 java 8。

有什么解决方法吗?

java.lang.RuntimeException: WFLYEJB0054: Failed to marshal EJB parameters
at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:385)
at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:365)
at org.jboss.as.ejb3.remote.LocalEjbReceiver$CloningResultProducer.getResult(LocalEjbReceiver.java:304)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:567)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
at org.jboss.ejb.protocol.remote.RemotingEJBClientInterceptor.handleInvocationResult(RemotingEJBClientInterceptor.java:56)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
at org.jboss.ejb.client.TransactionPostDiscoveryInterceptor.handleInvocationResult(TransactionPostDiscoveryInterceptor.java:133)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
at org.jboss.ejb.client.DiscoveryEJBClientInterceptor.handleInvocationResult(DiscoveryEJBClientInterceptor.java:118)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
at org.jboss.ejb.client.NamingEJBClientInterceptor.handleInvocationResult(NamingEJBClientInterceptor.java:78)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:172)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:907)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:165)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:100)
at com.sun.proxy.$Proxy155.findRecordsInTable(Unknown Source)

EJB

@Stateless
@Remote(QueriesRemote.class)
@org.jboss.ejb3.annotation.TransactionTimeout(value = 20, unit = TimeUnit.MINUTES)
public class Queries extends Base implements QueriesRemote

    @PersistenceContext
    private EntityManager manager;
    
    @Resource(mappedName="java:/TedingDS")
    private javax.sql.DataSource db;

    @Resource
    SessionContext ctx;
    

    
    public List<DynaBean> findRecordsInTable(String querySource)
        List<DynaBean> beanList = Collections.EMPTY_LIST;

        try (ResultSet myResult = db.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY).executeQuery(querySource)) 
            RowSetDynaClass rsdc = new RowSetDynaClass(myResult, false);
            beanList =  rsdc.getRows();
            closeAllViaResultSet(myResult);
         catch (SQLException e) 
            logger.log(Level.SEVERE, "From class:".concat(this.getClass().getName()));
        

        return beanList;
    


我怎么称呼它

@Route(value = QueriesView.ROUTE, layout = MainLayout.class)
@PageTitle(QueriesView.TITLE)
public class QueriesView extends VerticalLayout implements BeforeEnterObserver, BeforeLeaveObserver, AfterNavigationObserver, LocaleChangeObserver, HasUrlParameter<String> 
    private final Logger LOGGER = Logger.getLogger(this.getClass().getName());
    public static final String ROUTE = "queryView";
    public static final String TITLE = "Query";


        @EJB
        public QueriesRemote remote;

        public QueriesView() 

    @Override
    public void beforeEnter(BeforeEnterEvent beforeEnterEvent) 
        LOGGER.info("beforeEnter queryView");
        if(remote == null)
            Notification.show("beforeEnter remote == null");
        else 
            List<DynaBean> list = remote.findRecordsInTable("select * from attached limit 5");
            Notification.show("Size beforeEnter:".concat(String.valueOf(list.size())), 5000, Notification.Position.MIDDLE);
        
    


【问题讨论】:

vaadin 应用程序和 EJB 是否在同一台服务器上?如果是,您可以使用@Local 接口而不是@Remote 【参考方案1】:

感谢@areus

我只是使用@Local接口而不是@Remote

【讨论】:

以上是关于无法编组 EJB 参数?的主要内容,如果未能解决你的问题,请参考以下文章

RPC调用的参数编组协议作业?

编组变量参数 - __arglist 或替代

C# 将 char* 编组到 StringBuilder 总是得到空字符串

从 C# 到 C++ 的编组

通过 P/Invoke 将 MFC CArray 编组为 C#

将非 Blittable 结构从 C# 编组到 C++