1

I am using gwt-maven-plugin and eclipse to create GWT+Spring webapp. In the end I want to get .war file to be deployed to some application server(tomcat etc). The problem is that the generated .war file has strange structure. enter image description here

And then I run in on Tomcat the application doesn't work - SimpleGWT.html page has a link to javascript file which does all the job

<script type="text/javascript" language="javascript" src="SimpleGWT/SimpleGWT.nocache.js"></script>

My guess is that since the SimpleGWT.nocache.js in located inside SimpleGWT folder which is not inside WEB-INF - it is not accessible Is there any way to alter options of gwt-maven-plugin in order to get normal webapp structure? Here is part of my pom.xml

<!-- GWT Maven Plugin -->
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>gwt-maven-plugin</artifactId>
    <version>2.6.0</version>
    <executions>
      <execution>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
    <!-- Plugin configuration. There are many available options, see 
      gwt-maven-plugin documentation at codehaus.org -->
    <configuration>
        <inplace>true</inplace>
      <runTarget>SimpleGWT.html</runTarget>
      <hostedWebapp>${webappDirectory}</hostedWebapp>
      <i18nMessagesBundle>com.javacodegeeks.gwtspring.client.Messages</i18nMessagesBundle>
    </configuration>
  </plugin>
Russell'sTeapot
  • 373
  • 2
  • 11
  • 21
  • What do you mean by "normal webapp structure", your WAR looks good to me. (your `SimpleGWT.html` and `SimpleGWT.css` are not in `WEB-INF` right? so why do you want `SimpleGWT.nocache.js` to be in `WEB-INF`?) What's the exact error/problem you're seeing deploying this WAR file to Tomcat? – Thomas Broyer Apr 01 '14 at 10:13
  • Tomcat does not complain. When SimpleGWT.html get loaded it says that SimpleGWT/SimpleGWT.nocache.js - 404 not found. When I put this script into WEB-INF by manually reassembling war it works – Russell'sTeapot Apr 01 '14 at 10:45

1 Answers1

0

Its the issue that is mostly related to access static resources in an HTML page.

You are using relative path that does not have a "/" prefix. That is an absolute path pointing to the root of the web-server.

In Spring MVC application org.springframework.web.servlet.DispatcherServlet is responsible fore serving all the contents for web apps.

What have you defined as url-pattern for above servlet mapping? Please try with *.html or /* as url-pattern.

For more information read about Unable to load java script files in Jetty webapplication.

Community
  • 1
  • 1
Braj
  • 46,415
  • 5
  • 60
  • 76
  • Braj, nochace.js is not missing from war. It is inside SimpleGWT folder. But when this war is generated this folder ends up not being inside WEB-INF. So when I run this war on apache tomcat the browser can't download the script because it is not inside WEB-INF. I tried and manually put SimpleGWT folder inside WEB-INF and then app works perfect. However manually reassembling war file seems to me kind of blasphemous ))) – Russell'sTeapot Apr 02 '14 at 05:46
  • What is the value of `${webappDirectory}`? – Braj Apr 02 '14 at 05:53
  • mmm sorry... you mean in maven war plugin? I use eclipse with maven plugin. Inside my pom I don't have war plugin. Maybe I should post my pom.xml? – Russell'sTeapot Apr 02 '14 at 05:59
  • I found what I needed http://stackoverflow.com/questions/16295347/maven-how-to-copy-sub-folders-and-their-content-in-a-different-structure – Russell'sTeapot Apr 04 '14 at 08:52