heroku示例应用程序错误

时间:2012-04-16 06:10:36

标签: java deployment heroku

我在这里做示例应用https://github.com/heroku/devcenter-embedded-tomcat

我使用'mvn package'运行应用程序并且构建成功..但是当我使用“sh target / bin / webapp”运行脚本时,我得到以下错误。请帮助..谢谢

  

C:\ Documents and   设置\ srinivasa \ Documents \ workspace-sts-2.9.0.RELEASE \ sriniv as> sh   target / bin / webapp线程“main”中的异常   java.lang.NoClassDefFoundError:launch / Main引起:   java.lang.ClassNotFoundException:launch.Main           在java.net.URLClassLoader $ 1.run(URLClassLoader.java:202)           at java.security.AccessController.doPrivileged(Native Method)           在java.net.URLClassLoader.findClass(URLClassLoader.java:190)           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)           在sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:301)           在java.lang.ClassLoader.loadClass(ClassLoader.java:247)找不到主类:launch.Main。程序将退出。

@james先生,请帮助我收到此错误

C:\Documents and Settings\srinivasa\Documents\workspace-sts-2.9.0.RELEASE\testhe
roku\target\bin>webapp.bat
configuring app with basedir: C:\Documents and Settings\srinivasa\Documents\work
space-sts-2.9.0.RELEASE\testheroku\target\bin\.\src\main\webapp
Apr 16, 2012 8:12:01 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Apr 16, 2012 8:12:01 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Apr 16, 2012 8:12:01 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.22
Apr 16, 2012 8:12:01 PM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Documents and Settings\srin
ivasa\Documents\workspace-sts-2.9.0.RELEASE\testheroku\target\bin\src\main\webap
p does not exist or is not a readable directory
        at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.
java:140)

先生我的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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.heroku.sample</groupId>
  <artifactId>embeddedTomcatSample</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>embeddedTomcatSample Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-logging-juli</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper-el</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jsp-api</artifactId>
        <version>7.0.22</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>embeddedTomcatSample</finalName>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>appassembler-maven-plugin</artifactId>
            <version>1.1.1</version>
            <configuration>
                <assembleDirectory>target</assembleDirectory>
                <programs>
                    <program>
                        <mainClass>main.java.launch.Main</mainClass>
                        <name>webapp</name>
                    </program>
                </programs>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>assemble</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
  </build>
</project>

并使用相同的Main.java,HelloServlet.java,index.jsp

3 个答案:

答案 0 :(得分:4)

在Windows上,您需要运行:

target\bin\webapp.bat

答案 1 :(得分:0)

JVM告诉你它无法找到类launch.Main。您需要设置JVM的类路径才能找到它:

java -cp <f> launch.Main

其中<f>是包含启动目录的文件夹的路径(例如target / bin)

答案 2 :(得分:0)

不知道你是否仍然关心这一点,但是你做到了:

set REPO=%UserProfile%\.m2\repository

? appassembler生成的target / bin / webapp脚本依赖于该环境变量。