What am I not understanding about hosting a Java w

2020-04-16 18:52发布

问题:

I am new to Java and I am trying to host a Java web app using Firebase.

Problem

My problem appears to be that my index.html file does not exist in my Java file structure. Therefore, I can not "point to it" in my firebase.json file.

Question

  1. What am I not understanding about how to host a Java web app?
  2. Do java web apps have an index.html file when they are deployed (which, apparently, Firebase requires)?
  3. What can I do to successfully host my Java web app?

Firebase hosting setup instructions:

SETUP & INSTALLATION

First Time Installation

You should have Node.js installed (you do not need to run Node, just have it installed)

$npm install -g firebase-tools or $sudo npm install -g firebase-tools

Updating Previously Installed Firebase Tools

$npm update -g firebase-tools or $sudo npm update -g firebase-tools

DEPLOY YOUR WEBSITE

  1. $cd into your website directory and run $firebase init
  2. Then deploy your website with $firebase deploy

My error message:

When I follow the hosting instructions and browse to https://my-example-firebase.firebaseio.com/ I get the following error message.

Page Not Found

This file does not exist and there was no index.html found in the current directory or 404.html in the root directory.

Why am I seeing this?

You may have deployed the wrong directory for your application. Check your firebase.json and make sure the public directory is pointing to a directory that contains an index.html file.


My firebase.json

{
  "firebase": "my-example-firebase",
  "public": ".",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ]
}

As you can see, my firebase.json file assumes my root directory is my public directory. However, that does not contain an index.html file. Therefore, this is what I think I am missing about the structure of a Java web app and file structure. There IS NO index.html file.


My file structure

(as scaffolded by Eclipse) (partially) looks like the following.

root
  Deployment descriptor: myproject
  JAX-WS Web Services
  Java Resources
  Javascript Resources
  build
    src
      com.example.myproject
        MyprojectUI.java
          MyprojectUI
    test
    libraries
  WebContent
  ivy.xml
  ivysettings.xml

I looked all through it and there is no index.html file. I'm wondering if I need to maybe compile something into HTML and Javascript? Then serve that file? I'm lost and confused. Please somebody help.

回答1:

Firebase Hosting is for hosting static assets only, so HTML, JavaScript, CSS, images, etc.

Firebase Hosting cannot be used to run your Java web application.