在Openshift上运行代理servlet

时间:2014-09-03 16:34:09

标签: java openshift

此应用程序http://bit.ly/1vNUIsU最初与Openshift合作,在删除应用程序,然后重新创建,它不再工作,它非常奇怪。之前的代码相同。不确定发生了什么。

无论如何,我已经尝试了所有内容,rhc app-tidyrhc tail,但应用只是不断加载

Error 503 when accessed. 

我不确定问题是否与之前的Restlet有关。为了以防万一,Restlet与Opennshift的问题可能是什么?

代码:

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一起使用。不是吗。

1 个答案:

答案 0 :(得分:0)

我设法使用Tomcat 7 Cartridge代替JBoss / Capedwarf