无法打开openshift上部署的应用程序

时间:2016-06-18 03:40:10

标签: java angularjs git netbeans openshift

我已经使用netbeans部署了openshift。我已经提交了更改并将其推送到openshift提供的git url,但是当我尝试打开它时会出现404错误。加载了openshift的默认index.html页面,而不是我的应用程序。

在我的本地计算机中,我正在打开本地主机的URL:

http://localhost:8089/BGR3/#/home

Openshift应用链接:http://bgr3-management999.rhcloud.com/

web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
     version="3.1">
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>Default.html</welcome-file>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

上下文文件:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/BGR3"/>

Angular stateprovider:

myApp.config(function ($stateProvider, $locationProvider, $urlRouterProvider, $httpProvider) {

    // For any unmatched url, redirect to /login
    $urlRouterProvider.otherwise("home");

    var header = {
        templateUrl: 'views/header.html',
        controller: function ($scope) {
        }
    };

    var footer = {
        templateUrl: 'views/footer.html',
        controller: function ($scope) {
        }
    };
    // Now set up the states 
    $stateProvider
            .state('home', {
                url: "/home",
                views: {
                    header: header,
                    content: {
                        templateUrl: 'views/home.html',
                        controller: function ($scope) {
                        }
                    },
                    footer: footer
                }
            })
            .state('about-us', {
                url: "/about-us",
                views: {
                    'header': header,
                    'content': {
                        templateUrl: 'views/about-us.html',
                        controller: function () {
                        }
                    },
                    'footer': footer
                },
//                data: {
//                    requiresLogin: true
//                }
            })
            .state('products', {
                url: "/products",
                views: {
                    'header': header,
                    'content': {
                        templateUrl: 'views/our-products.html',
                        controller: function () {
                        }
                    },
                    'footer': footer
                },
//                data: {
//                    requiresLogin: true
//                }
            })
            .state('contact-us', {
                url: "/contact-us",
                views: {
                    'header': header,
                    'content': {
                        templateUrl: 'views/contact-us.html',
                        controller: function () {
                        }
                    },
                    'footer': footer
                },
//                data: {
//                    requiresLogin: true
//                }
            }).state('faqs', {
                url: "/faqs",
                views: {
                    'header': header,
                    'content': {
                        templateUrl: 'views/FAQS.html',
                        controller: function () {
                        }
                    },
                    'footer': footer
                },
//                data: {
//                    requiresLogin: true
//                }
            });
    $locationProvider.html5Mode({
        enabled: false,
        requireBase: true
    });
});

我在这里缺少什么?

注意:我使用tomcat作为服务器在本地系统和openshift上运行应用程序。

1 个答案:

答案 0 :(得分:0)

在OpenShift中,您的应用程序需要使用OpenShift环境变量进行部署。

这里发生了什么?

  1. 您首先使用选定的墨盒创建了应用程序。
  2. OpenShift添加默认模板以启动并运行应用程序。
  3. 您在localhost上运行应用程序,它运行。
  4. ? (见下面的重点)
  5. 现在您提交并将其推回到您的应用工作区。
  6. 为什么显示默认页面而不是部署代码?

    • 应用程序无法启动应用程序并恢复到以前的版本(这是OpenShift默认模板)。
    • 因此,显示了OpenShift默认页面。

    现在该怎么办?

      

    您需要将应用配置为在部署之前使用Tomcat的OpenShift环境变量(在上面的步骤4中)。

    Tomcat的OpenShift环境变量:

    OPENSHIFT_JBOSSEWS_IP          -   The IP address used to bind EWS
    OPENSHIFT_JBOSSEWS_HTTP_PORT   -   The EWS listening port
    OPENSHIFT_JBOSSEWS_JPDA_PORT   -   The EWS JPDA listening port
    JAVA_OPTS_EXT                  -   Appended to JAVA_OPTS prior to invoking the Java VM
    

    进一步阅读:Tomcat Environment Variables

相关问题