简体   繁体   English

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

[英]unable to open app deployed on openshift

I have deployed using netbeans to openshift. 我已经部署了使用netbeans进行openshift。 I have committed the changes and push it to git url provided by openshift, but when I try to open it gives 404 error. 我已经提交了更改并将其推送到openshift提供的git url,但是当我尝试打开它时会出现404错误。 The default index.html page of openshift is loaded instead of my app. 已加载openshift的默认index.html页面,而不是我的应用程序。

In my local machine, I am opening the url into local host like this: 在我的本地计算机上,我将打开URL到本地主机,如下所示:

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

Openshift app link: http://bgr3-management999.rhcloud.com/ Openshift应用程序链接: http ://bgr3-management999.rhcloud.com/

web.xml file: 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>

Context file: 上下文文件:

<?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
    });
});

What am I missing here? 我在这里想念什么?

Note: I am using tomcat as server to run the app in local system and on openshift. 注意:我使用tomcat作为服务器在本地系统和openshift上运行应用程序。

In OpenShift, your applications need to use OpenShift Environment Variables to deploy. 在OpenShift中,您的应用程序需要使用OpenShift环境变量进行部署。

What is Happening Here? 这里发生了什么?

  1. You first created apllication with selected cartridge. 您首先使用选定的盒带创建了复制。
  2. OpenShift adds default template to get application up and running. OpenShift添加了默认模板来启动和运行应用程序。
  3. You run application at localhost, it runs. 您在本地主机上运行应用程序,它将运行。
  4. ? (See Highlight below) (请参见下面的突出显示)
  5. Now you commit and push it back to your app workspace. 现在,您提交并将其推回应用程序工作区。

Why is default page showing instead of deployed code? 为什么显示默认页面而不是已部署的代码?

  • Application did not able to start app and revert back to previous version (which is OpenShift default template). 应用程序无法启动应用程序,并无法还原到以前的版本(这是OpenShift默认模板)。
  • So, OpenShift default page is shown. 因此,将显示OpenShift默认页面。

What to do now ? 现在做什么 ?

You need to configure your app to use OpenShift Environment Variables for Tomcat before deployment (At Step 4 above). 在部署之前,您需要将应用程序配置为对Tomcat使用OpenShift环境变量(在上面的步骤4)。

OpenShift Environment Variables for Tomcat: 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

Further Reading: Tomcat Environment Variables 进一步阅读: Tomcat环境变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM