Servlet not found once hosted on a web server - gwt

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.

Related

Struts 2 Hello World

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.

eclipse webapp welcome file display error

I m new to eclipse and facing difficulties at the beginning of a new webapp.
index.jsp doesnt display.
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>PizzaOrderApp</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
I already tryed with http://localhost:8080/PizzaOrderApp/index.jsp and http://localhost:8080/PizzaOrderApp/jsp/index.jsp
after remove-readd tomcat server:
Have you tried putting the .jsp file directly in the WebContent folder rather than creating a folder for the JSP pages?
You did not define the Spring dispatcher servlet in web.xml. You can either copy index.jsp outside of WEB-INF directory (into webcontent), or you should have a deep look into the Spring MVC documentation.
I also faced this problem but what i was doing wrong is, I created
Dynamic project in eclipse with Dynamic Web Module version 3.0. It
won't give you Web.xml file.I added Web.xml file from other project
but still Welcome File is not getting.
Then i deleted the project and i created the project with Dynamic Web
Module Version 2.4 and it given me Web.xml file. I again Configure the
Welcome File in the Web.xml file, After that its working fine.Server
which i am using is Tomcat 7 and java 1.7,Eclipse Luna.

How to run GWT RPC in Tomcat

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.

gwt app deployment to tomcat doesn't load compiled javascript

I use Eclipse GWT Plug-in to build a GWT app. Later on, I'll have to deploy this as a Tomcat webapp. I have read many pages on how to do it and it looks dead simple but it doesn't work here.
If I create a new Web application using the plug-in and that I copy the war directory content to de tomcat_install/webapps folder it works right out the box, I get the application and all the things get loaded correctly.
If I do the same with the application I'm working on for a couple of weeks now, I get nothing, there is just the plain html file I use as welcome page that loads. If I inspect the page I can see it has correctly loaded the .nocache.js but no controls whatsoever show up on my page.
Everything works in development, my servlet are correctly mapped.
Here is my app.gwt.xml :
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='VirtualLabPortal'>
<inherits name="com.google.gwt.user.User" />
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<inherits name="com.google.gwt.i18n.I18N"/>
<set-property name="gwt.logging.enabled" value="FALSE"/>
<define-property name="webkitVariant" values="safari, chrome" />
<collapse-all-properties />
<extend-property name="locale" values="en"/>
<extend-property name="locale" values="fr" />
<set-property-fallback name="locale" value="fr"/>
<entry-point
class="com.banctecmtl.ca.vlp.view.webview.client.VirtualLabPortal" />
<source path='view/webview/client' />
<source path='shared' />
<source path='model' />
</module>
My web,xml, where my two servlet are mapped looks like this :
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>VlpControllerService</servlet-name>
<servlet-class>com.banctecmtl.ca.vlp.view.webview.server.VlpControllerServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>UserAccessService</servlet-name>
<servlet-class>com.banctecmtl.ca.vlp.view.webview.server.UserAccessServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VlpControllerService</servlet-name>
<url-pattern>/VirtualLabPortal/VlpController</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>UserAccessService</servlet-name>
<url-pattern>/VirtualLabPortal/UserAccess</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>VirtualLabPortal.html</welcome-file>
</welcome-file-list>
</web-app>
Note that in my services interfaces I use #RemoteServiceRelativePath("VlpController") and #RemoteServiceRelativePath("UserAccess") to ensure a correct mapping.
This is the content of my entrypoint, that I made plain simple just to see if I could get it to work on deployment :
public class VirtualLabPortal implements EntryPoint {
/**
* Entry point method.
*/
public void onModuleLoad() {
RootPanel.get().add(new Label("This"));
}
}
Since the body of my html page is empty, a white page shows up, the javascript should write the test label on that page, but nothing happens. As I said, my VirtualLabPortal.nocache.js is loaded in the html page.
Is there something I'm completely missing here?
EDIT :
I think i just got it, I removed two properties my partner added to the gwt.xml file to reduce the number of permutations and it seems to be fixed so far:
<set-property name="gwt.logging.enabled" value="FALSE"/>
<define-property name="webkitVariant" values="safari, chrome" />
<collapse-all-properties />
Do you compile your project via :
project right clic > google > gwt compile
and then
project right clic > export > WAR file
this is the way I proceed, it works !
check this one:
Deploying GWT app from GAE to Tomcat
After long hours of searching and testing, I understtod how GWT bootstrapping process was working. I looked over my module.gwt.xml file and I found the following line added by one of my partners to reduce the number of permutations :
<collapse-all-properties />
Removing this line brought us back to 18 permutations and deploying the WAR folder to my tomcat webapps directory did the job. Compiling only once was not generating the file used required by my locale. Maybe if my browser language would have been in English it would have worked out the first time.
Well now it works as all the required files are correctly compiled.

How to set a custom 404 page in JBoss 5?

How to set a custom 404 page in JBoss 5?
In general handling custom error pages is more to do with the servlet spec rather than the actual application container. Consequently, the most common place to put this is in your web.xml, like this:
<error-page>
<error-code>404</error-code>
<location>/my-404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/my-500.jsp</location>
</error-page>
If the above still does not work, verify that you have the correct XSD in your web.xml, it's easy to use an old one that causes JBoss to fall back to an older version of the servlet API which doesn't recognise the above tags. In general, this one works for me with servlet 2.5:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
Out of interest, the JBoss 5.0.x and 5.1.0, the global web.xml file is located at server/<your server>/deployers/jbossweb.deployer/web.xml, and ROOT.war is at server/<your server>/deploy/ROOT.war. This will allow you to make custom error pages for all applications within the server.