What am I not understanding about hosting a Java web app? - java

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
What am I not understanding about how to host a Java web app?
Do java web apps have an index.html file when they are deployed (which, apparently, Firebase requires)?
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
$cd into your website directory and run $firebase init
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.

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.

Related

Installing Hysterix turbine from WAR/JAR file

I am a sydadmin and was evaluating Hysterix Turbine.
https://github.com/Netflix/Turbine/wiki/Getting-Started-(1.x)
It is available as a war/jar file.
Directory structure looks like this after downloading
$ ls turbine-4.0
conf lib LICENSE NOTICE README.txt site sql turbine-4.0.jar
How to get this installed . If I download tomcat and put the above contents in deploy directory , will it work .
I am new to JAVA and Tomcat. So any help to get this installed will be highly appreciated.
Simple Steps-
Download the war file from here. If you are an absolute newbie, go with version 0.5. The version 0.0.1 has weird behaviour where it gives IOException while running multiple application instances on the same machine.
You should then deploy the war file to your tomcat by just placing it in the webapps folder in tomcat and starting the server. If your war name is turbine.war, you should be able to view your aggregated logs at http://localhost:8080/turbine/turbine.stream?cluster={cluster-name}
Before deploying your turbine.war, make sure you configure the file path of archaius.properties in catalina.sh in bin folder in the tomcat. Something like-
CATALINA_OPTS="-Darchaius.configurationSource.additionalUrls=file:///home/mukulbansal/Downloads/oauth-stuff/turbine-archaius.properties"
The contents of turbine-archaius.properties can something be like-
turbine.aggregator.clusterConfig={cluster-name}
turbine.instanceUrlSuffix.user-write=/hystrix.stream
turbine.ConfigPropertyBasedDiscovery.{cluster-name}.instances={IP:port-of-application-producing-hystrix-event-stream}
turbine.InstanceMonitor.eventStream.skipLineLogic.enabled=false
More info can be found here.

Relative Path not working in Vaadin Application

I have a Vaadin application in Eclipse running using Tomcat. I have an external jar file that requires access to a folder "/WordNet-JWI/3.0/dict/".
This works perfectly fine in a normal Java application, where the folder stays in the main project folder, but in a web application, it can't resolve this relative path and gives an error Dictionary directory does not exist: WordNet-JWI/3.0/dict
I am fairly new to Web applications and don't know in which folder to put the Wordnet-folder and how to make it available to the external jar for it to run properly.
PS - I put the external jar in /WEB-INF/lib and is working fine.
Based on your path the file should be located starting from the root of your partition.
For example if you are using windows it would be C:/WordNet-JWI/3.0/dict/ if you are running the webapp on C:
Mind that on unix the "user" running the Tomcat process must have r/w permission on that folder.
Regards.

Website directory structure different from eclipse

I am coding a website using java servlets and am using eclipse and tomcat. When I test it using localhost, it works fine. But when I am deploying it on my actual website, the directory structure is messed up and the files are not called properly.
My eclipse directory structure on localhost is
Project Name
.src/packageName/java files
.WebContent/HTML files.
When I make a call from the html files, I use the relative location and tomcat automatically knows to look in the src/packageName folder. For example, from the /WebContent/login.html page makes a onClick call as follows,
. This will automatically trigger the java file in /src/packageName/welcome
When I am deploying it in my actual website, the WebContent/login.html is throwing an error WebContent/welcome file is not found. How do I tell my website to search in /src/packageName folder?
Hmm...have you been sure to package the application as a war for deployment.

How to run a JSP website in localhost ? What is the environment to set up?

I am a PHP programmer.But i have a website code which was developed in jsp technology..
I dont know the environment of jsp engine. I wan to run my website in my localhost using Tomcat server..Please help me to do that...
You first need to install and download Tomcat. Of course you need to have a Java runtime in your machine. The website should have been given to you as a WAR file. To install it, simply copy the WAR file in the webapps folder of Tomcat. If you only have a bunch of JSP files, put them in the ROOT folder of Tomcat.

Web Services in Unix. What should be the directory structure

I earlier got to create a simple RESTful webservice on my localhost using Eclipse IDE, Tomcat, and JAX-RS libraries.
I am now trying to move the same on to a different unix server which has Tomcat installed. I am not knowing how to get started as in what is equivalent to creating a "Dynamic Web Project" that I do in Eclipse. Do I need to just create a directory myself with all the sub-directories as created by Eclipse? Should this directory be placed in webapps folder in Tomcat container. Should META-INF and WEB-INF also be created by myself?
Where should I put my Java classes?
Can somebody please clarify this or direct me to any documentation about the same.
You need to package your application in a WAR file.
The Sun Java EE 6 Tutorial has a chapter deciated to packaging.
It's pretty easy to export a web application as a war in Eclipse.
Dynamic Web Project (right click) => Export => Web =>war file =>war export dialog
Creation of web application archive - WAR is the solution for your problem,
but take care about all libraries that you need there.
You can easily extract (unzip) WAR file content
and check your project structure and libraries needed
and they will be in WAR's WEB-INF/lib.
Make sure that both Tomcats are set same way,
make sure your code is all OS friendly (users, file paths, permissions)
Always write some test simple code that will run up on app start,
and check all dependencies and libs, system clock, outside world network communication, so you can trace it in web app console or logger easily.
regards

Categories

Resources