大家好!将 Web 应用程序部署到 tomcat 服务器。通过intellij idea这里具有这样的特点:
<component name="ArtifactManager">
<artifact type="exploded-war" build-on-make="true" name="webrp:war exploded">
<output-path>$PROJECT_DIR$/target/webrp-1.0</output-path>
<root id="root">
<element id="directory" name="WEB-INF">
<element id="directory" name="classes">
<element id="module-output" name="webrp" />
</element>
<element id="directory" name="lib">
<element id="library" level="project" name="Maven: com.vaadin:vaadin-server:7.6.7" />
<element id="library" level="project" name="Maven: com.vaadin:vaadin-sass-compiler:0.9.13" />
<element id="library" level="project" name="Maven: com.vaadin.external.flute:flute:1.3.0.gg2" />
<element id="library" level="project" name="Maven: com.yahoo.platform.yui:yuicompressor:2.4.8" />
<element id="library" level="project" name="Maven: rhino:js:1.7R2" />
<element id="library" level="project" name="Maven: com.vaadin:vaadin-shared:7.6.7" />
<element id="library" level="project" name="Maven: com.vaadin.external.streamhtmlparser:streamhtmlparser-jsilver:0.0.10.vaadin1" />
<element id="library" level="project" name="Maven: com.vaadin.external.google:guava:16.0.1.vaadin1" />
<element id="library" level="project" name="Maven: org.jsoup:jsoup:1.8.3" />
<element id="library" level="project" name="Maven: com.vaadin:vaadin-push:7.6.7" />
<element id="library" level="project" name="Maven: com.vaadin.external.atmosphere:atmosphere-runtime:2.2.7.vaadin1" />
<element id="library" level="project" name="Maven: com.vaadin.external.slf4j:vaadin-slf4j-jdk14:1.6.1" />
<element id="library" level="project" name="Maven: org.w3c.css:sac:1.3" />
<element id="library" level="project" name="Maven: com.vaadin:vaadin-themes:7.6.7" />
<element id="library" level="project" name="Maven: org.tltv.gantt:gantt-addon:0.9.3" />
</element>
</element>
<element id="javaee-facet-resources" facet="webrp/web/Web" />
</root>
</artifact>
</component>
结果,我有一个错误:
Aug 09, 2016 9:51:40 AM com.vaadin.server.VaadinServlet serveStaticResourcesInVAADIN
INFO: Requested resource [/VAADIN/widgetsets/ru.comp.webgrp.MyAppWidgetset/ru.comp.webgrp.MyAppWidgetset.nocache.js] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
网上介绍的那些方法都不管用,有的也不适合。据我了解,问题是 vaadin 本身不编译。添加更多时出现相同的错误gwt-compiler-output
如果我们添加整个输出:
<component name="ArtifactManager">
<artifact type="exploded-war" build-on-make="true" name="webrp:war exploded">
<output-path>$PROJECT_DIR$/target/webrp-1.0</output-path>
<root id="root">
<element id="directory" name="WEB-INF">
<element id="directory" name="classes">
<element id="module-output" name="webrp" />
</element>
<element id="directory" name="lib">
<element id="library" level="project" name="Maven: com.vaadin:vaadin-server:7.6.7" />
<element id="library" level="project" name="Maven: com.vaadin:vaadin-sass-compiler:0.9.13" />
<element id="library" level="project" name="Maven: com.vaadin.external.flute:flute:1.3.0.gg2" />
<element id="library" level="project" name="Maven: com.yahoo.platform.yui:yuicompressor:2.4.8" />
<element id="library" level="project" name="Maven: rhino:js:1.7R2" />
<element id="library" level="project" name="Maven: com.vaadin:vaadin-shared:7.6.7" />
<element id="library" level="project" name="Maven: com.vaadin.external.streamhtmlparser:streamhtmlparser-jsilver:0.0.10.vaadin1" />
<element id="library" level="project" name="Maven: com.vaadin.external.google:guava:16.0.1.vaadin1" />
<element id="library" level="project" name="Maven: org.jsoup:jsoup:1.8.3" />
<element id="library" level="project" name="Maven: com.vaadin:vaadin-push:7.6.7" />
<element id="library" level="project" name="Maven: com.vaadin.external.atmosphere:atmosphere-runtime:2.2.7.vaadin1" />
.........................................
<element id="library" level="project" name="Maven: org.codehaus.jackson:jackson-xc:1.9.12" />
</element>
</element>
<element id="javaee-facet-resources" facet="webrp/web/Web" />
<element id="directory" name="VAADIN">
<element id="directory" name="widgetsets">
<element id="gwt-compiler-output" facet="webrp/gwt/GWT" />
</element>
</element>
</root>
</artifact>
</component>
然后我得到一个错误:
SEVERE: Allocate exception for servlet WebrpUIServlet
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/vaadin/server/BootstrapHandler.setupStandaloneDocument(Lcom/vaadin/server/BootstrapHandler$BootstrapContext;Lcom/vaadin/server/BootstrapPageResponse;)V @54: invokevirtual
Reason:
Type 'org/jsoup/nodes/DocumentType' (current frame, stack[1]) is not assignable to 'org/jsoup/nodes/Node'
Current Frame:
bci: @54
flags: { }
locals: { 'com/vaadin/server/BootstrapHandler', 'com/vaadin/server/BootstrapHandler$BootstrapContext', 'com/vaadin/server/BootstrapPageResponse', 'org/jsoup/nodes/Document', 'org/jsoup/nodes/DocumentType' }
stack: { 'org/jsoup/nodes/Element', 'org/jsoup/nodes/DocumentType' }
Bytecode:
0x0000000: 2c12 4b12 4cb6 004d 2c12 4e12 4cb6 004d
0x0000010: 2c12 4f09 b600 502c b600 514e bb00 5259
0x0000020: 1253 121e 121e 2db6 0054 b700 553a 042d
0x0000030: 03b6 0056 1904 b600 5757 2db6 0058 3a05
0x0000040: 1905 1259 b600 5a12 5b12 5cb6 005d 125e
0x0000050: 125f b600 5d57 1905 1259 b600 5a12 5b12
0x0000060: 60b6 005d 125e 1261 b600 5d57 2bb6 0022
0x0000070: 3a06 013a 0719 0613 0062 b600 63c0 0062
0x0000080: 3a08 1906 1300 64b6 0063 c000 643a 0919
0x0000090: 08c6 003e 1909 c600 39bb 0065 59bb 002c
0x00000a0: 59b7 002d 1906 b600 66b6 0031 1267 b600
0x00000b0: 3113 0062 b600 68b6 0031 1269 b600 3113
0x00000c0: 0064 b600 68b6 0031 b600 32b7 006a bf19
0x00000d0: 08c6 000f 1908 b900 6b01 003a 07a7 004a
0x00000e0: 1909 c600 4519 09b9 006c 0100 3a0a 190a
0x00000f0: b600 6dc0 006e 2bb6 0018 b900 6f02 003a
0x0000100: 07a7 0026 3a0b bb00 3d59 bb00 2c59 b700
0x0000110: 2d12 71b6 0031 190a b600 66b6 0031 b600
0x0000120: 3219 0bb7 0072 bf19 07c6 0019 1905 1259
0x0000130: b600 5a12 7312 74b6 005d 125e 1907 b600
0x0000140: 5d57 2cb6 0075 bb00 7659 2bb6 0018 2bb6
0x0000150: 0022 b700 77b6 0078 3a0a 190a c600 1019
0x0000160: 0512 79b6 005a 190a b600 7a57 1905 127b
0x0000170: b600 5a12 7c12 7db6 005d 127e b600 7a57
0x0000180: 2bb6 007f 3a0b 190b c600 6a2a 2b19 0bb6
0x0000190: 0080 3a0c 1905 1281 b600 5a12 8212 83b6
0x00001a0: 005d 127c 1284 b600 5d12 85bb 002c 59b7
0x00001b0: 002d 190c b600 3112 86b6 0031 b600 32b6
0x00001c0: 005d 5719 0512 81b6 005a 1282 1287 b600
0x00001d0: 5d12 7c12 84b6 005d 1285 bb00 2c59 b700
0x00001e0: 2d19 0cb6 0031 1286 b600 31b6 0032 b600
0x00001f0: 5d57 1906 1300 88b6 0063 c000 883a 0c19
0x0000200: 0cc6 004d 190c b900 8901 003a 0d19 0d3a
0x0000210: 0e19 0ebe 360f 0336 1015 1015 0fa2 0031
0x0000220: 190e 1510 323a 112a 2b19 0619 11b7 008a
0x0000230: 3a12 1905 128b b600 5a12 7c12 8cb6 005d
0x0000240: 128d 1912 b600 5d57 8410 01a7 ffce 1906
0x0000250: 1300 8eb6 0063 c000 8e3a 0d19 0dc6 0054
0x0000260: 190d b900 8f01 003a 0e19 0e3a 0f19 0fbe
0x0000270: 3610 0336 1115 1115 10a2 0038 190f 1511
0x0000280: 323a 122a 2b19 0619 12b7 008a 3a13 1905
0x0000290: 1281 b600 5a12 8212 90b6 005d 127c 127d
0x00002a0: b600 5d12 8519 13b6 005d 5784 1101 a7ff
0x00002b0: c72d b600 263a 0e19 0e12 9112 92b6 005d
0x00002c0: 5719 0e12 93b6 0094 57b1
Exception Handler Table:
bci [238, 257] => handler: 260
Stackmap Table:
full_frame(@207,{Object[#310],Object[#341],Object[#346],Object[#345],Object[#397],Object[#347],Object[#316],Object[#398],Object[#399],Object[#400]},{})
same_frame(@224)
full_frame(@260,{Object[#310],Object[#341],Object[#346],Object[#345],Object[#397],Object[#347],Object[#316],Object[#398],Object[#399],Object[#400],Object[#316]},{Object[#401]})
chop_frame(@295,1)
same_frame(@322)
append_frame(@364,Object[#398])
append_frame(@498,Object[#398])
full_frame(@537,{Object[#310],Object[#341],Object[#346],Object[#345],Object[#397],Object[#347],Object[#316],Object[#398],Object[#399],Object[#400],Object[#398],Object[#398],Object[#402],Object[#403],Object[#403],Integer,Integer},{})
full_frame(@590,{Object[#310],Object[#341],Object[#346],Object[#345],Object[#397],Object[#347],Object[#316],Object[#398],Object[#399],Object[#400],Object[#398],Object[#398],Object[#402]},{})
full_frame(@629,{Object[#310],Object[#341],Object[#346],Object[#345],Object[#397],Object[#347],Object[#316],Object[#398],Object[#399],Object[#400],Object[#398],Object[#398],Object[#402],Object[#404],Object[#403],Object[#403],Integer,Integer},{})
full_frame(@689,{Object[#310],Object[#341],Object[#346],Object[#345],Object[#397],Object[#347],Object[#316],Object[#398],Object[#399],Object[#400],Object[#398],Object[#398],Object[#402],Object[#404]},{})
at com.vaadin.server.VaadinServletService.createRequestHandlers(VaadinServletService.java:49)
at com.vaadin.server.VaadinService.init(VaadinService.java:191)
at com.vaadin.server.VaadinServlet.createServletService(VaadinServlet.java:317)
at com.vaadin.server.VaadinServlet.init(VaadinServlet.java:223)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1238)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1151)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:828)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
这是 WebrUI 的样子:
@Theme("valo")
@Widgetset("ru.comp.webgrp.MyAppWidgetset")
@Title(value = "Планирование")
public class WebrpUI extends UI {
private Navigator navigator;
@Override
protected void init(VaadinRequest request) {
navigator = new Navigator(this, this);
navigator.addView("", ResourcesView.class);
navigator.addView("resources", ResourcesView.class);
}
@WebServlet(urlPatterns = "/*", name = "WebrpUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = WebrpUI.class, productionMode = false)
public static class WebrpUIServlet extends VaadinServlet {
}
}
聚甲醛
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<encoding>${project.encoding}</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>${project.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Exclude some unnecessary files generated by the GWT compiler. -->
<packagingExcludes>WEB-INF/classes/VAADIN/gwt-unitCache/**,
WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.plugin.version}</version>
<configuration>
<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
<webappDirectory>${basedir}/target/classes/VAADIN/widgetsets</webappDirectory>
<draftCompile>false</draftCompile>
<compileReport>false</compileReport>
<style>OBF</style>
<strict>true</strict>
<runTarget>http://localhost:8080/webrp</runTarget>
</configuration>
<executions>
<execution>
<goals>
<goal>update-theme</goal>
<goal>update-widgetset</goal>
<goal>compile</goal>
<!-- disabled by default to use on-the-fly theme compilation -->
<!-- <goal>compile-theme</goal> -->
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6.1</version>
<!-- Clean up also any pre-compiled themes -->
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/VAADIN/themes</directory>
<includes>
<include>**/styles.css</include>
<include>**/styles.scss.cache</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<!-- The Jetty plugin allows us to easily test the development build by
running jetty:run on the command line. -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.plugin.version}</version>
<configuration>
<scanIntervalSeconds>2</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
也许问题在于执行mvn clrean installand时mvn clean vaadin:compile跳过了以下步骤:
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ webrp ---
[INFO] Deleting C:\svn\tmpTrunk\webrp\target
[INFO] Deleting C:\svn\tmpTrunk\webrp\src\main\webapp\VAADIN\themes (includes = [**/styles.css, **/styles.scss.cache], excludes = [])
[INFO]
[INFO] --- vaadin-maven-plugin:7.6.7:update-theme (default) @ webrp ---
[INFO] Theme processing is skipped
[INFO]
[INFO] --- vaadin-maven-plugin:7.6.7:update-widgetset (default) @ webrp ---
[INFO] GWT compilation is skipped
[INFO]
[INFO] >>> vaadin-maven-plugin:7.6.7:compile (default) @ webrp >>>
[INFO]
[INFO] --- vaadin-maven-plugin:7.6.7:update-theme (default) @ webrp ---
[INFO] Theme processing is skipped
[INFO]
[INFO] <<< vaadin-maven-plugin:7.6.7:compile (default) @ webrp <<<
[INFO]
[INFO] --- vaadin-maven-plugin:7.6.7:compile (default) @ webrp ---
[INFO] GWT compilation is skipped
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ webrp ---
[INFO] Installing C:\svn\tmpTrunk\webrp\pom.xml to C:\Users\s\.m2\repository\ru\comp\webrp\1.0\webrp-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.162s
[INFO] Finished at: Tue Aug 09 10:06:32 MSK 2016
[INFO] Final Memory: 27M/445M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
告诉我如何解决这个问题?
问题本身
pom,有必要指出<packaging>war</packaging>