2014-06-12 730 views
1

我正在使用GWT 2.5.1和具有maven配置的requestfactory的webapp項目。實際上,我在eclipse中作爲一個獨立的項目開始了這個項目,它仍然可以正常工作。GWT Requestfactory問題與Maven + IntelliJ

但爲了集成的目的,我不得不將項目集成爲一個maven模塊並使用IntelliJ IDE。現在,當我在dev模式下啓動項目時,它可以工作,但只要我使用requestfactory,我就會得到一個Error500。我在這個主題上發現了很多話題,但我仍然無法解決它。

我想這個錯誤要麼與註釋處理相關,要麼與pom.xml配置相關。

關於使用gwt requestfactory-apt.jar配置的annotationg處理,我無法使用IntelliJ中的maven使用我的新配置獲取rep .apt_generated,就像我在eclipse中做的那樣,我不明白爲什麼。

這裏是我的Maven配置的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/maven-v4_0_0.xsd"> 
<parent> 
    <artifactId>toolkit2</artifactId> 
    <groupId>somepackage</groupId> 
    <version>v2-maven-alpha</version> 
</parent> 
<modelVersion>4.0.0</modelVersion> 
<artifactId>docentryeditor</artifactId> 
<packaging>war</packaging> 
<name>doc-entry-editor</name> 
<url>http://maven.apache.org</url> 
<repositories> 
    <repository> 
     <id>gwt-maven</id> 
     <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url> 
    </repository> 
</repositories> 

<!-- include pluginRepository and repository for GWT-Maven --> 
<pluginrepositories> 
    <pluginrepository> 
     <id>gwt-maven-plugins</id> 
     <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url> 
    </pluginrepository> 
</pluginrepositories> 
<dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.sencha.gxt</groupId> 
     <artifactId>gxt</artifactId> 
     <version>3.0.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-servlet</artifactId> 
     <classifier>deps</classifier> 
     <version>2.5.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-user</artifactId> 
     <version>2.5.1</version> 
     <scope>provided</scope> 
     <exclusions> 
      <exclusion> 
       <groupId>javax.validation</groupId> 
       <artifactId>validation-api</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>com.google.web.bindery</groupId> 
     <artifactId>requestfactory-server</artifactId> 
     <version>2.5.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.web.bindery</groupId> 
     <artifactId>requestfactory-apt</artifactId> 
     <version>2.5.1</version> 
    </dependency> 
    <dependency> 
     <groupId>aopalliance</groupId> 
     <artifactId>aopalliance</artifactId> 
     <version>1.0</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.gwt.inject</groupId> 
     <artifactId>gin</artifactId> 
     <version>1.5.0</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.inject</groupId> 
     <artifactId>guice</artifactId> 
     <version>3.0</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.inject.extensions</groupId> 
     <artifactId>guice-servlet</artifactId> 
     <version>3.0</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.inject.extensions</groupId> 
     <artifactId>guice-assistedinject</artifactId> 
     <version>3.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-validator</artifactId> 
     <version>5.1.1.Final</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.annotation</groupId> 
     <artifactId>jsr250-api</artifactId> 
     <version>1.0-20050927.133100</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.0.0.GA</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.0.0.GA</version> 
     <classifier>sources</classifier> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.7</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.7.7</version> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.17</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-fileupload</groupId> 
     <artifactId>commons-fileupload</artifactId> 
     <version>1.3.1</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-io</groupId> 
     <artifactId>commons-io</artifactId> 
     <version>2.4</version> 
    </dependency> 

</dependencies> 
<build> 
    <finalName>docentryeditor</finalName> 
    <!-- Generate compiled stuff in the folder used for developing mode --> 
    <!--<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>--> 
    <plugins> 
     <!-- GWT Maven Plugin --> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>gwt-maven-plugin</artifactId> 
      <version>2.5.1</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>compile</goal> 
         <goal>test</goal> 
         <goal>i18n</goal> 
         <goal>generateAsync</goal> 
        </goals> 
       </execution> 
      </executions> 
      <!-- Plugin configuration. There are many available options, see gwt-maven-plugin 
       documentation at codehaus.org --> 
      <configuration> 
       <runTarget>XDS-MetadataEditor.html</runTarget> 
       <hostedWebapp>${webappDirectory}</hostedWebapp> 

      </configuration> 
     </plugin> 

     <!-- Copy static web files before executing gwt:run --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.1.1</version> 
      <executions> 
       <execution> 
        <phase>compile</phase> 
        <goals> 
         <goal>exploded</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <webappDirectory>${webappDirectory}</webappDirectory> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 

     <!-- RequestFactory Validation jar --> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.5.1</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
      <dependencies> 
       <dependency> 
        <groupId>com.google.web.bindery</groupId> 
        <artifactId>requestfactory-apt</artifactId> 
        <version>2.5.1</version> 
       </dependency> 
      </dependencies> 
     </plugin> 
    </plugins> 
    <resources> 
     <resource> 
      <directory>src/main/java</directory> 
      <includes> 
       <include>**/client/**</include> 
       <include>**/*.gwt.xml</include> 
      </includes> 
     </resource> 
    </resources> 
