I'm developing a GWT app, let's say SoapCon that connects to a web service so I'm using Axis on my server-side to connect to this web service. When I run my app in development mode, it works fine (which returns xml as its response). But when I deployed my app to Apache 2.0 in Linux, RPC failed and returns 404 for the servlet mapping URL.
When I deployed this app to Apache, I recursively copied the /war/soapcon to the /var/www/html/SoapCon directory and the SoapCon.html and .css.
Here's my web.xml:
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>com.sample.google.server.SampleServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/soapcon/greet</url-pattern>
</servlet-mapping>
SoapCon.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='soapcon'>
....
The client side stub for the RPC service:
#RemoteServiceRelativePath("greet")
public interface SampleService extends RemoteService {
String method( String params, ... );
}
When I run my app
http://localhost/SoapCon/SoapCon.html
the module is loaded but when I clicked a button which will call RPC method from my server, error occurs returning:
com.google.gwt.user.client.rpc.StatusCodeException: 404 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /SoapCon/soapcon/greet was not found on this server.</p>
</body></html>
What should I do? please help. thanks in advance.
I assume you are running tomcat on your apache server. To deploy your gwt project you should build a .war-file, and do not try to copy all parts manually.
The 404 error tells us, that the URL "/SoapCon/soapcon/greet" was not found / in the right place on your server. Deploying the .war instead of manual copying will automatically place everything in the right position.
Related
I have a problem at this example
I work with eclipse for Java EE and Apache Tomcat 8.
My project structure:
The web.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Hello World Struts 2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
The other files code is the same as the struts website.
When I run the index.jsp file I get the following error:
**HTTP Status 404 - /helloworld/index.jsp
type Status report
message /helloworld/index.jsp
description The requested resource is not available.**
Can someone spot the reason why can't I run it?
First of all the project is created by using Maven configuration, and to access the Struts action you should use url
Step 6 - Build the WAR File and Run The Application
Execute mvn clean package to create the war file.
Copy the war file to your Servlet container. After your Servlet
container successfully deploys the war file go to this URL
http://localhost:8080/helloworld/index.action where you should see
the following:
(source: apache.org)
Web application context is where the application was deployed. In the docs url it's /helloworld, on the image it's /Hello_World_Struts2_Ant. Use it as a part of the url. It doesn't matter which app context did you use during deployment but url depends on it. If you want to change the web app context you should read Java - How to change context root of a dynamic web project in Eclipse. After the context you use action name with .action extension to execute action.
Don't use URLs like localhost:8080/helloworld/index.jsp because you might not get the resource because it's already handled by the web server.
I have a small application which is running fine ,but not correctly in Tomcat, I just copied all the files in my GWT's war folder to Tomcat webapps folder , when i run my application on localhost, it starts perfectly but when i try to make an RPC call via tomcat it gives me this error attached
Any idea
thanks
NOTE:: MY RPC Service ONLY creates issue if i run in TOMCAT ,otherwise RPC working fine
My Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<servlet>
<servlet-name>DashBoardServlet</servlet-name>
<servlet-class>com.dashboard.server.DashBoardServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DashBoardServlet</servlet-name>
<url-pattern>/dashboardsupervisor/DashBoardServlet</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>DashBoardSupervisor.html</welcome-file>
</welcome-file-list>
</web-app>
My RPC Service Interface
package com.dashboard.client;
import java.util.ArrayList;
#RemoteServiceRelativePath("DashBoardServlet")
public interface DashBoardService extends RemoteService {
ArrayList<FoundIntravue> fetchIntraVUE(String first, String second, String choice);
String saveIntraVue(Intravue interVue, ArrayList<Networks> networksList) t throws Exception;
String restoreDatabase(Date selectedDate) throws Exception;
String cleanDatabase() throws Exception;
String saveDatabase() throws Exception;
ArrayList<Intravue> fetchIntravuesList();
}
I'm not sure if this is all there is to the problem but if you're running your application on Tomcat you do not need to run code on the GWT code server. I can see in your address bar that you're URL has ?gwt.codesvr=127.0.0.1:9997in it. Try removing that.
EDIT:
In Eclipse you run the app with
http://127.0.0.1:8888/Project1.html?gwt.codesvr=127.0.0.1:9997
where Project1.html is the page you want to load.
In Tomcat the URL should be
localhost:8080/project
Where project is the name of the WAR file that you put in the webapps directory.
What ended up being the answer:
Don't forget that your libraries have to be in war/WEB-INF/lib. Where war is the top level folder that you put in Tomcat's webapps folder.
The main problem is that the servlet is basically not found on the web server once I upload it to some webhosting server I got, while it finds it all fine and dandy in hosted mode with the embedded jetty
I can't really check the full tomcat setup on the host, but it's actually there as some .jsp test files run fine there, unless there's something missing that I'm not sure of
When going directly to the path of the servlet, when in hosted mode it does the
HTTP method GET is not supported by this URL,
while just 404 on the webserver
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<servlet>
<servlet-name>retailQuery</servlet-name>
<servlet-class>com.retail.report.server.DBConnectionServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>retailQuery</servlet-name>
<url-pattern>/retailreport/retailQuery</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>RetailReport.html</welcome-file>
</welcome-file-list>
</web-app>
RetailReport.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='retailreport'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- Specify the app entry point class. -->
<entry-point class='com.retail.report.client.RetailReport'/>
<servlet class="com.retail.report.server.DBConnectionServiceImpl"
path="/retailQuery" />
DBConnectionServiceImpl:
package com.retail.report.client;
import java.util.ArrayList;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
#RemoteServiceRelativePath("retailQuery")
public interface DBConnectionService extends RemoteService {
public ArrayList<SalesEntry> dayOfWeekQuery(String hier);
public ArrayList<SalesEntry> weekQuery(String hier);
}
As far as I can see, everything seems to be normal when looking at similar problems with servlets not being found, the only thing I cant check 100% for sure is any tomcat settings that I don't know about that need to be set, since it's some shared tomcat server on the webhost that I cant change anything with myself (although can probably ask the hosting if there's actually something that needs to change)
What is inside your tomcat/lib folder on the host? It is possible that GWT assumes some libraries are available on the hosted mode, but they are missing from your deployed version's host libraries. Just make sure all needed .jar files are in the war file in classes or lib.
I searched this site for answer to this question and couldn't find a solution.
what i did is that i simply compress the war directory in my eclipse GWT app project then rename it to .war then drop it to tomcat webapps folder.
when i run the web app, the first screen is successfully shown but when i call a servlet within my src code it gives me resource not found by tomcat server.
i'm sure i have added entry for servlet in web.xml file and the app worked well when i run it in eclipse gwt dev mode. something prevent my servlets (standard servlets not GWT RPC servlets) to be found and executed by tomcat. what could be the reason?
UPDATE
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Servlets -->
<servlet>
<servlet-name>OAuth</servlet-name>
<servlet-class>org.goauth.server.OAuthServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>OAuth</servlet-name>
<url-pattern>/goauth/oauth</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>OAuthCallback</servlet-name>
<servlet-class>org.goauth.server.OAuthCallbackServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>OAuthCallback</servlet-name>
<url-pattern>/goauth/callback</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>service</servlet-name>
<servlet-class>org.goauth.server.OAuthServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>service</servlet-name>
<url-pattern>/goauth/service</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>OAuthConfirm</servlet-name>
<servlet-class>org.goauth.server.OAuthConfirmServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>OAuthConfirm</servlet-name>
<url-pattern>/goauth/confirm</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>GOAuth.html</welcome-file>
</welcome-file-list>
</web-app>
Error
nothing in tomcate logs files
the only error in browser is :
HTTP Status 404 - /goauth/oauth
type Status report
message /goauth/oauth
description The requested resource (/goauth/oauth) is not available.
Apache Tomcat/6.0.20
I found the problem :
for invoking my servlet i was calling a url of the format : "/goauth/OAuth"
this worked with eclipse gwt plugin in dev mode but not when i deploy war to tomcat server.
the solution is that my url pointing to my servlet should be of the form :
String href = GWT.getHostPageBaseURL()+"goauth/OAuth";
so we need to tell tomcat the full url by prefixing servlet url with GWT.getHostPageBaseURL().
Take a look at how to create a GWT .war in eclipse: http://blog.elitecoderz.net/gwt-and-tomcat-create-war-using-eclipse-to-deploy-war-on-tomcat/2009/12/
In your mapping, try changing
/goauth/oauth
to /OAuth
I want to setup a GWT application (Version 2.0.0) with many dependencys in my local Tomcat Server. I started to write a maven2 build script for deploying and packaging of the application.
I wrote a maven2 script which works really fine in my eyes, but I get an error when trying to deploy the out coming war on my tomcat.
2011-04-21 18:14:13,951 ERROR org.apache.catalina.startup.ContextConfig - Parse error in application web.xml file at jndi:/localhost/quickfinder.ui-1.0-SNAPSHOT/WEB-INF/web.xml
org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed.
The web.xml is look like the following:
here and my maven2 script looks like this:
here
After compiling and linking and the other stuff my "deploy" directory (named war) looks like:
|-AnswerPanel.css
|-common.css
|-DomainListPanel.css
|-glossary.css
|-glossary.html
|-images
|-META-INF
|-MulitpleChoiceEditPanel.css
|-MultipleChoiceDisclosurePanel.css
|-NaviPanel.css
|-QuestionnairePanel.css
|-quickfinder
|-Quickfinder.css
|-Quickfinder.html
|-quickfinderportlet
|-QuickfinderPortlet.html
|-styles-css2.css
|-styles-css3.css
|-WEB-INF
|--lib
Under lib in the WEB-INF directory, all needed library's are available. The Project has got some RPC calls and so on.
With mvn compile war:war a .war file and a folder named #artifactId#-SNAPSHOT-1.00 are created under /target.
I don't know how to handle with this error form tomcat, or is there a logical mistake in the pom.xml.
BR,
mybecks
Your web.xml is not well-formed: fix the below section
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" [
<!ENTITY GlossaryWebXml SYSTEM "glossary.web.xml"> -->
]>
I would suggest to add maven-xml-plugin to your validate phase. It will check your web.xml automatically.