Deployment descriptor in web.xml file is failing to load - eclipse

I have a web-application that I'm developing using JSP. I'm running the application on Tomcat Server (version 8). In the project explorer view of Eclipse IDE, I'm getting an error saying that the source code could (a JSP file) not be run on server.
I have written my web.xml from scratch. It includes some server options or parameters which are defined by certain xml tags (display names). These display names were missing so I had to modify the web-app tag so that these tags are available. So far so good. The application is fine, but I get a pop-up message from the IDE giving a null pointer exception. I found that it is related to the Project View of Eclipse IDE, and when I switched to package explorer the error is gone but this time when I pick a server page to run on server (the server is running fine) i get another error which says the selection (the jsp file) could not be run on server. I believe this is still a dev environment problem. How can I fix it?

Related

Eclipse's Tomcat gives a 404 while the WAR file works-previous solutions don't work

So when I'm running my project through Eclipse's "Run on server" the 'server' doesn't work (when trying the URI http://localhost:8080/simpleapp/ there is an automated 404 Tomcat's webpage), but when compiling and deploying the WAR file through Tomcat's app manager it works fine (the exact same URI gives the response I expected).
How can I systematically solve the issue?
It's important for me to solve it since debugging is a living hell this way right now (can't do a step-by-step debugging,every time that I want to check something I have to re-deploy my project :( ).
I've looked for hours for a solution so I've tried lots of different settings, and the proposed solutions don't work here.
Specifically,when changing the server's configuration in Eclipse to 'use tomcat installation', it doesnt work through eclipse (and the WAR file cannot be undeployed and doesn't work either!),switch location doesn't work either...
More details which are optional but might help:
I have another project where the server through Eclipse does function, I've just used a different Maven archetype this time. When Eclipse's server 'worked' I used jersey-quick start-web app but this time I had to use (org.glassfish.jersey.archetypes:jersey-heroku-webapp (An archetype which contains a quick start Jersey-based web application project capable to run on Heroku)) and added dynamic web module through project facets and as I said now the Eclipse server doesn't work (oh and I've tried to delete the server and reset the configuration too, but no luck).
Try to deploy your WAR using "Add and Remove" from the Servers view instead of using "Run on Server". If the WAR doesn't appear check the Project Facets and ensure that Dynamic Web module is enabled.

Apache tomcat 7 No error with localhost page, But when run project: show HTTP Status 404

I know there are many questions about Apache tomcat 404 error: but I think mine is different.
I am using windows 7 64 bit
unzipped eclipse-jee-juno-SR2-win32-x86_64 to C:\
unzipped apache-tomcat-7.0.37-windows-x64
changed port server.xml to 3030 instead of 8080
continue with this steps "Quick Start" from point (2)
I didn't forget:
copying ROOT folder
R-click tomcat node in eclipse Servers tab -> properties -> Switch location
Double click tomcat node in Project explorer and check use tomcat instillation (takes control of tomcat installation)
The page:http://localhost:3030/ works fine. It shows the message If you're seeing this, you've successfully installed Tomcat. Congratulations!
But when I tried simple project (I followed basic tutorial) and use Run as -> Run on Server the page of error 404 is shown. When back to http://localhost:3030/ it shows no error.
No error with http://localhost:3030/
Error when running a project!
HTTP Status 404 - /SimpleProject/
type Status report
message /SimpleProject/
description The requested resource is not available.
Apache Tomcat/7.0.37
I am The author of this question, and I solved it. I will provide the solution so that others can get help from it.
As I followed this installation steps carefully, then the installation is correct.
The only problem that caused the error is in the web.xml:
- When create a new "Dynamic Web Project" (As my case)
- Take care of this file: WebContent -> WEB-INF -> web.xml
- The <welcome-file> </welcome-file> tags must refer to exist files to display in the browser.
- If there are some default tags delete them.
- when you create for example a new HTML file named index.html, then make sure that the web.xml file refers to it. <welcome-file>index.html</welcome-file>
Digression (irrelevant to the solution above)
I am actually working on NetBeans extensively doing simple Java Standard Edition projects. I rarely encountered problems with NetBeans, and when they occur I can solve them easily either myself or by searching for information about the problem.
When I began learning the Java Entrprise Edition, and see tutorial on NetBeans, I started my first project from the first day.
But I found most of the tutorials use Eclipse and that was the reason why I installed it.
When I moved to Eclipse. I encountered many problems, and each problem take many hours to search and solve. that takes three days before starting one project.
I am wondering why people prefer Eclipse over NetBeans. I think there is some reason. (^_^)

