Run the website on server on eclipse ide with tomcat as server - java

I have made a website using Tomcat Server on Eclipse Mars 2.0 IDE. When I run it on server, I have to manually add the name of the first (home) page of the website i.e the JSP/HTML file.
I want the website to open directly on the server so tell me how to do that please.

If you put an index.html into src/main/resources/static/ and reload the server does it show the content of the index page? If you have no static folder then go ahead and create one :)
In general you have to decide for a context-root which is basically the name of the application. If the name of the application is 'myapp' and the context-root is set to 'myapp' too then you should be able to see the website at serverip:port/myapp/.
If your project is configured as a WebProject you should be able to see Web Project Settings in the properties of the project itself. There you can adjust the context root. If you leave it empty it means that your application will be reachable at serverip:port/.

you can change your welcome-file-list in web.xml
you can refer this
https://cloud.google.com/appengine/docs/flexible/java/configuring-the-web-xml-deployment-descriptor
or look for Configuring the web.xml deployment descriptor

Related

Which application context set in IntelliJ IDEA for Tomcat?

So far I run Tomcat server (v. 7.0.26) in windows command by catalina.bat start script. If I want to deploy my web app I have to build it by Maven and copy WARs to specify Tomcat deploy directory. When server start everything is ok.
Now I try to connect my web app to IntelliJ IDEA Ultimate 2017.1.4. My app have multiple WARs. At Run/Debug Configuration I add new Tomcat Server. At the Deployment tab I have:
I have to choose Application context but if I set blank for more than one artifact I get error Duplicate context path''. Same situation is when I choose /. If I try to run server nothing deploy. Which application context I should set?
The application context will be part of the URL you have to enter in your browser when accessing the application. You could use the name of your war file:
kb-hook
Then you can enter the adress in your browser and find the application. (Given your Tomcat runs on port 8080) You will maybe have to add a path to a resource within the war behind that URL.
http://localhost:8080/kb-hook/
You could also choose another name, but the name of the war file is chosen quite often.

Unable to open "Tomcat web application manager"

I am new to java web programming and eclipse-apache Tomcat. I have small login web-application which includes (one jsp page , one servlet class).
I want to configure/deploy this application on apache web application manager. I mean I don't want to run this application in eclipse. I hope you understand my point.
Whenever I run my server in eclipse it run successfully. But when I want to open apache default page by typing http://localhost:8080 or http://localhost:8080 to configure my app It wouldn't open.
Please advice me.
To deploy a web application on Tomcat, you need to first compile your web application into a WAR file. Then, take that WAR file (let's assume it's called "MyApp.WAR") and put that into the tomcat/webapps directory. Restart the tomcat service. Tomcat will extract that WAR to a folder in the webapps directory. After that, any request to localhost:8080/MyApp will go to your webapp.
Make sure you have java installed, and add JAVA_HOME to your environment variable. (it is the path to java installation directory for e.g. C:\Program Files\java\jdk-1.6)
i.e
JAVA_HOME=C:\Program Files\java\jdk-1.6
install TOMCAT from here "http://tomcat.apache.org/download-70.cgi"
make sure you do not install it in you "c:\program files" due to some permission issues.
Lets say you installed tomcat at "c:\webserver\apache-tomcat\" this is your CATALINA_HOME, add it to your environment variable
i.e CATALINA_HOME=c:\webserver\apache-tomcat\
to acess tomcat webapp manager you need to configure user in %CATALINA_HOME%\conf\tomcat-users.xml
Add a role and a user :
Have your WAR file ready with you (this is how you create WAR "How to make war file in Eclipse")
move your WAR file to "%CATALINA_HOME%\webapp" directory. lets say "TestWeb.WAR" is your application with index.jsp page in it.
Now go to your %CALALINA_HOME%\bin and launch the startup.bat file (you would be using startup.bat to start and shutdown.bat to stop tomcat)
once tomcat is up and running check http://localhost:8080 is working fine.
P.S. If port 80 is already in use then try configuring your tomcat to some other unused PORT here "http://www.mkyong.com/tomcat/how-to-change-tomcat-default-port/"
go to your browser type http://localhost:8080/TestWeb/index.jsp
now you can to lot of configuration to your web app like having a default page and all
Hope this help you !
Normally eclipse uses Tomcat as an eclipse project, hence it uses metadata.
Server > Double click on the tomcat server instance > Server Location > Select "Use Tomcat installation"
Update: Tested just now. Set Deploy path to webapps folder. Works fine :)

How Tomcat Notify about When New Jsp being uploaded

when we directly upload JSP page into tomcat where application deployed directory then why we don't need to restart Tomcat? how tomcat know that it has new JSP page?
when user hit the url /myapp/mynewjsp.jsp He/She always get new jsp deployed page.
Tomcat has an auto deploy feature. When you update JSP files it detects you have done so, compiles it, and replaces the old compiled JSP page with the new one that it compiles into a java class.
http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html
If you don't want that to happen, you can turn off the auto deploy feature for your web application. It is described in the link how you do that.
Hey you can use jetty plugin for auto deploying tomcat folder . You don't need to paste your file on webapps folder. If you using maven project structure then add jetty plugin on pom.xml file . There is some command to run like mvn jetty:run etc... May these solution get you out from these problem

