0

我的 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)`
4

2 回答 2

0

Set following property in portal-ext.properties

json.servlet.hosts.allowed=

Let me know if you have any problem !!

于 2013-07-04T06:37:50.760 回答
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结果是什么(遗憾的是似乎没有您可以激活的日志记录),您应该比现在更接近解决方案。

于 2013-07-04T07:25:36.713 回答