问题描述
我正在尝试使用apache-cxf Web服务在Liferay-7 portlet中,我在linux环境中遇到以下错误。
I am trying to consume apache-cxf Web Services In Liferay-7 portlet ,I got the following error in linux environment.
13:39:14,374 ERROR [ http-nio-4080-exec-9] [status_jsp:950] com.liferay.portal.kernel.portlet.PortletContainerException:com.liferay.portal.kernel.portlet.PortletContainerException:javax.servlet.ServletException:java.lang.LinkageError :com / sun / org / apache / xpath / internal / jaxp / XPathImpl
13:39:14,374 ERROR [http-nio-4080-exec-9][status_jsp:950] com.liferay.portal.kernel.portlet.PortletContainerException: com.liferay.portal.kernel.portlet.PortletContainerException: javax.servlet.ServletException: java.lang.LinkageError: com/sun/org/apache/xpath/internal/jaxp/XPathImpl
如果我在liferay 7 windows环境中运行相同的portlet它运行正常
If I run the same portlet in liferay 7 windows environment it is working fine
以下是示例jsp代码(view.jsp)
And here is the sample jsp code (view.jsp)
<portlet:defineObjects />
<%@ page import="org.apache.cxf.endpoint.Client" %>
<%@ page import="org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%
String endpoint="http://*******/***-ws/soap/login?wsdl";
String method ="login";
String uname ="admin";
String pwd = "admin";
String result = "";
Object[] params = new Object[2] ;
params[0] = (Object)uname;
params[1] = (Object)pwd;
result = call(endpoint, method, params);
System.out.println("Result : "+result);
%>
<%!
public static String call(String endpoint, String method, Object[] params) {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
try {
Client client = dcf.createClient(endpoint);
System.out.println("Client Object Create successfully :");
Object[] returnVals = client.invoke(method, params);
//extract returned value. getting 1st value as sakai ws calls returns only one value.
if(returnVals!=null && returnVals.length>0)
return (String)returnVals[0];
}
catch (Exception e) {
e.printStackTrace();
System.out.println("A connection error occurred: " + e.getClass() + ": " + e.getMessage());
}
return null;
}
%>
问题发生在
客户端客户端= dcf.createClient(端点) ;
以下是我们使用的依赖项
Here is the dependencies we are using
======== ======================
==============================
cxf-core-3.1.8.jar
cxf-core-3.1.8.jar
cxf-rt-bindings-soap-3.1.8.jar
cxf-rt-bindings-soap-3.1.8.jar
cxf-rt-databinding-jaxb-3.1.8 .jar
cxf-rt-databinding-jaxb-3.1.8.jar
cxf-rt-frontend-jaxws-3.1.8.jar
cxf-rt-frontend-jaxws-3.1.8.jar
cxf-rt-frontend -simple-3.1.8.jar
cxf-rt-frontend-simple-3.1.8.jar
cxf-rt-transports-http-3.1.8.jar
cxf-rt-transports-http-3.1.8.jar
cxf-rt-wsdl-3.1.8.jar
cxf-rt-wsdl-3.1.8.jar
neethi-3.0.3.jar
neethi-3.0.3.jar
= =============================
==============================
我已签入的相同代码Liferay 6.2及其在windows和linux环境下的工作正常,但我添加了一些jar文件。
Same Code I have checked in Liferay 6.2 and its working fine in both windows and linux environment, but I have added some more jar files.
============= =================
==============================
cxf-rt-bindings-xml-3.1.8.jar
cxf-rt-bindings-xml-3.1.8.jar
cxf-rt-ws-addr-3.1.8.jar
cxf-rt-ws-addr-3.1.8.jar
cxf-rt-ws-policy-3.1.8。 jar
cxf-rt-ws-policy-3.1.8.jar
jaxb-impl-2.2.11.jar
jaxb-impl-2.2.11.jar
jaxb-core-2.2.11.jar
jaxb-core-2.2.11.jar
xmlschema-core-2.2.1.jar
xmlschema-core-2.2.1.jar
stax2-api-3.1.4.jar
stax2-api-3.1.4.jar
woodstox-core-asl-4.4.1.jar
woodstox-core-asl-4.4.1.jar
wsdl4j-1.6.3.jar
wsdl4j-1.6.3.jar
==============================
==============================
请帮帮我。
谢谢&问候,
P.V.B.Raju。
P.V.B.Raju.
推荐答案
我的方法不同。我在Liferay实例上安装了必要的Apache CXF模块作为OSGi包,之后我使用导出到OSGi容器的CXF API构建了一个简单的WS客户端。作为OSGIi包安装的Apache CXF模块。
My approach was different. I installed the necessary Apache CXF modules as an OSGi bundle on the Liferay instance, after which I built a simple WS client using the CXF APIs exported to the OSGi container. Apache CXF modules installed as OSGIi bundle.
- Apache XmlSchema Core(v.2.2.1)
- Apache CXF Core
- Apache CXF运行时JAXB数据绑定
- Apache CXF运行时XML绑定
- Apache CXF运行时SOAP绑定
- 用于WSDL的Apache CXF运行时核心
- Apache CXF运行时简单前端
- Apache CXF运行时JAX -WS前端
- Apache CXF运行时HTTP传输
- Apache XmlSchema Core (v. 2.2.1)
- Apache CXF Core
- Apache CXF Runtime JAXB DataBinding
- Apache CXF Runtime XML Binding
- Apache CXF Runtime SOAP Binding
- Apache CXF Runtime Core for WSDL
- Apache CXF Runtime Simple Frontend
- Apache CXF Runtime JAX-WS Frontend
- Apache CXF Runtime HTTP Transport
安装九个元素Apache CXF框架可以通过telnet连接到Apache Felix GoGo Shell来执行。 Liferay 7门户运行后,可以通过执行命令安装Apache CXF框架安装$ URL_CXF_BUNDLE
The installation of the nine elements of the Apache CXF framework can be performed by connecting via telnet to the Apache Felix GoGo Shell. Once the Liferay 7 portal is running, the Apache CXF framework can be installed by executing the commands install $URL_CXF_BUNDLE
有关详细信息,请阅读本文
For more information you can read this article Liferay 7: Come realizzare un client SOAP con Apache CXF in OSGi Style
这篇关于在Liferay 7中使用apache-cxf Web服务时出现链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!