Why do I have a directory listing on my project when it's not on a web server, and how can I disable it - webserver

When I visit my project on http://localhost:8080/, instead of taking me to the homepage it takes me to a directory listing of all my files. When I look up how to disable it every solution has to do with different web servers, but my project isn't being hosted on a web server. In fact it isn't even deployed online, so I'm not sure what I can do to disable it.

Related

Web application directories and data are lost during build and deploy of the application in tomcat

I am developing a sample web application in spring tool suite. I find that during the builds in the Tomcat local host, I loose all the data that was stored prior to the build. Data include directories and their contents that were stored by the applicatin prior to the new build. I use the sample application to store pictures. The problem is all of the pictures are lost after a new build. Is there a parameter that needs to be set to preserve the directories and the data. Is is this an expected process and that I need to backup all the application data prior to the build?
If I deploy on a cloud server using a .war file, will it behave the same way.
Please let me know if I need to post any files here.
Thanks
Balaji
Once you republish to Tomcat all new files form your workspace/project folder will be copied to the webapps folder, as well as all files in your webapps folder, which do not exist in your workspace, will be removed. If you upload files into f.e. webapps/YourProjectName/uploads/* directly, they will be removed because they do not exist in your workspace.
The best way is to separate your projects files (everything in your .war) from custom files like user data or uploads, by saving the the latter in a directory outside your webapps folder. Once you are republishing they are not going to be removed.
Otherwise, if you need something like 'example images' in your app to show to your customers (lets say they do not change that often) you can copy them into your workspace, so they will be republished every time.

How-to deploy to application server web project with non-webproject structure (within Eclipse)

Basically what I want is to deploy from Eclipse web project to application server (WebLogic). The problem is that project source files are structured differently than what application server expects (i.e. there is no WEB-INF containing deployment descriptor). As a results when I try to deploy my project to app server it is not recognized as deployable app. Is there a smart and elegant way how-to solve this problem?
OK, i will answer my question myself. Basically this situation can be solved by creating a new dynamic web project with the required structure and then using Linked folder functionality of eclipse.

How to get Two Eclipse Dynamic Web Projects Set up on WebLogic with a Different Port for Each Project?

We currently have one dynamic web project (our main web application) already setup on WebLogic. We now need to set up a new dynamic web project specifically for web services. Our main web application was design with the context root being just / and would take years to change it to something else. So this leaves us with the alternative of making the new project listen to a different port.
I first looked into virtual hosts, but could not find out how to change the virtual host ports. Then I looked into creating a new server, but couldn't figure out how to get eclipse to see two servers on the same domain.
We have WebLogic 11gR1, PatchSet 2 and OEPE Eclipse 3.6.1 bundle.
I found out how to do it. I had to use Eclipse to create a new domain. The only downside to this is that I had to re-setup the connection pools, which is most fortunately a one-time deal.

Create remote P2 eclipse update site?

I have created an eclipse update site using the Plugin project wizard in eclipse helios. I have added some features to this site and build it and it works fine (I can add the site to the update manager in eclipse).
Now I would like to move this update site to a server so it can be accessed globally. But where do I find info on setting up a server and how to move the site to the correct folders?
It is very simple: you need a server that can serve files over HTTP. You upload your update site to the server. You will have plugins and features directories and all the relevant XMLs or compressed XMLs (depends on how you created it).
For example, if your server is at http://update.example.com/ and your doc-root is at /var/docroot then all these files go under /var/docroot, so you will have /var/docroot/plugins, /var/docroot/features, etc.
Again, very simple, simply copy the local update site to the server and unjar it if it is an archive.
Try p2-maven-plugin: http://projects.reficio.org/p2-maven-plugin/manual.html
It can do both generate and expose the P2 update site using the HTTP protocol.

Tomcat works but I can't reach http://localhost:8080/

When I run Tomcat from the windows tray, it starts and I can't reach http://localhost:8080/ Tomcat homepage, but if I run it from Eclipse, it works, my applications works, but I can't reach the http://localhost:8080/...
How to solve it? Or is it normal?
Thanks!
This maybe normal, according to this thread:
This is normal.
To see why, double-click on the Tomcat server in the Servers view. This will open the Tomcat configuration editor. Click on the "Open launch configuration" link in the Overview section. This will open the launch configuration properties dialog. Select the Arguments tab and examine the contents of the VM Arguments field.
Note that the catalina.home property points to your Tomcat installation, but catalina.base points to a ".metadata\.plugins\org.eclipse.wst.server.core\tmp" directory under your workspace.
Thus, you are running a separate instance of Tomcat. The "webapps" directory under the ".metadata\...\tmp" directory contains only an "empty" ROOT webapp plus any web projects you have added to the server. This is why you get the 404.
In the Tomcat configuration editor, you can uncheck the "Run modules directly from the workspace (do not modify the Tomcat installation)" option and catalina.base and catalina.home will both be set to your Tomcat installation.
Be aware that in this configuration, the Tomcat server in Eclipse "owns" your Tomcat installation.
Every time you start the Tomcat server from Eclipse, the Tomcat files under the Servers project in your workspace will overwrite the files in your installation.
It was assumed the most would want to keep their Tomcat installation independent from Eclipse Tomcat server, so the default is to create a separate Tomcat instance.
With separate instances, you can run the Tomcat installation at the same time as the Eclipse Tomcat server provided you modify one or both of them so that the ports they use do not conflict.
If you would like the standard Tomcat webapps present while keeping the separate Tomcat instance in Eclipse, switch to the Modules tab in the Tomcat configuration editor and use the "Add External Web Module" button to manually add the desired webapps. Note that this will add a little bit to the startup time for the server.
Note this is for tomcat versions that use WTP x1.5 (seems to be tomcat 5 or below), in tomcat with WTP(Web tools platform) x2.0 and above you no longer get that option. Instead you need to go into server properties and hit switch location which will then show a proper path. then you go into the server config (double clicking the server opens config) and change the "Server Location" to "use Tomcat instillation" (the middle one).2
Understanding Web Application Structure
A web application is a collection of web resources, such as JSP pages, HTML pages, servlets,
and configuration files, organized into a hierarchy as specified in the Servlet specification. You
have two ways in which to organize a web application: packed and unpacked. The packed form
is called a web archive (WAR) file, and the unpacked form is a collection of directories stored
on the file system.
The unpackaged format is convenient for web application developers, as it allows them to
replace individual files while the application is being developed and debugged.
However, in a deployment environment, it’s often more convenient to provide a single file
that can be automatically deployed. This reduces the deployment process to placing the file and
setting up system resources. Tomcat can also automatically expand a web application once
the server has booted. The automatic expansion of WAR files is configured in the server.xml
file as part of the element that configures hosts.
Web Application Context
Each web application corresponds to a context component, as discussed in Chapter 1, and
you assign a context path to each. The default context is called ROOT and corresponds to the
name of the server with no other context information. For example, the ROOT web application
on your local machine will correspond to http://localhost:8080. If you’ve configured Domain
Name System (DNS) settings for your server, it may also be accessible from a location such as
Users access other web applications by requesting a context relative to the server. For
example, users can access Tomcat’s manager web application with the following URL:
http://
localhost:8080/manager.
Applications that you place in the webapps folder are named after the directory they’re in.
So, you can access the web application in the tomcat-docs directory with the following:
http://localhost:8080/tomcat-docs. Each application on the server is known by its name,
and users can access resources according to the remainder of the uniform resource locator
(URL) after the web application’s name.