程序分为dao、Service、XFire层,不用XFire层时程序测试通过,加上XFire后,出现如下异常
,疑为XFire不支持类的泛型。
异常 代码
- Exception in thread "Thread-2" org.codehaus.xfire.XFireRuntimeException: Couldn't write stream.. Nested exception is org.codehaus.xfire.XFireRuntimeException: Couldn't get property {http://lang.java}classes from bean class cn.cetelem.accounting.model.CsiAcctPmtHistory. Nested exception is java.lang.reflect.InvocationTargetException: null
- org.codehaus.xfire.XFireRuntimeException: Couldn't get property {http://lang.java}classes from bean class cn.cetelem.accounting.model.CsiAcctPmtHistory. Nested exception is java.lang.reflect.InvocationTargetException: null
- java.lang.reflect.InvocationTargetException
- at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
- at java.lang.reflect.Method.invoke(Unknown Source)
- at org.codehaus.xfire.aegis.type.basic.BeanType.readProperty(BeanType.java:467)
- ……
- ……
- Caused by: java.lang.StackOverflowError
- at java.security.AccessController.doPrivileged(Native Method)
- at java.lang.Class.getClasses(Unknown Source)
- at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
- at java.lang.reflect.Method.invoke(Unknown Source)
- at org.codehaus.xfire.aegis.type.basic.BeanType.readProperty(BeanType.java:467)
- at org.codehaus.xfire.aegis.type.basic.BeanType.writeObject(BeanType.java:402)
- at org.codehaus.xfire.aegis.type.basic.BeanType.writeObject(BeanType.java:417)
- …………
- …………
- at org.codehaus.xfire.aegis.type.basic.BeanType.writeObject(BeanType.java:417)
- 2007-10-15 21:31:14,953 ERROR [org.codehaus.xfire.service.binding.PostInvocationHandler] -
- 2007-10-15 21:31:14,953 ERROR [org.codehaus.xfire.handler.DefaultFaultHandler] -
- org.codehaus.xfire.XFireRuntimeException: Couldn't read stream.. Nested exception is com.ctc.wstx.exc.WstxIOException: Write end dead
- com.ctc.wstx.exc.WstxIOException: Write end dead
- at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:650)
- at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1071)
- at org.codehaus.xfire.transport.local.LocalChannel.sendViaNewChannel(LocalChannel.java:175)
- at org.codehaus.xfire.transport.local.LocalChannel.send(LocalChannel.java:75)
- at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
- …………
- …………
关键问题出在Page对象。
java 代码
- public class Page<T><t></t><t></t> implements Serializable {
- private Class<T><t></t><t></t> entityClass;
- /**
- * long:serialVersionUID
- */
- private static final long serialVersionUID = -5732135470845307885L;
- public static int DEFAULT_PAGE_SIZE = 10;
- private int pageSize = DEFAULT_PAGE_SIZE; // records per page
- private int start; // the location of the first record of list in curren
- private List<T><t></t><t></t> list; // records in current page
- private int totalCount; // total records
- private int currentPageNo;
- private int totalPageCount;
- /**
- * @return Returns the entityClass.
- */
- public Class<T><t></t><t></t> getEntityClass() {
- return this.entityClass;
- }
- /**
- * @param entityClass
- * The entityClass to set.
- */
- public void setEntityClass(Class<T><t></t><t></t> entityClass) {
- this.entityClass = entityClass;
- }
- /**
- * construct method by default.
- *
- * @param start
- * the location of the first record of list in current page ,
- * starting form 0.
- * @param totalSize
- * total pages
- * @param pageSize
- * records per page
- * @param list
- * records in current page
- */
- public Page(int start, int totalSize, int pageSize, List<T><t></t><t></t> list,
- Class<T><t></t><t></t> entityClass) {
- this.entityClass = entityClass;
- System.out.println("Page.getEntityClass()=" + entityClass.getName());
- this.pageSize = pageSize;
- this.start = start;
- this.totalCount = totalSize;
- this.list = list;
- }
- /**
- * Get total records.
- */
- public int getTotalCount() {
- return this.totalCount;
- }
- /**
- * Get total pages.
- */
- public int getTotalPageCount() {
- if (totalCount % pageSize == 0)
- totalPageCount = totalCount / pageSize;
- else
- totalPageCount = totalCount / pageSize + 1;
- return totalPageCount;
- }
- /**
- * Get records per page.
- */
- public int getPageSize() {
- return pageSize;
- }
- /**
- * Get records in current page.
- */
- public List<T><t></t><t></t> getList() {
- return list;
- }
- /**
- * Get current page number,starting from 1.
- */
- public int getCurrentPageNo() {
- currentPageNo = start / pageSize + 1;
- return currentPageNo;
- }
- /**
- * Judge whether there is next page.
- */
- public boolean hasNextPage() {
- return this.getCurrentPageNo() < this.getTotalPageCount() - 1;
- }
- /**
- * Judge whether there is pre page.
- */
- public boolean hasPreviousPage() {
- return this.getCurrentPageNo() > 1;
- }
- /**
- * Get the location of the first record of list in any page. It use default
- * value of records per page.
- *
- * @see #getStartOfPage(int,int)
- */
- protected static int getStartOfPage(int pageNo) {
- return getStartOfPage(pageNo, DEFAULT_PAGE_SIZE);
- }
- /**
- * Get the location of the first record of list in any page.
- *
- * @param pageNo
- * starting from 1.
- * @param pageSize
- * records per pages.
- * @return the first record in the page.
- */
- public static int getStartOfPage(int pageNo, int pageSize) {
- return (pageNo - 1) * pageSize;
- }
- /**
- * @return Returns the start.
- */
- public int getStart() {
- return this.start;
- }
- /**
- * @param start
- * The start to set.
- */
- public void setStart(int start) {
- this.start = start;
- }
- /**
- * @param pageSize
- * The pageSize to set.
- */
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
- /**
- * @param list
- * The list to set.
- */
- public void setList(List<T><t></t><t></t> list) {
- this.list = list;
- }
- /**
- * @param totalCount
- * The totalCount to set.
- */
- public void setTotalCount(int totalCount) {
- this.totalCount = totalCount;
- }
- /**
- * @param currentPageNo
- * The currentPageNo to set.
- */
- public void setCurrentPageNo(int currentPageNo) {
- this.currentPageNo = currentPageNo;
- }
- /**
- * @param totalPageCount The totalPageCount to set.
- */
- public void setTotalPageCount(int totalPageCount) {
- this.totalPageCount = totalPageCount;
- }
- }
如果为Page对象加上aegis则程序正常运行。
Page.aegis.xml
- xml version="1.0" encoding="UTF-8"?>
- <mappings xmlns:my="http://my.bjvsp.tongtech.com">
- <mapping name="my:User">
- <property name="list"
- componentType="cn.cetelem.accounting.model.CsiAcctPmtHistory" />
- mapping>
- mappings>
XFire的版本,我试过1.2.2和1.2.6。 搞了一天,还没找到答案
PS -- 在codehaus上也找到类似的: jira.codehaus.org/browse/XFIRE-1002