2014-04-25 41 views
1

我是Seam中的新成員。我使用REST服務,在我休息服務的一個我試圖通過組件一樣獲得實例,在Component.getInstance(GateAction.class,true)上拋出的ClassCastException

GateAction gateAction = (GateAction) Component.getInstance(GateAction.class, true); 

所以這個我有錯誤java.lang.IllegalStateException:沒有應用程序上下文積極

然後來解決此我請Lifecycle.beginCall()和Lifecycle.endCall()如下面的方法,

Lifecycle.beginCall(); 
GateActionIntf gateAction = (GateActionIntf) Component.getInstance(GateActionImpl.class, true); 
Lifecycle.endCall(); 

其中GateActionIntf​​是一個接口和GateActionImpl是實現GateActionIntf​​接縫部件。但現在我得到ClassCastException。

注意:在我的web服務項目,我沒有任何component.xml文件和接縫基於配置,我剛纔說的jboss-縫罐子

這有可能獲得實例那樣,沒有任何component.xml和接縫配置?再次強調我得到的實例,但類型轉換拋出ClassCastException。如何解決這個問題?

回答

0

給下面的一個嘗試:

GateActionIntf gateAction = (GateActionImpl) Component.getInstance(GateActionImpl.class, true); 
+0

嘗試,但沒有運氣... –

相關問題