Hi all,
I've a problem with the generated web.xml by the gwt maven plugin.
We have a module called 'com.pirobase.pim.gwt.dashboard' which
inherits widgets (also our code) which inherits services (also our
code). If I compile the dashboard application the web.xml will be
merged. In the pom.xml the parameter 'webXmlServletPathAsIs' is set to
'false'.
The merged web.xml contains after the build entries like:
<servlet-mapping>
<servlet-name>com.pirobase.pim.gwt.servlets.ItemGridServlet/
com.pirobase.pim.gwt.dashboard/ItemGridServlet</servlet-name>
<url-pattern>/com.pirobase.pim.gwt.dashboard/ItemGridServlet</url-
pattern>
</servlet-mapping>
This is ok up to this point. Now I wanted to created a ear file for
use it on a jboss. Because the name was too long i renamed the module
to 'dashboard' with the rename-to attribute in the gwt.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<module rename-to="dashboard">
...
</module>
The problem is now, that this dont affect the merged web.xml and the
context path of the application is not the same like the ones from the
mapped servlets => the application doesn't work.
For testing purpose I made some changes in the class
GwtWebInfProcessor:
Index: src/main/java/com/totsp/mavenplugin/gwt/support/
GwtWebInfProcessor.java
===================================================================
--- src/main/java/com/totsp/mavenplugin/gwt/support/
GwtWebInfProcessor.java (Revision 955)
+++ src/main/java/com/totsp/mavenplugin/gwt/support/
GwtWebInfProcessor.java (Arbeitskopie)
@@ -25,6 +25,7 @@
import java.util.HashSet;
import java.util.List;
+import org.jdom.Attribute;
import org.jdom.Comment;
import org.jdom.Content;
import org.jdom.Document;
@@ -73,7 +74,7 @@
throw new Exception("Unable to locate module definition
file: " + moduleName.replace('.', '/') + ".gwt.xml");
}
- this.servletDescriptors = this.getGwtServletDescriptors
(moduleName, webXmlServletPath);
+ this.servletDescriptors = this.getGwtServletDescriptors
(moduleName, webXmlServletPath, null);
if (this.servletDescriptors.size() == 0) {
throw new ExitException("No servlets found.");
@@ -103,7 +104,7 @@
this.destination = new File(targetWebXml);
- this.servletDescriptors = this.getGwtServletDescriptors(null,
webXmlServletPath);
+ this.servletDescriptors = this.getGwtServletDescriptors(null,
webXmlServletPath, null);
if (this.servletDescriptors.size() == 0) {
throw new ExitException("No servlets found.");
@@ -117,7 +118,7 @@
* @param webXmlServletPath
* @return
*/
- protected List getGwtServletDescriptors(String module, boolean
webXmlServletPath) throws IOException, JDOMException {
+ protected List getGwtServletDescriptors(String module, boolean
webXmlServletPath, String servletPathModuleName) throws IOException,
JDOMException {
///System.out.println("GwtWebInfProcessor
getGwtServletDescriptors (module - " + module + ")");
@@ -161,11 +162,27 @@
Element element = document.getRootElement();
List inherits = element.getChildren("inherits");
-
+
+ if (servletPathModuleName == null) {
+ Attribute renamedModuleName = element.getAttribute("rename-
to");
+
+ if (renamedModuleName != null) {
+ servletPathModuleName = renamedModuleName.getValue();
+ } else {
+ servletPathModuleName = this.moduleName;
+ }
+ }
+
for (int i = 0; (inherits != null) && (i < inherits.size()); i+
+) {
Element inherit = (Element) inherits.get(i);
- if (!checkedModules.contains(inherit.getAttributeValue
("name")))
- servletElements.addAll(this.getGwtServletDescriptors
(inherit.getAttributeValue("name"), webXmlServletPath));
+ if (!checkedModules.contains(inherit.getAttributeValue
("name"))) {
+ servletElements.addAll(
+ this.getGwtServletDescriptors(
+ inherit.getAttributeValue("name"),
+ webXmlServletPath,
+ servletPathModuleName != null ?
servletPathModuleName : inherit.getAttributeValue("name")
+ ));
+ }
}
List servlets = element.getChildren("servlet");
@@ -178,7 +195,7 @@
if (webXmlServletPath) {
servletPath = servlet.getAttributeValue("path");
} else {
- servletPath = "/" + this.moduleName +
servlet.getAttributeValue("path");
+ servletPath = "/" + servletPathModuleName +
servlet.getAttributeValue("path");
}
String servletClass = servlet.getAttributeValue("class");
ServletDescriptor servletDesc = new ServletDescriptor
(servletPath, servletClass);
I checked if the master gwt.xml has a rename-to attributes and read
the new module name.
This name is used in all recursive method calls for generate the
servlet-mapping entry.
With this web.xml I can successfull deploy my application in any
application server.
If this change is ok it would by nice if someone can integrate it. Or
is there another way
for merge the web.xml so the renamed module name is part of the
mapping?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"gwt-maven" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/gwt-maven?hl=en
-~----------~----~----~----~------~----~------~--~---