So I have this google app engine app that a development company developed and they put a test server up online and it works completely. I can build the app locally and run it on the gae dev server locally and everything works, but when I upload to google app engine it gets errors and 404 page not found. I fixed all the errors by including specific .jar files in the WEB-INF/lib directory that I found in target/lib.
I've tried just including all the .jar files that are in the target/lib directory but then the app gets errors locally so I've had to find the specific files and include those in the WEB-INF/lib directory.
In the logs I get this error
org.springframework.web.servlet.PageNotFound noHandlerFound: No mapping found
for HTTP request with URI [/api/universe/v1/auth/signup/student/email] in DispatcherServlet
with name 'spring-dispatcher'
For this error I can't find which file may be missing that I need to include in the WEB-INF/lib directory because I have already included all of the spring .jar files. What file may I be missing? Is there anything else I should include in here to help find what the problem is?
Also if there a way to see what files are being uploaded to google app engine? If I could just see what was missing I could stick it into the WEB-INF/lib directory.
Your error message indicates that there's a servlet-mapping element missing and/or improperly set up for the DispatcherServlet ('spring-dispatcher' could either be a param-name or the actual servlet-name, without your web.xml file I cannot say for certain). You can set the servlet-mapping element in the web.xml file in WEB-INF.
As an example, a given servlet could be set up like this:
<servlet>
<servlet-name>redteam</servlet-name>
<servlet-class>mysite.server.TeamServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>redteam</servlet-name>
<url-pattern>/red/*</url-pattern>
</servlet-mapping>
There's documentation here for more information on the web.xml file
This is the structure of the JSP app on eclipse.Once I run it on eclipse using tomcat server(localhost:8090/index4.html) it works.On the index page i have to add details,this details are uploaded via the servlet as you can see above Java Resources->src->FileUPloadDBServlet(Also I am not sure if it uses this or it uses WEB-INF->src->FileUploadServlet below.)
In my index4.html the action is action=uploadServlet(no address given for it).This everything works on using eclipse.
But once I put the QMS folder(not WAR) from eclipse worskspace to tomcat ROOT,the index4.html works but the following action,i.e uploadServlet doesnt work(here I use the address localhost:8090/WebContent/index4.html)I dont have a web.xml.
Is that creating a problem?
Please provide me help.
You need to put your project folder or .war file in the
webapps folder of Tomcat directly not in ROOT folder under webapps.
Try to follow directory structure as follows
Photo Courtesy http://www.studytonight.com/servlet/steps-to-create-servlet-using-tomcat-server.php (Here you can also find more details on Servlet and JSP, as well as project structure)
Where you have your web.xml put into the WEB-INF folder under your application folder.
For java files you don't need the source files, the classes folder will have all the source folder (src) files compiled and ready to execute.
The lib will contain all the .jar files you need for your application to run.
Make sure you put web.xml file at proper place, because without it, application will not be able to run. Because as they say web.xml is Heart of the application.
Let me explain you the problem.
When we configure a dynamic java project to run on eclipse the server takes the just the stuff from webcontent folder and deploy it the wbcontent folder contains web.xml file which defines the url descriptor for servlet.
now when you copy the whole folder the server can not find the web.xml file which is a descriptor where it expects the file to be.
hope its clear comment for clarification
GWT RPC call don't seems to work when i deploy my war file to TOMCAT (tomcat/webapps/ROOT/war).
It gives me an error:
The requested resource
(/war/myproject/call) is not
available.
If i change the directory structure and then deploy directly war contents (not war directory itself), like (tomcat/webapps/ROOT/project.html, project.css, project, etc...) then it works.
Can someone please explain me whats going on?
I think there might a problem at:
<servlet>
<servlet-name>callServlet</servlet-name>
<servlet-class>com.myproject.server.dao.Call</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>callServlet</servlet-name>
<url-pattern>/myproject/call</url-pattern>
</servlet-mapping>
The thing is that a single Tomcat server can have multiple applications deployed, each in its so-called context. The applications are deployed in the webapps folder and each folder is mapped to one context, while the ROOT folder is the default (no-context).
To access an application on Tomcat, you specify the context after the URL. For example if you had an application (context) Test in webapps/Test folder, you would access it like this:
http://localhost:8080/Test
But applications in the ROOT folder have no context and are accessed by simply going to localhost:8080. And this is your case. Tomcat is looking for you application directly in the ROOT folder but you have your app in the ROOT/war folder. In other words, the RPC call expects the myproject folder to be under the ROOT folder and not under the ROOT/war folder. That's why it's not working.
If you still wanted to have your war folder within the ROOT folder, you would have to change the url-pattern to /war/myProject/call.
Well i found the solution, it had to do with Tomcat's way of operation.
Open your project war directory
Select all the files (html/jsp , images, WEB-INF etc...)
Compress all the files into a single project.zip archieve
Rename the project.zip into project.war
Copy project.war into Tomcat/webapps/
Restart Tomcat server
You will now notice inside webapps directory that project.war has been decompressed into a project directory, if you open it you will find all the .war contents(html/jsp, images, WEB-INF, etc...)
Access it from here http://localhost/project or http://localhost/project/index.html or index.jsp.
The error was: I was compressing only the war directory (not it's inside contents) into project.war.
look like, servlet is not initializing for you war try to change SERVLET tag as
i.e. add tag
<load-on-startup>1</load-on-startup>
this tag ensures that servlet should be loaded
<servlet>
<servlet-name>callServlet</servlet-name>
<servlet-class>com.myproject.server.dao.Call</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
hopefully this will work
I am fairly new to Tomcat. I just managed to build a project and exported it as a WAR file. I tried manually copying a WAR file to the Tomcat folder then restarting. It created the folder structure and everything but I get a 404 Status code when I try to reach the application. I tried deploying it through the Tomcat Admin panel but I'm seeing the same behavior. Am I doing anything fundamentally wrong?
Assuming that you have full privileges with the Tomcat installation, try going to http://localhost:8080/manager/html/, if you don't know the password to get into that area, look for the tomcat-users.xml file in your ${tomcat-installation}/conf directory, and that should have it. If it has no entries in it then you will want to add an entry like the following to it:
<user username="username" password="password" roles="admin,manager" />
See whether your application shows up in that screen, and if it does, click on the link and see if that gets you anywhere. If it doesn't, then I suggest following ifishers's advice, and looking at the log files to see if it lists any errors.
But long story short, most likely something is screwed up with your project's web.xml
In more recent times, this condition might occur if JAVA_HOME points to an earlier version of Java than the code in the WAR. Tomcat might use JAVA_HOME to determine JRE_HOME it shows after running startup.bat in Tomcat's BIN directory. While Tomcat may be happy itself with the Java version it gets, for the application this might not be sufficient. In my case, Tomcat 8.0.49 was running alright with JDK1.7, while the application was not initializing at all (yes, it was a Spring Boot application, WAR was being unpacked, but that's all) - without giving any errors. After setting JAVA_HOME to the location of JDK1.8, the problem was solved.
I have the same problem.
My problem is my application name and war file name are different.
I have change war file name to my application name.
Here, when your application is deployed tomcat automatically extract your war file with same name. In my case my service name is my-web-service(i.e.https://localhost:8080/my-web-service/) and my war file name is MY-java-connector-0.0.1-SNAPSHOT.war(this is my project folder name). Now tomcat is looking for my-web=service folder and it finds epicor-java-connector-0.0.1-SNAPSHOT folder. so rename the folder to my-web=service.war and it is working.
I had the same issue, my problem was that I was copying the file via sftp straight into the webapps dir of tomcat which may have caused a polling issue causing it to not deploy correctly.
Tomcat monitors the webapps dir and when it sees the .xml it will crack on and do its thing, problem is that maybe everything hasn't been copied across yet. :(
Best to create a staging folder, move or copy the war to that folder and then use linux mv command to move it into the webapps - mv is atomic so tomcat won't do anything until the operation is complete.
Magic.
Credit goes to a very very random post that I found on javarance which in turn lead to : http://pub.admc.com/howtos/tomcat/ch02.html#stagedir-section
Hope this helps someone else :)
If your'e using Spring-Boot like me to create your WAR file make sure to add the following to your main Application file.
#SpringBootApplication
public class serverTestApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(serverTestApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(serverTestApplication.class);
}
}
I was stuck on this for awhile, looked through dozens of guides. This is the video that finally showed me I never configured my application properly:
https://www.youtube.com/watch?v=05EKZ9Xmfws
My best guess is that you have not configured the welcome files in your web.xml. If you go to /app/ you need to have some default file available. Typically, people either created an index.html or they have welcome file settings to point the user to the correct jsp.
I ran into this problem, too.
My simple roundabout solution is to change docBase path.
problem occurs when
docBase=".../tomcat/webapps/app_name.war";
problem solved with
docBase=".../tomcat/webapps/app_foldername/web"
I had the same problem with tomcat and just fixed it by forcing my IDE to create a web.xml file. Mine was missing. It would deploy the project but I would still get the 404 error. I read through several of these tutorials but to no avail. I read somewhere that the web.xml file needed to be configured correctly. Went to find the web.xml in the WEB-INF folder, and there was no folder and no web.xml file. I did a quick google on how to create on using my IDE and then compiled my program with the web.xml output, and it fixed the problem for me. Hope that helps. Cheers!
FWIW I had this problem and fixed it by discovering I was accessing the wrong host, like "http://wronghost:8080/why_is_this_war_not_there" so if it says "XX.war successfully deployed" in catalina.out/localhost.*.out that may be a hint for followers.
I had the same issue. In my case there were no errors in the log files, I had a welcome page defined, it was listed in the Tomcat manager webapp, and it deployed and worked fine on my dev machine. However, visiting the app at http://example.com/myApp just returned a 404 error.
It turns out the problem was in the Apache config. Apache didn't have a mount point, so it didn't know to proxy those requests to Tomcat.
Adding in the appropriate directive fixed the problem:
ProxyPass /myApp ajp://127.0.0.1:8009/myApp
If you have not created any welcome page like index.html JSP or whatever then create one. project must have an index page. I just created one say index.html and the problem is solved..🙏🙏🙏
Did you try
localhost:8080/app
assuming your war file is app.war?
edit for comment -- then your web.xml is screwed up.
I am trying to make servlet.
I have installed tomcat6 on ubuntu with admin examples and docs. I am able to run the examples provided. But when i try to make my own servlet it doesnt work.
I did following steps
Under the ROOT i create folder with
-ROOT
----myapp
------WEB-INF
---------classes
I made two files one is index.html which have a button and action on form to call the servlet. Second is .java file. I compiled the .java file and .class is done. So now tree look like
-ROOT
----myapp
------index.html
------WEB-INF
---------classes
-----------TestServ.java
-----------TestServ.class
Now i open this in browser using http://localhost:8080/myapp
It shows up with index.html page with button. But when i click on the button it says
Error 404:
http://localhost:8080/myapp/TestServ not found !!
I dont know where m going wrong. I have set the CATALINA_HOME too. But still this problem continue.
You need to create a web.xml in the WEB-INF directory, and define the servlet mapping in web.xml, so that the myapp/TestServ URL is forwarded to the TestServ servlet class.
Here is a page describing web.xml, and has the example and elements you need to set up. For your class, these elements will probably look something like this:
<servlet>
<servlet-name>testServ</servlet-name>
<servlet-class>TestServ</servlet-class>
</servlet>
<servlet-mapping>
<!-- For any URL starting with /content/, the rewriter servlet will be called -->
<servlet-name>testServ</servlet-name>
<url-pattern>/TestServ</url-pattern>
</servlet-mapping>
You shouldn't be deploying any of your code under ROOT.
You shouldn't have any Java class in the default package. Try putting your TestServ.java in a package.
Your deployment should NOT include any .java files.
You've got to register your servlet properly in web.xml. Include a mapping to a particular URL.
Your best best is to create a WAR file named myapp.war, which includes WEB-INF/classes and WEB-INF/lib and a web.xml for your situation. Put that in the Tomcat /webapps and start the container. If you've registered your servlet properly you should be able to access it via http://localhost:8080/myapp/TestServ.
I'd read the deployment docs carefully.