error in running a web application on tomcat server

I am currently converting my Java project written under Eclipse to a web application and trying to run on tomcat server. I have converted the project into a maven module, changed its project facets and other requirements to make it a web app. I have put my project.cfg.xml file under WEB-INF and included deployment to web.xml file. When i run my browser and point to "http://localhost:8080/manager/html", i am able to see my deployed war file. But it says running = false and when i click on my project, it shows me
HTTP Status 404 - /myproject/
type Status report
message /myproject/
description The requested resource is not available.
Apache Tomcat/7.0.32
I faced the same problem in running sample programs from "quickstart" also.
You should read $TOMCAT_HOME/logs/catalina.out This log records the lifecycle of web applications. You should be able to find the part where it attempts to start your web application and it is most likely throwing some errors at that location.
Observe the tomcat console . Surely, there are some errors being thrown at the application start-up, due to which it's not starting.

debug GWT on tomcat using eclipse

I'm using GWT 2.4 and have a ton of code already written. I understand the Jetty server that comes with the GWT plugin has very tight control over the jars that can be used in a project to mimic app engine as closely as possible. I need to deploy to tomcat 7. I modified my project in eclipse and "blessed" it as a dynamic web project so I can export...WAR and upload it to my QA and production tomcat.
I need help with getting the app to run (and debug) on an embedded tomcat (like an honest dynamic web project would). I already have tomcat setup in eclipse and I have my CAS server web app deployed to it.
I've ready tons of either old or confusing posts here and elsewhere. Basically, I'm looking for the same debugging environment I would get with the packaged Jetty server, but on my own tomcat configured with WTP in eclipse...so I can mimic my production environment (just like Jetty mimics app engine)
any help is appreciated.
It should probably a little bit easier, but it's possible. Here's how I do it:
1. Setting up the web server
Using the JavaEE edition of Eclipse, I set up the Tomcat 7.0 server adapter, and define an environment in Preferences > Server > Runtime Environments
File > New > Project... > Web/Dynamic Web Project
Select the target runtime I set up in the first step
Important: In Context Root, enter /
I create an HTML file and a Servlet, and then try running the setup using Debug As > Debug On Server
2. Adding the GWT code server
Project > Properties > Google > Web Toolkit > Use Google Web Toolkit
Important: I always need to change the order in the Java Build Path (Project > Properties > Java Build Path > Order and Export), see http://code.google.com/p/google-web-toolkit/issues/detail?id=4479 - gwt-dev.jar must be pretty much on top of the path.
Project > Properties > Google > Web Application: War directory = "WebContent", also check "Launch and deploy from this directory"
I create some sample GWT content (I create a sample GWT project, and copy most of it over)
I try to GWT compile the project. This shows me, if I got the build path order right - otherwise, the compiler fails early with "java.lang.NoSuchFieldError: warningThreshold".
Debug As > Web Application - just to create a debug configuration. Stop the debug. Edit the debug configuration (Run > Debug Configurations...), deselect "Run built-in server". Start the debug again.
Now, finally, I can debug both the server and the client part (I still need to click two Debug icons to start both!) I can manage the client side from the "Development Mode" view, and the server side from the "Servers" view. At the end of the day, it works great, and using the "Automatically publish when resources change" feature (Servers view > myServerName > Open > Publishing), sometimes even better than with the integrated Jetty.
At first thought, I don't really see why you would be facing a problem. Perhaps, the way Eclipse is laid out is too confusing and daunting.
On my Eclipse, I had been using the default jetty as the server during GWT debug. However, there were some problems which would not be caught by jetty when deployed on Tomcat or JBoss.
And when I added Tomcat or JBoss instances to Eclipse and added my app to those server instances, the debugging worked straight away. Are you missing one piece of vital, but simple info?
Let me presume that the following would fill in your missing link ...
Locating/adding your server instance:
On Package Explorer (or Project Explorer, either one) in Eclipse, you would see, besides your personal projects, a "servers" project. Under it is are configuration nodes listing all your Tomcat instances.
If you cannot see the "servers" node in Package Explorer, it probably is due to your working set filter. (And if you don't know what working sets are ... I guess you would need to beef up on your dexterity in Eclipse).
If you don't already have a Tomcat instance, you simply right click on the "servers" project to add a new server (Package Explorer -> New -> Server ...). You would be asked the location of your Tomcat home. And your desired port number of the server instance. Of course, you would have to ensure that the port number will not clash with the port used by any other inet operation on your box.
Configuring the port number a 2nd time
On the server instance node in Package Explorer, you would find the file you should edit to set the port number to match the one you specified when creating the new Tomcat instance. If you don't know which file to edit, you would need to read up on the Tomcat version you created to find out which file contains the port number config.
You need to config the port a 2nd time because the 1st time tells Eclipse where and at what port to expect the server instance to be running. The 2nd time is to configure the server instance itself.
Adding your app to the server
However, the nodes in "servers" project only allow you to configure your Tomcat instances. There is yet another view called the "server view" to further configure your tomcat instance. You need to enable Server view from Window->Show View->Server->Servers.
Right click on the server instance in the "Server View" to add your app.
Running debug off the Maven generated target.
There are times you wish to debug the war structure to figure out which jars are missing in the war. And incrementally remove jars from your war to figure out the jars that are already supplied by the server. Since JBoss supplies many of the jars already, you would have to figure out if your development jars are of the versions as those expected by JBoss.
You would create another Eclipse project in your workspace and make an Eclipse folder softlink in your 2nd project to point to the Maven generated target of your first project. And you specify target/{maven generated webapp directory} as the webapp directory of your 2nd project. What I mean by "maven generated webapp directory" is the unzipped intermediate directory generated by Maven (used by Maven to generate the zipped war file).
This is the cleanest way to debug production war if you could faithfully replicate the production tomcat/jboss server on your Eclipse development box.
If you prefer JBoss.
Somehow, JBoss config node is not listed in the "Servers" node in Package/Project Explorers. You would need to go to your JBoss installation directory to edit them.
Remote debugging.
If you wanted to debug the app on your production box, or on a server sitting on another box, you would have to start that tomcat instance under debug. You should read up on that. You have to specify the debug port.
Then in Eclipse, at Run->Debug Configuration->Remote Java Application, you specify the app and the debug port.
The first time you debug, Eclipse "may not know" where the source files are, especially if your app has multiple project dependencies. (Why can't Eclipse search the source files from my list of projects?) Anyway, you have to specify where to find your source files. And then when your debugging traverses into another project dependency, you would have to over-write the location of the source files.
So, voila! That is how I got my debugging working. I advise you to avoid remote debugging as much as possible unless you need to diagnose production problems. Unless you are doing remote debugging, do not attempt to deploy the war to local server, but simply depend on associating the project to the server instance.
Eclipse is too confusing
I know Eclipse is too confusing and you have to wade thro its features. You just have to bear with it. Eclipse menus & views are apparently optimized for plugin-programmer-centric not user-centric.
For example, why would I go to "help" to install new software? I used to expect that "Help->Install new software" to be an instructional manual to installing new software.
It beats (and annoys me) that the Eclipse team did not combine the operations together so that I could add apps to a server instance at Package Explorer. Why not? As a user I would expect to see only a single entry point to configuring my servers.
To alleviate the confusion, I like encouraging people to download and install Springsource's version of Eclipse (STS). It's the same Eclipse, except that STS has the essential parts installed and has a dashboard pointing to compatibly installable plugins. Tomcat is preinstalled as VMware tc Server. And the views are correctly config'd to show the server instances. And the correct workable Eclipse-Maven bridging plugin is pre-installed.

gwt beginner- getting error when I make an RPC call on server- same code works in gwt dev mode

I have created a simple gwt application (with gwt 2.4) that makes a single RPC call.
When I run this in GWT Dev mode, it runs fine, however when I try to run this on a server-
this is the message that I get --
POST http://app.sparkcrawler.com/com.arvindikchari.auth.App/AuthenticationService 404 (Not Found)
I have copied all files from the WAR folder in my Eclipse GWT project, to the web server's folder. The web server uses Tomcat 5.5(with Cpanel control panel). I copied these files, after successfully compiling the files ("GWT Compile Project")...
What have i done wrong here? Have i missed some files? I have copied everything from war folder, including "WEB-INF" folder and its contents, to the web server.
I think, copying the Eclipse project's WAR folder is not the appropriate way to deploy a GWT application to a server.
You first have to compile for production mode (see Understanding the GWT compiler), then with the resulting JavaScript files, create a WAR including server side classes which you can deploy to a Tomcat server. (See Deploy a GWT Application)
You can use Ant or Maven to automate this process.