build-impl.xml:1031: The module has not been deployed

I have been working on a Java web application and i am using SmartGwt on Netbeans 7.3 and out of a sudden I encountered this problem. I tried cleaning the build-impl.xml then restarting the IDE and I should say I have fairly low knowledge on this. Can someone please tell me why it is giving an error and how I can fix that?
The error message says :
nbproject/build-impl.xml:1031: The module has not been deployed. See the server log for details.
BUILD FAILED (total time: 4 seconds)
Note: i am using Tomcat 7.0.34
may its so late but the response useful for others so :
Sometimes, when you don't specify a server or servlet container at the
creation of the project, NetBeans fails to create a context.xml file.
In your project under Web Pages, create a folder called META-INF.
Do this by right mouse button clicking on Web pages, and select:
New->Other->Other->File Folder
Name the folder META-INF. Case is important, even on Windows.
Create a file called context.xml in the META-INF folder.
Do this by right mouse button clicking on the new META-INF folder, and
select:
New->Other->XML->XML Document
Name it context (NetBeans adds the .xml)
Select Well-formed Document
Press Finish
Edit the new document (context.xml), and add the following:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/app-name"/>
Replace app-name with the name of your application.
Now your in-place deployment should work. If not, make sure that the
file can be read by everyone.
The context.xml file is specific to Tomcat. For more information about
that file, see the Tomcat documentation at tomcat.apache.org.
Start your IDE with administrative privilege( Windows: right click and run as admin), so that it has read write access to tomact folder for deployment. It worked for me.
Take a look at the server logs!
I had been with this for hours. The awful Tomcat servlet is not very helpful neither but if you can see the stacktrace that should be enough.
For instance, I read the following error message there:
As you can see, the message was pretty clear and easy to fix :-)
Check if there any other instance of the server is running already
Check if the port that will be used by the server is free.
If you add jars in tomcat's lib folder you can see this error
Close Netbeans.
Delete all libraries in the folder "yourprojectfolder"\build\web\WEB-INF\lib
Open Netbeans.
Clean and Build project.
Deploy project.
One of the main reason for this error is due to permission not granted to all users. so remove this error, follow the following steps :
1) Go to the C:/Programme Files/Apache Software Foundation/Tomcat 7.0
2) Right click on the Tomcat 7.0 folder and click on properties.
3) go to Security Tab.
4) Select the User and click on Edit... button
5) Grant all the permission to the user and click on apply and ok.
Refresh the system and now try. I hope it will work
if you still getting this error try this.
Go to Netbeans services
Remove Apache Tomcat.
Add Apache Tomcat again.
Build Project.
Deploy Project
in my case , it said that the 8080 port is in use , so I change the server port of Tomcat to 8081 and it works
Check whether you placed the within the .. or outside the ...
If you placed it outside the server tag , and if you try to access the init-parameter then it will give error.

How to make the application context run as root in Spring 3 MVC and eclipse

I’m trying to develop a Spring 3 MVC application using the Springsource Tool Suite/Eclipse IDE.
My current application context in STS/Eclipse is /localhost:8080/realtyguide/
What I want is to access the application as root using just /localhost:8080/
I tried in eclipse.. Project > Properties > Web Project Settings > entered “/” for Context Root . But this just returned a “404 error - requested resource (/) is not available” after executing the app. And it also broke the app. So I just put context root back to 'realtyguide'.
I deployed the app to my webhost on a Tomcat server. I edited the server.xml’s and elements and so I was able to bring up the index page with the url www.mydomain.com.
However, the links to the other pages are broken. It is also not picking up the static resources for the index page like css and jquery files.
I believe this is caused by my app’s application context of /localhost:8080/realtyguide/ in eclipse (in my development pc). The rest of the pages returned by my controller has a url of /localhost:8080/realtyguide/page_name
How do I change my app’s application context to run as root in eclipse, as in simply /localhost:8080/. So that my pages would be called as simply /localhost:8080/page_name
Is the solution a setting I should make in my web or Spring configuration files or in eclipse?
I’ve tried googling this but have not found a clear, definitve answer. I am very new to this and a detailed answer from you will be of great help.
Thanks to the other answers provided. However, it doesn't address my main objective - to run the app as root inside eclipse.
This is how I was able to do it. I changed Tomcat's conyext path in eclipse.
Do the following:
Right click on the server name from the Server Console > Open
Click on the Modules tab
Click on a module then click the Edit button
Edit the entry for Path to the desired context path then click
OK
You need to make your web-app the "default" application, ROOT. There are step-by-step instructions on the Tomcat Wiki, at http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application.3F.
One way is to name the war simply ROOT.war (uppercase).
This works only if you deploy not from eclipse
If you have done your links/urls with <c:url> or <spring:url> then it should work without problems.
Simply change server.xml in Tomcat Server.
Package Explorer > Servers
expend path Tomcat vX.X Server
open server.xml
go to Server > Service > Engine
find your Context and change path to value "/"
restart the server!

Categories

Resources