将Eclipse App Engine项目转换为Maven?

时间:2014-11-18 22:50:14

标签: java eclipse google-app-engine maven gwt

我有一个已经向AppEngine发布了几个版本的项目。在I / O和Cloud Platform事件中观看会话让我对推送部署和实时断点感到兴奋。添加额外的奖金,如Maven管理依赖项的能力,Maven对这个项目非常有吸引力。

该项目只是一个Eclipse项目,通过New>创建。 Google> Eclipse中的Web应用程序项目。目前它只是使用内置的Eclipse / Google Plugin构建。

我已完成以下任务:

  • Ran m2eclipse转换。
  • 将源移动到Maven标准目录结构中。
  • 从lib /文件夹中删除Maven可用的依赖项并添加到Maven。
  • Maven Build和Maven Unit Test都成功。
  • Ran mvn eclipse:eclipse重新构建配置,然后重新添加GAE SDK到 Java Build Path,因此Eclipse的Google插件可以看到它。

我仍然有一些问题,但是......

  1. 本地调试/运行会导致java.lang.NoClassDefFoundError: 控制台输出中的javax / mail / MessagingException。
  2. 我尝试过包含javax.mail依赖项,但我90%肯定 因为它在GAE SDK中我不应该明确列出它。
  3. 一旦服务正在运行,我会为主应用程序获得404 和管理控制台。假设这与上述有关,但是 不是100%肯定。
  4. 我们之前使用辅助AppEngine实例测试“live” 部署到生产。有没有办法设置分支 推送部署所以我们不会提前合并回主人 释放?
  5. 是否有理由通过Maven提供GWT 2.6.1,但没有 通过谷歌Eclipse回购?另外,GWT .properties文件在哪里用于Maven?我还有什么 需要转换吗?
  6. 对于一些看似有点基本的问题感到抱歉,但这是我与Maven的第一次跳舞,而且我在这个项目上独自飞行。 (我的PM不是贸易开发商,我的实习生也不知道Maven。)

    编辑:忘了张贴pom:

    <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.stripped</groupId>
      <artifactId>bogus</artifactId>
      <version>1.5.3</version>
      <packaging>war</packaging>
      <name>Stuff</name>
      <properties>
        <appengine.target.version>1.9.15</appengine.target.version>
        <gwt.target.version>2.6.1</gwt.target.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
      <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>          
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.6.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>generateAsync</goal>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <runTarget>index.html</runTarget>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <archiveClasses>true</archiveClasses>
                    <webResources>
                        <!-- in order to interpolate version from pom into appengine-web.xml -->
                        <resource>
                            <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
      </build>
      <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwt.target.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwt.target.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.objectify</groupId>
            <artifactId>objectify</artifactId>
            <version>4.1.3</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.objectify</groupId>
            <artifactId>objectify-gwt</artifactId>
            <version>1.2.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-gwt</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom2</artifactId>
            <version>2.0.5</version>
        </dependency>
        <!-- Unit Test Dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
            <version>4.11</version>
        </dependency>
      </dependencies>
    </project>
    

    EDIT2:

    我注意到调试配置指向了     -war [AbsPath] src \ main \ webapp ...没有lib /文件夹。我改成了     -war [AbsPath] target \ bogus-3.9.6 并且不再获得NoClassDefFoundError!

    但是,我现在得到了这个,这是我部署到AppEngine时获得的第一个例外。

    INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
    Nov 21, 2014 12:10:37 AM com.google.appengine.tools.development.IsolatedAppClassLoader checkWorkingDirectory
    WARNING: Your working directory, ([...]workspace\bogus\src\main\webapp) is not equal to your 
    web application root ([...]workspace\bogus\target\bogus-3.9.6)
    You will not be able to access files from your working directory on the production server.
    
    Nov 21, 2014 12:10:37 AM com.google.apphosting.utils.jetty.JettyLogger info
    INFO: jetty-6.1.x
    Nov 21, 2014 12:10:38 AM com.google.appengine.tools.development.agent.impl.Transformer transform
    SEVERE: Unable to instrument com.bogus.server.services.MailHandlerFilter. Security restrictions may not be entirely emulated.
    java.lang.ArrayIndexOutOfBoundsException: 1790
        at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:181)
        at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
        at com.google.appengine.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
        at com.google.appengine.tools.development.agent.impl.Transformer.rewrite(Transformer.java:133)
        at com.google.appengine.tools.development.agent.impl.Transformer.transform(Transformer.java:113)
        at sun.instrument.TransformerManager.transform(Unknown Source)
        at sun.instrument.InstrumentationImpl.transform(Unknown Source)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:216)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.mortbay.util.Loader.loadClass(Loader.java:91)
        at org.mortbay.util.Loader.loadClass(Loader.java:71)
        at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:73)
        at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:81)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
        at org.mortbay.jetty.Server.doStart(Server.java:224)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:255)
        at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:288)
        at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26)
        at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:87)
        at com.google.appengine.tools.development.Modules.startup(Modules.java:105)
        at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:258)
        at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
        at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:213)
        at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:211)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:211)
        at com.google.appengine.tools.development.gwt.AppEngineLauncher.start(AppEngineLauncher.java:97)
        at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
        at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
        at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
        at com.google.gwt.dev.DevMode.main(DevMode.java:322)
    
    Nov 21, 2014 12:10:38 AM com.google.apphosting.utils.jetty.JettyLogger warn
    WARNING: failed MailHandlerFilter: java.lang.ClassFormatError: Incompatible magic value 4022320623 in class file com/bogus/server/services/MailHandlerFilter
    Nov 21, 2014 12:10:38 AM com.google.apphosting.utils.jetty.JettyLogger warn
    WARNING: failed com.google.appengine.tools.development.DevAppEngineWebAppContext@77fcc757{/,[...]workspace\uswr_gwt\target\uswr_gwt-3.9.6}: java.lang.ClassFormatError: Incompatible magic value 4022320623 in class file com/bogus/server/services/MailHandlerFilter
    Nov 21, 2014 12:10:38 AM com.google.apphosting.utils.jetty.JettyLogger warn
    WARNING: failed JettyContainerService$ApiProxyHandler@7403695c: java.lang.ClassFormatError: Incompatible magic value 4022320623 in class file com/bogus/server/services/EcontrollerMailHandlerFilter
    Nov 21, 2014 12:10:38 AM com.google.apphosting.utils.jetty.JettyLogger warn
    WARNING: Error starting handlers
    java.lang.ClassFormatError: Incompatible magic value 4022320623 in class file com/bogus/server/services/EcontrollerMailHandlerFilter
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:216)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.mortbay.util.Loader.loadClass(Loader.java:91)
        at org.mortbay.util.Loader.loadClass(Loader.java:71)
        at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:73)
        at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:81)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
        at org.mortbay.jetty.Server.doStart(Server.java:224)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:255)
        at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:288)
        at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26)
        at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:87)
        at com.google.appengine.tools.development.Modules.startup(Modules.java:105)
        at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:258)
        at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
        at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:213)
        at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:211)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:211)
        at com.google.appengine.tools.development.gwt.AppEngineLauncher.start(AppEngineLauncher.java:97)
        at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
        at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
        at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
        at com.google.gwt.dev.DevMode.main(DevMode.java:322)
    

0 个答案:

没有答案