我正在使用JBoss 6.0.2进行eclipse。 我将一些EJB作为Web服务公开,并且成功。
但是在我想揭露的最后一个Ejb上,当我在JBoss上部署我的应用程序时,我收到了这个错误:
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
com.upsilon.beans.pfselection.SelectionCriterium is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at com.upsilon.beans.pfselection.SelectionCriterium
at private java.util.ArrayList com.upsilon.beans.pfselection.SelectionCriteria.criteria
at com.upsilon.beans.pfselection.SelectionCriteria
at private java.util.ArrayList com.upsilon.beans.client.jaxws_asm.GetPortfolios.arg2
at com.upsilon.beans.client.jaxws_asm.GetPortfolios
com.upsilon.beans.pfselection.SelectionCriterium does not have a no-arg default constructor.
this problem is related to the following location:
at com.upsilon.beans.pfselection.SelectionCriterium
at private java.util.ArrayList com.upsilon.beans.pfselection.SelectionCriteria.criteria
at com.upsilon.beans.pfselection.SelectionCriteria
at private java.util.ArrayList com.upsilon.beans.client.jaxws_asm.GetPortfolios.arg2
at com.upsilon.beans.client.jaxws_asm.GetPortfolios
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:466)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:298)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1157)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_51]
这是我的界面:
public interface SelectionCriterium //extends Serializable
{
}
这是我的SelectionCriteria类
public class SelectionCriteria //implements Serializable
{
private ArrayList<SelectionCriterium> criteria = new ArrayList<SelectionCriterium>( );
public SelectionCriteria(){}
public SelectionCriteria( ArrayList<SelectionCriterium> criteria )
{
this.criteria = criteria;
}
/*public SelectionCriteria( )
{
criteria = new ArrayList<SelectionCriterium>( );
}*/
public ArrayList<SelectionCriterium> getCriteria( )
{
return criteria;
}
public void setCriteria( ArrayList<SelectionCriterium> criteria )
{
this.criteria = criteria;
}
public void addCriterium( SelectionCriterium criterium )
{
criteria.add( criterium );
}
}
我尝试使用Xml注释,但它不起作用:/
如果有人有想法?非常感谢(对不起我的英语)
答案 0 :(得分:0)
如果您有一个作为接口类型的映射字段/属性,则需要使用@XmlElement
注释来指定实现类型。
@XmlElement(type=SelectionCriteriumImpl.class)
public ArrayList<SelectionCriterium> getCriteria( )
{
return criteria;
}
其他信息
您可以在我的博客上找到有关此用例的更多信息: