我尝试使用SearchFacade.java
的远程界面保存搜索结果时收到以下错误
"Failed to marshal EJB parameters"
无法设置org.apache.commons.collections.FastHashMap字段 org.apache.commons.validator.Field.hMsgs to org.apache.commons.collections.FastHashMap at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) 在
我使用struts 1.1,EJB 2.1使用xdoclet 1.2.3 jar生成依赖文件。(这是不可避免的使用),我的Local,Home接口是使用Xdoclet生成的。
我也在我的项目中使用Java 6,Jboss EAP 6.1 Alpha。
注意:在Jboss 4.0中运行时,相同的代码可以正常工作
很奇怪我的远程通话是否正确。
欢迎任何帮助。
错误记录
java.lang.RuntimeException:JBAS014154:无法在org.jboss.as.ejb3.remote.LocalEjbReceiver上的org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:270)封送EJB参数。克隆(LocalEjbReceiver.java:259)在org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:170)在org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)在组织.gboss.ejb.client.EJBHomeCreateInterceptor.handleInvocation(EJBHomeCreateInterceptor.java:79)org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183)org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor)的.java:42)在org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183)在org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:125)在org.jboss.ejb中。 client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.j AVA:183)在org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:177)在org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:161)在org.jboss.ejb.client位于com.web.history.SearchFormDelegate.saveSearch(SearchFormDelegate.java:177)的$ Proxy25.saveSearch(未知来源)的.EJBInvocationHandler.invoke(EJBInvocationHandler.java:124)位于com.history.SaveSearchAction.createNewSavedSearch(SaveSearchAction.java: 109)在com.history.SaveSearchAction.executeSynchronized(SaveSearchAction.java:296)在com.dispatch.SynchronizedAction.execute(SynchronizedAction.java:206)在org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431 )org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)at org.apache.struts.action.ActionServlet。 doPost(ActionServlet.java:432)位于ja的javax.servlet.http.HttpServlet.service(HttpServlet.java:754)位于org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)的vax.servlet.http.HttpServlet.service(HttpServlet.java:847)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain。 java:214)at com.security.AuthenticationFilter.doFilter(AuthenticationFilter.java:672)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:214)在com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:270)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)的组织。 apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)位于org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve。 java:149)在org.jbos s.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)在org.apache.catalina.valves.ErrorReportValve.invoke( ErrorReportValve.java:97)在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)在org.apache.coyote .http11.Http11Processor.process(Http11Processor.java:856)在org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:653)在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run (JIoEndpoint.java:920)java.lang.Thread.run(Thread.java:662)引起:java.lang.IllegalArgumentException:无法设置org.apache.commons.collections.FastHashMap字段org.apache.commons。验证器.Field.hMsgs到org.apache.commons.collections.FastHashMap at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAcce ssorImpl.java:146)在sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)at java.lang.reflect.Field.set(Field.java) :657)在org.jboss.marshalling.cloner.SerializingCloner.storeFields(SerializingCloner.java:368)在org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:313)在org.jboss.marshalling.cloner。 SerializingCloner.clone(SerializingCloner.java:253)在org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134)在org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348)在组织.gboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309)atg.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253)org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner) .java:134)org.jboss.marshalling .cloner.SerializingCloner $ StepObjectInput.doReadObject(SerializingCloner.java:836)在org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)在org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:57)在位于sun.reflect.DelegatingMethodAccessorImpl.invoke的sun.reflect.GeneratedMethodAccessor119.invoke(未知来源)的java.util.HashMap.readObject(HashMap.java:1030)中的java.io.ObjectInputStream.readObject(ObjectInputStream.java:344) DelegatingMethodAccessorImpl.java:25)在org.jboss.marshalling.cloner的org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:218)的java.lang.reflect.Method.invoke(Method.java:597) .SerializingCloner.initSerializableClone(SerializingCloner.java:302)在org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253)在org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134)在org.jboss.marshalling.cloner.Seri alizingCloner.cloneFields(SerializingCloner.java:348)在org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309)在org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253)在组织.gboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134)org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348)org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner)的.java:309)在org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:285)在org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:253)在org.jboss.marshalling。 cloner.SerializingCloner.clone(SerializingCloner.java:134)在org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348)在org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309)在org.jboss.marshalling.clone r.SerializingCloner.clone(SerializingCloner.java:253)在org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134)在org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java: 268)......还有42个
代码:
saveAction.java
protected void newSavedSearch(final SrchFrmDelegate sfd,
final String userId, final HttpServletRequest request,
final SaveSearchForm form) throws RemoteException,
UsrNotFoundException {
BseSrchValue srchValue = SrchResultsAction.retrieveSrchCriteria(request);
FrmLayout frmLayout = (FrmLayout) request.getSession().getAttribute(
FrmBuilderAction.FRM_LAYOUT_KEY);
Integer resultCount = null;
SrchResultValue srchResult = SearchResultsAction.retrieveSearchResults(request);
if (srchResult != null) {
resultCount = new Integer(srchResult.getTotal());
}
sfd.saveSearch(userGuid,
form.getTitle(),
form.getDesc(),
form.getNewTtle(),
srchValue,
frmLayout,
resultCount,
form.getSearches());
}
SrchFrmDelegate.java
/**
* Reference to the remote interface.
*/
private SrhFrmFacadeRemote srhFacadeRemote;
public String saveSearch(final String userId, final String srchTtle,
final String srchDesc, final Boolean newTtle,
final BsSearchValue srchValue, final FrmLay frmLay,
final Integer resultCount, final List alerts)
throws UsrNotFoundException,
RemoteException {
return srhFacadeRemote.saveSearch(userId, srchTtle,
srchDesc, newTtle, srchValue, frmLay,
resultCount, alerts);
}
SrchFrmFacadeRemote.java
/**
* Remote interface for SrchFrmFacade.
*/
public java.lang.String saveSearch( java.lang.String userId,java.lang.String srchTtle,java.lang.String srchDesc,java.lang.Boolean newTtle,com.common.search.BsSearchValue srchValue,com.common.search.advanced.FrmLay frmLay,java.lang.Integer resultCount,java.util.List alerts ) throws com.common.admin.UserNotFoundException, java.rmi.RemoteException;
答案 0 :(得分:3)
作为参数传递的对象或远程调用的响应必须是Serializable。
例如: -
Item
|> order_by([desc: :start])
|> where([active: true])
答案 1 :(得分:2)
在Jboss 7模块中加入以下罐子&相应地改变standalone.xml文件,问题是固定的。
的JBoss-EAP-6.1.0.Alpha \模块\ SYSTEM \层\基\组织\阿帕奇\公地\验证 公地验证-1.1.0.jar
jboss-eap-6.1.0.Alpha \ modules \ system \ layers \ base \ org \ apache \ commons \ collections commons-collections-3.2.1.jar
在Standalone.xml中
<subsystem xmlns="urn:jboss:domain:ee:1.1">
<spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
<global-modules>
<module name="org.apache.commons.collections" slot="main"/>
<module name="org.apache.commons.validator" slot="main"/>
</global-modules>
</subsystem>
答案 2 :(得分:1)
在EJB3中,当在EJB的@Remote
视图中调用EJB会话Bean时,也会发生此错误。根据设计和使用方案,您可以通过@Local
接口调用EJB。使用@Local
接口将消除对参数Serializable
的要求,但这可能会显着改变您的设计。如果您使用@Local
视图是一个选项,则只需将@Local
添加到EJB而不删除@Remote
。
答案 3 :(得分:0)
请记住添加serialVersionUID,以使类得以序列化和还原(将其生成为getter或setter)
答案 4 :(得分:0)
对于这个问题,首先,您必须在POJO类(java bean)中实现Serializable接口,如下所示:
package com.test;
import java.io.Serializable;
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
private int empID;
private String empName;
private int empSalary;
public int getEmpID() {
return empID;
}
//alt_shift_s_r-getter and setter method
//alt_shift_s_s override toString()
public void setEmpID(int empID) {
this.empID = empID;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public int getEmpSalary() {
return empSalary;
}
public void setEmpSalary(int empSalary) {
this.empSalary = empSalary;
}
@Override
public String toString() {
return "Employee [empID=" + empID + ", empName=" + empName + ", empSalary=" + empSalary + "]";
}
}
注意:如果要在项目中添加一些外部jar,请按照以下步骤添加jar。
现在从所需位置添加广口瓶,然后完成该过程。
enter code here