首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

liferay axis 外部WebService调用变换ClassCastExcep

2012-08-14 
liferay axis 外部WebService调用转换ClassCastExcepWhen some code within a portlet consumes non-Lifer

liferay axis 外部WebService调用转换ClassCastExcep

When some code within a portlet consumes non-Liferay web services with the help of the AXIS package, an unexpected error happens.
This error is related to the invocation of the com.liferay.util.axis.SimpleHTTPSender.

The same code will not produce this error if it is running outside of the Liferay portlet environment.

The cause of the error is a silent assumption that every call to AXIS is about Liferay services and in this case com.liferay.util.axis.SimpleHTTPSender knows what to do.
But in the situation when the AXIS is used to consume non-Liferay web services, this invocation is wrong.

The workaround:
open a jar file: tomcat/webapps/ROOT/WEB-INF/lib/util-java.jar
delete from this jar: client-config.wsdd
(In this file there is a line that instructs to invoke the SimpleHTTPSender)
save this jar back as: tomcat/webapps/ROOT/WEB-INF/lib/util-java.jar

Check if this util-java.jar file is included in the YourPortlet/WEB-INF/lib
If so, do the same thing. (Be aware that util-java.jar is created in each build)

Although the problem has surfaced many times without good explanation, there is at least one place where it was described: http://issues.liferay.com/browse/LEP-1190, August 26, 2006 by Javier Cámara.

Thank you, Javier!
----------------------------
If you expected that this is it... you are almost right. One more thing: working with web services within the web application causes more than one ClassLoader to work on jars. Duplication of the axis.jar (one is in the portlet/WEB-INF/lib and another is in the tomcat/webapps/ROOT/WEB-INF/lib) tricks the Class Loaders into the Exception:

ClassCastException: org.apache.axis.attachments.AttachmentsImpl cannot be cast to org.apache.axis.attachments.Attachments

Delete this one: tomcat/webapps/ROOT/WEB-INF/lib/axis.jar
-----------------------------
Soon after solving this one I found out the message by Raj K. with the same solution: http://www.liferay.com/community/forums/-/message_boards/message/5677416

Thank you, Raj!

Jeff (Yefim)

?

?

?

?

?

?

?

?

kennzeichnen

s

?

?

热点排行