我正在尝试将 maven 集成到我现有的 Vaadin 项目中。有几个错误和奇怪的事情。首先,我不明白我应该怎么做才能使 maven 使用的 tomcat 实例在 eclipse 中可见。我的意思是,当我运行 tomcat7:run 时,在 eclipse 中预先配置的 Tomcat 实例保持停止。我也无法理解 maven 使用哪个 Tomcat 实例以及为什么它在项目文件夹中创建 Tomcat 配置文件,因为当我尝试在 tomcat7:run 之后在浏览器中打开应用程序时,我收到错误 404。
顺便说一下,有几个关于Vaadin 小部件的编译。我配置了 vaadin maven 插件和 gwt maven 插件。当我运行 mvn gwt:compile 时,似乎一切正常,但是当我尝试使用 eclipse 插件编译 Vaadin 小部件时,出现以下错误
Executing compiler with parameters [C:\Program Files\Java\jdk1.7.0_03\bin\java.exe, -Djava.awt.headless=true, -Xss8M, -Xmx512M, -XX:MaxPermSize=512M, -classpath, C:\Program Files\Java\jre7\lib\resources.jar;C:\Program Files\Java\jre7\lib\rt.jar;C:\Program Files\Java\jre7\lib\jsse.jar;C:\Program Files\Java\jre7\lib\jce.jar;C:\Program Files\Java\jre7\lib\charsets.jar;C:\Program Files\Java\jre7\lib\ext\dnsns.jar;C:\Program Files\Java\jre7\lib\ext\localedata.jar;C:\Program Files\Java\jre7\lib\ext\sunec.jar;C:\Program Files\Java\jre7\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jre7\lib\ext\sunmscapi.jar;C:\Program Files\Java\jre7\lib\ext\zipfs.jar;C:/Popov/Ohta/src/main/java;C:/Popov/Ohta/src/test/java;C:/Popov/Ohta/target/classes;C:/Popov/Ohta/target/test-classes;C:/Popov/newEclipse/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-dev/2.3.0/gwt-dev.jar;C:/Users/popov/.m2/repository/com/google/gwt/gwt-user/2.1.1/gwt-user-2.1.1.jar;C:/Users/popov/.m2/repository/com/vaadin/vaadin/6.8.2/vaadin-6.8.2.jar;C:/Users/popov/.m2/repository/org/vaadin/addons/refresher/1.1.1/refresher-1.1.1.jar;C:/Users/popov/.m2/repository/org/vaadin/addons/vaadin-colorpicker/1.1.0/vaadin-colorpicker-1.1.0.jar;C:/Users/popov/.m2/repository/com/google/gwt/gwt-user/2.3.0/gwt-user-2.3.0.jar;C:/Users/popov/.m2/repository/com/vaadin/vaadin/6.8.8/vaadin-6.8.8.jar, -Dgwt.persistentunitcachedir=C:\Users\popov\AppData\Local\Temp\widgetset_com.ritmsoft.ohta.widgetset.OhtaWidgetset943bcbe5-0ae3-4759-b1c0-d878be4261f9, com.vaadin.tools.WidgetsetCompiler, -war, src/main/webapp/VAADIN/widgetsets, -deploy, C:\Users\popov\AppData\Local\Temp\widgetset_com.ritmsoft.ohta.widgetset.OhtaWidgetset943bcbe5-0ae3-4759-b1c0-d878be4261f9, -extra, C:\Users\popov\AppData\Local\Temp\widgetset_com.ritmsoft.ohta.widgetset.OhtaWidgetset943bcbe5-0ae3-4759-b1c0-d878be4261f9, -localWorkers, 2, -logLevel, INFO, com.ritmsoft.ohta.widgetset.OhtaWidgetset]
Updating GWT module description file...
фев 12, 2013 7:36:08 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
INFO: Widgetsets found from classpath:
com.github.wolfie.refresher.RefresherApplicationWidgetset in jar:file:C:/Users/popov/.m2/repository/org/vaadin/addons/refresher/1.1.1/refresher-1.1.1.jar!/
com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:C:/Users/popov/.m2/repository/com/vaadin/vaadin/6.8.8/vaadin-6.8.8.jar!/
com.vaadin.addon.colorpicker.gwt.ColorPickerWidgetSet in jar:file:C:/Users/popov/.m2/repository/org/vaadin/addons/vaadin-colorpicker/1.1.0/vaadin-colorpicker-1.1.0.jar!/
com.ritmsoft.ohta.widgetset.OhtaWidgetset in file://C/Popov/Ohta/src/main/java
фев 12, 2013 7:36:08 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
INFO: Search took 24ms
Done.
Starting GWT compiler
Unknown argument: -war
Google Web Toolkit 2.3.0
GWTCompiler [-logLevel level] [-workDir dir] [-gen dir] [-style style] [-ea] [-XdisableClassMetadata] [-XdisableCastChecking] [-validateOnly] [-draftCompile] [-optimize level] [-compileReport] [-strict] [-out dir] [-localWorkers count] module[s]
where
-logLevel The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL
-workDir The compiler's working directory for internal use (must be writeable; defaults to a system temp dir)
-gen Debugging: causes normally-transient generated types to be saved in the specified directory
-style Script output style: OBF[USCATED], PRETTY, or DETAILED (defaults to OBF)
-ea Debugging: causes the compiled output to check assert statements
-XdisableClassMetadata EXPERIMENTAL: Disables some java.lang.Class methods (e.g. getName())
-XdisableCastChecking EXPERIMENTAL: Disables run-time checking of cast operations
-validateOnly Validate all source code, but do not compile
-draftCompile Enable faster, but less-optimized, compilations
-optimize Sets the optimization level used by the compiler. 0=none 9=maximum.
-compileReport Create a compile report that tells the Story of Your Compile
-strict Only succeed if no input files have errors
-out The directory to write output files into (defaults to current)
-localWorkers The number of local workers to use when compiling permutations
and
module[s] Specifies the name(s) of the module(s) to compile
Widgetset compilation failed
否则,如果我使用 mvn gwt:compile 编译小部件,然后使用 maven 构建战争并部署它,我会在浏览器中收到空白页面。
此外,当我尝试在服务器上运行应用程序时,我有以下异常
WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:Ohta' did not find a matching property.
фев 12, 2013 7:55:08 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Ohta]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/HibernateException
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 25 more
фев 12, 2013 7:55:08 PM org.apache.catalina.startup.HostConfig deployDescriptor
SEVERE: Error deploying configuration descriptor C:\Popov\Soft\conf\Catalina\localhost\Ohta.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Ohta]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
有我的 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ritmsoft</groupId>
<artifactId>Ohta</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>Ohta</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution></execution>
</executions>
<configuration>
<url>http://127.0.0.1:8080/manager/text</url>
<server>local_tomcat</server>
<path>/Ohta</path>
<username>tomcat</username>
<port>8080</port>
<username>tomcat</username>
<password>s3cret</password>
<warFile> ${project.build.directory}/Ohta.war</warFile>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>1.0.2</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>update-widgetset</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.3.0</version>
<configuration>
<webappDirectory>${basedir}/src/main/webapp/VAADIN/widgetsets/</webappDirectory>
<extraJvmArgs>-Xmx512M -Xss1024k </extraJvmArgs>
<deploy>${project.build.directory}/gwt-tmp/</deploy>
<soyc>false</soyc>
<force>true</force>
<strict>true</strict>
<style>OBFUSCATED</style>
<optimizationLevel>9</optimizationLevel>
</configuration>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>resources</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webXml>webContent\WEB-INF\web.xml</webXml>
<warName>Ohta</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<inherited>true</inherited>
<configuration>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>rg.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache
Tomcat v7.0</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.vaadin</groupId>
<artifactId>
vaadin-maven-plugin
</artifactId>
<versionRange>
[1.0.2,)
</versionRange>
<goals>
<goal>update-widgetset</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<pluginRepositories>
<pluginRepository>
<id>codehaus-snapshots</id>
<url>http://nexus.codehaus.org/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.9.Final</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin</artifactId>
<version>6.8.8</version>
</dependency>
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>vaadin-colorpicker</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>refresher</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.2-pre7</version>
</dependency>
<dependency>
<groupId>org.glassfish.metro</groupId>
<artifactId>webservices-rt</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.22</version>
</dependency>
</dependencies>
</project>
请帮帮我。