GlassFish Quandary - java

I am trying to install GlassFish (on a Mac) as directed by a book on Core JSF. When I go to
http://localhost:8080
I see the page as displayed in the book, with no problems. However, when I copy the login.war file to the directory specified in the book and try to go to the login page
http://localhost:8080/login
I simply see a 404 Error.
I /think/ I have copied the file correctly. What does this indicate? By virtue of the fact that I am able to see the page
http://localhost:8080
correctly does this mean that GlassFish has been appropriately installed? What does the 404 Error likely mean? Thanks. Conor.

The 404 error is the HTTP page not found error. This means, the page you are trying to access does not exist. I believe your application is not deployed on the server.
To deploy your application, go to server admin page localhost:4848 click on application from the navigation menu. From there click on Deploy and browse to the file location. You can also specify the context root where your application should be deployed.
However, your application might be deployed on the server with a different context root.
If you have a glassfish descriptor, then you can check your context root from there. However, If you do not have a glassfish descriptor then you need to create one.
In this descriptor you need to define your context root name.
<context-root>/foobar</context-root>
this means the application will be deployed on localhost:8080/foobar
Similarly, if you defined your context root as following:
<context-root>/</context-root>
Then your application will be deployed on localhost:8080/

Related

Why Tomcat works fine when I put a .jsp but with a .html doesn't works?

I'm working with eclipse and I created a project, I put a test.html and test.jsp file in the root folder. In the URL of the Google Chrome I put this:
http://localhost:8080/project/test.html Error 404
http://localhost:8080/project/test.jsp Works (hello world!)
What is happening?
Double check if your test.html exists under this path:
"Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\project"
If exists, then it should be accessed normally, if not then you have to clean/build your application correctly or even try to restart eclipse.
Based on your follow-up comments about the custom Tomcat install and the project error message, it sounds like you either don't have Eclipse properly configured to use your Tomcat server, or you don't have your project associated with the Tomcat server you've set up, and so perhaps your changes arent being deployed properly. See if that issue has a quick fix suggestion (right click it) or go through your project settings and verify your selected server runtime. Sorry on phone can't give specific instructions.

How to deploy many applications on Tomcat 7

I have a server where is running my web-application, located in the root folder (you can see it in the image, the path is /).
I reach that application by typing the IP and the Port (for example 111.222.333.444:1234).
Now I'm trying to deploy another web-application and reach it by typing 111.222.333.444:1234/prova/index.jsp (you can see it in the image, the path is /prova).
By using Tomcat Web Application Manager I uploaded a new war file called prova.war.
But, when I try to start it by clicking the start button, it doesn't start. In fact, when I click the start button, the Tomcat Web Application Manager I get the message:
FAIL - Application at context path /prova could not be started
.
If I use a ftp client, I can see that prova.war was correctly (I assume) unpacked.
Thank you.
Please check the log file. I.e you can check catalina.out file may be there are some issues while deploying the your new application (i.e prova)

Open JSP Page directly in brower using URL

I am using Apache-Tomcat-7 and I placed a jsp page( myjsp.jsp ) in
...\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\desktop\
I have started the tomcat and trying the following URL to open the jsp page
http://localhost:8089/desktop/myjsp.jsp
But it is giving 404. I donot want it to open through other means. Can any body tell me that what I am doing wrong?
P.S. localhost:8089 works fine for other applications and tomcate is configured to this port-8089.
EDIT
When I placed the myjsp.jsp in ROOT folder under
...\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ROOT\
and try
http://localhost:8089/myjsp.jsp
Now it works. So what is the reason that in the desktop folder the jsp was NOT found
OR
how can I access myjsp.jsp if it is placed within desktop folder?
Well one way is the way you have already done (by deploying it at the root context of the tomcat server). Although it would seem to work fine, I won't recommend doing that. Changing root context of tomcat to some other application/pages is for other purpose.
The best way to do is to create a small project (you need a dynamic web project with a proper deployment descriptor --> eclipse will do all this job by just a button click), then deploy this project to your tomcat server.
So lets say if you create your project as MyProjectOne, then just place your JSP page (lets call it test.jsp) under WebContent or src/main/webapp folder and you will be able to view your page as http://localhost:8089/MyProjectOne/test.jsp

How to change path for web project in eclipse

I wrote the web application using Spring MVC. When I deploy the app to the server path is localhost:8080/projectName/. It is possible to remove projectName from path from eclipse? I found path in project properties but I cannot find the way how to change it.
I found that I have to change context root to : "/". I changed it but that has no effect.
Thank you for any help.
Regards,
Sebastian
I would break down your question into two parts :
A. Changes to the context root not taking any effect.
For changes to the context root to take effect, you must clean and republish you webapp on your server for the context root changes to get activated. To run "Clean" in context of the server from within eclipse,
Stop the Server
Window -> Show View -> Server -> Right click on your server configuration -> Clean. (Note: To "Clean" the server outside of eclipse, you need to go to the "webapps" directory of your server on your local filesystem and delete the .war file as well as the "project-name" folder which holds the exploded WAR file. )
Deploy your webapp to the server and restart the server.
B. Trying to run your webapp at the context root / - localhost:8080
From what it looks like, you are trying to run your web application at the "Root" of your application server. You haven't mentioned the application server that you are using, but let us for example assume that the server you are using is tomcat. For tomcat, to deploy an application which will run at localhost:8080/ you need to either deploy the exploded war under the "ROOT" directory at $CATALINA_HOME/webapps/ROOT , or name your war file to be root.war.
The $CATALINA_HOME/webapps/ROOT and $CATALINA_HOME/webapps/root.war are special keywords which tell tomcat to deploy the application at content root /.
If you are NOT using tomcat as your application server, then provide more details on the application server being used to see if I can help.

Deploying .war application in Tomcat to root

My .war application runs on TomCat
I am able to deploy my .war application to a specific directory e.g. www.abc.com/specific
I would do this by renaming my application specific.war and then going to Tomcat Web Application Manager and then going to "WAR file to deploy", select my WAR file and deploy it.
However I would like to deploy it so that if the user types www.abc.com he/she will go straight to the application, without specifying the directory.
How is this possible? Thanks [I have tried calling the application root.war]
Two ways:
name the war file ROOT.war
specify the context path attribute in META-INF/context.xml - see here
I solved this by using forwarding/masking (through the domain name provider)
I forwarded www.abc.com to www.abc.com/specific
and I masked so that "specific" is not shown
I am not sure if this answers your question. But I believe u can automatically navigate to the page u want using the
<welcome-file></welcome-file>
in the web.xml file of ur web app.

Categories