在Openshift上运行代理Servlet [英] Running Proxy servlet on Openshift

查看:90
本文介绍了在Openshift上运行代理Servlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此应用程序 http://bit.ly/1vNUIsU 最初与Openshift一起使用,删除了该应用程序之后,然后重新创建,它不再工作了,这很奇怪.相同的代码之前工作.不知道发生了什么.

This app http://bit.ly/1vNUIsU originally worked with Openshift, after deleting the app, then re-creating, its not working anymore, its very odd. The same code worked before. Not sure what happened.

无论如何,我都尝试了rhc app-tidyrhc tail的所有操作,但是应用程序一直在加载

In any case, I've tried everything, rhc app-tidy and rhc tail but the app just keeps loading

Error 503 when accessed. 

我不确定问题是否出在之前的Restlet上.以防万一,使用Openshift的Restlet有什么问题?

I am not sure if the issue is with Restlet as it worked before. What could be the issues of Restlet with Openshift just in case?

代码:

public class FirstStepsApplication extends Application {
    private static final String ROOT_URI = "/";
    @Override
    public Restlet createInboundRoot() {
        Router router = new Router(getContext());
        Redirector proxy = new Redirector(getContext(), Constants.root,
                Redirector.MODE_SERVER_OUTBOUND){
            @Override
            public void handle(Request request, Response response) {
                String path = request.getResourceRef().getHostIdentifier() +
                        request.getResourceRef().getPath();
                try {
                    URL url = new URL(path);
                    String host = url.getHost();
                    String pathParts = url.getPath();
                    if(pathParts.isEmpty() || pathParts.equals(ROOT_URI)){
                        pathParts = "/index.html";
                    }
                    String targetPattern = Constants.root + host + pathParts;
                    System.out.println("Target URL = " + targetPattern);
                    this.setTargetTemplate(targetPattern);
                } catch (MalformedURLException e){
                    e.printStackTrace();
                }
                super.handle(request, response);
            }
        };
        getConnectorService().getClientProtocols().add(Protocol.HTTP);
        router.attachDefault(proxy);
        return router;
    }
}

此代码以前与Opensift/JBoss一起使用.不,它不会.

This code worked with Opensift/JBoss before. Not it wont.

推荐答案

我设法使其与Tomcat 7 Cartridge(而不是JBoss/Capedwarf)一起使用

I managed to get it working with Tomcat 7 Cartridge instead of JBoss/Capedwarf

这篇关于在Openshift上运行代理Servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