2

I assemble WAR for GWT application through gradle.

When GWT is included like

dependencies {
    compile "com.google.gwt:gwt-user:2.5.1"
    compile "com.google.gwt:gwt-dev:2.5.1"
    ...
}

then I have gwt-user.jar and gwt-dev.jar in resulting WAR file. They are not really needed and are big. If I delete these jars from WAR - application works well.

But when I try to assemble WAR without these jars inside using

dependencies {
    providedCompile "com.google.gwt:gwt-user:2.5.1"
    providedCompile "com.google.gwt:gwt-dev:2.5.1"
    ...
}

then the application cannot start in tomcat saying

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [application-context.xml]: Invocation of init method failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)

and other strange error messages.

How can I correctly exclude just gwt-user and gwt-dev jars from gradle build?

Andrey Regentov
  • 3,687
  • 4
  • 34
  • 40
  • 1
    Looks like some other jars are missing from WAR too... I'll dig into it – Andrey Regentov Apr 02 '14 at 09:36
  • Yep. (1) `providedCompile` instead of `compile` on gwt causes validation-api*.jar to disappear from WAR. (2) Missing validation-api causes application to fail. But why in the world (1) happens? – Andrey Regentov Apr 02 '14 at 09:46

1 Answers1

1

Other jars that are listed in compile section did disappear from WAR too. It can be quickchecked (you may not assemble the whole war) with

gradle :dependencies

and checking providedCompile section. In my case it was validation-api as subdependency of gwt-user.

+--- com.google.gwt:gwt-user:2.5.1
|    +--- javax.validation:validation-api:1.0.0.GA
|    \--- org.json:json:20090211
+--- com.google.gwt:gwt-dev:2.5.1
|    \--- org.json:json:20090211
\--- javax.servlet:servlet-api:2.5

It is required by the app and its jar was removed resulting WAR.

To persist them, I had to write the following in build.gradle:

providedCompile ("com.google.gwt:gwt-user:$gwtVersion") {
    transitive = false;
}
providedCompile ("com.google.gwt:gwt-dev:$gwtVersion") {
    transitive = false;
}

and everything went ok.

Andrey Regentov
  • 3,687
  • 4
  • 34
  • 40