我的liferay portlet jsonws无法从远程位置访问,但我可以使用localhost访问它
example [http://localhost:8050/MySite-portlet/api/secure/jsonws] is accesible on the lacal machine
but when i try to access it remotely using the external ip e.g
[http://120.23.223.24:8050/MySite-portlet/api/secure/jsonws] its returning me the Connection refused error
但是[http://120.23.223.24:8050/api/jsonws]
和[http://120.23.223.24:8050/web/MySite]
正在运作
我的portal-ext.properties文件包含以下条目
open.id.auth.enabled=
auth.login.site.url=
auth.login.community.url=
company.default.home.url=
default.logout.page.path=
default.landing.page.path=
redirect.url.ips.allowed=
jsonws.servlet.hosts.allowed=
json.servlet.hosts.allowed=
json.web.service.enabled=true
jsonws.web.service.public.methods=*
json.service.auth.token.enabled=true
jsonws.web.service.strict.http.method=false
我正在使用liferay-tomcat 6.1.0
以下是我得到的错误
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
`java.net.ConnectException: Connection refused: connect
java.net.PlainSocketImpl.socketConnect(Native Metho
d)
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
java.net.Socket.connect(Socket.java:529)
java.net.Socket.connect(Socket.java:478)
sun.net.NetworkClient.doConnect(NetworkClient.java:163)
sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
sun.net.www.http.HttpClient.New(HttpClient.java:306)
sun.net.www.http.HttpClient.New(HttpClient.java:323)
sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860)
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801)
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726)
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
java.net.URL.openStream(URL.java:1010)
com.liferay.portal.jsonwebservice.JSONWebServiceServlet.service(JSONWebServiceServlet.java:136)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.liferay.portal.kernel.servlet.PortalClassLoaderServlet.service(PortalClassLoaderServlet.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:54)
$Proxy431.doFilter(Unknown Source)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:201)
com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
com.liferay.portal.kernel.servlet.PortalClassLoaderFilter.doFilter(PortalClassLoaderFilter.java:69)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)`
答案 0 :(得分:0)
在 portal-ext.properties
中设置以下属性json.servlet.hosts.allowed=
如果您有任何问题,请告诉我!!
答案 1 :(得分:0)
你能设置一个调试器来研究这个吗?如果您查看JSONWebServiceServlet
中的代码,您会在service()
中找到这个代码(我从6.1.1获取了我可用的代码 - 这与您示例中的行号不同 - 您可能想要尝试更新,这个类中的内容已经发生了变化。另外,为了简洁起见,我已经消除了空行和一些换行符,不要让那些烦恼你)
if (servletContext.getContext(PropsValues.PORTAL_CTX) != null) {
RequestDispatcher requestDispatcher = request.getRequestDispatcher(
apiPath);
requestDispatcher.forward(request, response);
}
else {
String requestURI = request.getRequestURI();
String requestURL = String.valueOf(request.getRequestURL());
String serverURL = requestURL.substring(0, requestURL.length() - requestURI.length());
String queryString = request.getQueryString();
if (Validator.isNull(queryString)) {
queryString = StringPool.BLANK;
}
else {
queryString += StringPool.AMPERSAND;
}
String servletContextPath = ContextPathUtil.getContextPath(servletContext);
queryString += "contextPath=" + HttpUtil.encodeURL(servletContextPath);
// CHECK THIS VALUE IN DEBUGGER:
apiPath = serverURL + apiPath + StringPool.QUESTION + queryString;
URL url = new URL(apiPath);
InputStream inputStream = null;
try {
inputStream = url.openStream();
OutputStream outputStream = response.getOutputStream();
StreamUtil.transfer(inputStream, outputStream);
}
finally {
StreamUtil.cleanUp(inputStream);
}
}
一种可能性是Liferay本身无法连接到它确定的服务器名称 - 例如因为防火墙或DNS设置。一旦你知道apiPath
导致了什么(遗憾的是似乎没有你可以激活的日志记录),你应该比现在更接近解决方案。