使用CXF遇到的一個問題

來源:互聯網
上載者:User

最近使用CXF2.1, 服務端語言是java, 中介軟體用tomcat6.0, 遇到了一個問題, 具體的異常資訊是:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OfficeService': Invocation of init method failed; nested exception is org.apache.cxf.service.factory.ServiceConstructionException

 

出現這個異常有可能是介面類的方法的引起的, 返回結果, 傳入參數的類型都會引起上面的異常.

 

一.  如果方法返回一個自訂類, 如 MyResult,

那麼,  MyResutl 必須  @XmlRootElement (還多人的例子的有提到介面要加@WebService, 但是對返回的結果就沒有提到)

@XmlRootElement
public class MyResult implements Serializable {

    .....................

}

 

如果 MyResult 類裡面也有自訂類, 那麼這個類前面也要加 @XmlRootElement. 只要是自訂類, 不過在那一層, 都要加上 @XmlRootElement.

 

二. 介面方法的參數如果是String, 沒啥問題, 但是如果其他的類, 如Long , 也是會報上述異常.

 

PS: 貌似工程裡面的jar 包中的 asm 出現衝突也會出現這個異常.

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.