</build> 

這裏是我的註釋處理的配置: enter image description here

,最終,這是我得到的錯誤:

SEVERE: Server Error 500 <html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> 
<title>Error 500 javax/validation/ParameterNameProvider</title> 
</head> 
<body><h2>HTTP ERROR: 500</h2><pre>javax/validation/ParameterNameProvider</pre> 
<p>RequestURI=/gwtRequest</p><h3>Caused by:</h3><pre>java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider 
    at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:41) 
    at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269) 
    at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111) 
    at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.<clinit>(ReflectiveServiceLayer.java:60) 
    at com.google.web.bindery.requestfactory.server.ServiceLayer.create(ServiceLayer.java:75) 
    at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.<init>(RequestFactoryServlet.java:103) 
    at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.<init>(RequestFactoryServlet.java:89) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
    at java.lang.Class.newInstance(Class.java:374) 
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153) 
    at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339) 
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463) 
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) 
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) 
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) 
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729) 
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at org.mortbay.jetty.Server.handle(Server.java:324) 
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) 
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843) 
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647) 
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) 
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) 
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) 
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488) 
Caused by: java.lang.ClassNotFoundException: javax.validation.ParameterNameProvider 
    at java.lang.ClassLoader.findClass(ClassLoader.java:531) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358) 
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:352) 
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337) 
    ... 31 more 
</pre> 
<h3>Caused by:</h3><pre>java.lang.ClassNotFoundException: javax.validation.ParameterNameProvider 
    at java.lang.ClassLoader.findClass(ClassLoader.java:531) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358) 
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:352) 
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337) 
    at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:41) 
    at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269) 
    at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111) 
    at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.<clinit>(ReflectiveServiceLayer.java:60) 
    at com.google.web.bindery.requestfactory.server.ServiceLayer.create(ServiceLayer.java:75) 
    at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.<init>(RequestFactoryServlet.java:103) 
    at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.<init>(RequestFactoryServlet.java:89) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
    at java.lang.Class.newInstance(Class.java:374) 
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153) 
    at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339) 
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463) 
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) 
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) 
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) 
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729) 
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at org.mortbay.jetty.Server.handle(Server.java:324) 
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) 
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843) 
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647) 
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) 
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) 
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) 
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488) 
</pre> 
<p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             

</body> 
</html> 

ERROR: Uncaught exception escaped 
com.google.web.bindery.event.shared.UmbrellaException: Exception caught: Server Error 500 <html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> 
<title>Error 500 javax/validation/ParameterNameProvider</title> 
</head> 
<body><h2>HTTP ERROR: 500</h2><pre>javax/validation/ParameterNameProvider</pre> 
<p>RequestURI=/gwtRequest</p><h3>Caused by:</h3><pre>java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider 
    at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:41) 
    at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269) 
    at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111) 
    at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.<clinit>(ReflectiveServiceLayer.java:60) 
    at com.google.web.bindery.requestfactory.server.ServiceLayer.create(ServiceLayer.java:75) 
    at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.<init>(RequestFactoryServlet.java:103) 
    at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.<init>(RequestFactoryServlet.java:89) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
    at java.lang.Class.newInstance(Class.java:374) 
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153) 
    at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339) 
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463) 
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) 
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) 
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) 
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729) 
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at org.mortbay.jetty.Server.handle(Server.java:324) 
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) 
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843) 
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647) 
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) 
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) 
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) 
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488) 
Caused by: java.lang.ClassNotFoundException: javax.validation.ParameterNameProvider 
    at java.lang.ClassLoader.findClass(ClassLoader.java:531) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358) 
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:352) 
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337) 
    ... 31 more 
</pre> 
<h3>Caused by:</h3><pre>java.lang.ClassNotFoundException: javax.validation.ParameterNameProvider 

如果有人能幫助我解決這個問題,我將非常感激。

回答

0

我終於解決了。

看來我對這個問題都是錯誤的。的確,我的問題與pom.xml中的Maven配置有關,用於bean驗證。我使用的是過時的hibernate版本,只能降級到休眠4.3.1。

<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-validator</artifactId> 
    <version>4.3.1.Final</version> 
</dependency> 
+0

http://stackoverflow.com/questions/14730329/jpa-2-0-exception-to-use-javax-validation-package-in-jpa-2-0 – RadASM