1

I am doing the sample application here https://github.com/heroku/devcenter-embedded-tomcat

I have run the application using 'mvn package' and the build is success..but when am running the script using "sh target/bin/webapp" then am getting the below error.Sir please help..thanks

C:\Documents and Settings\srinivasa\Documents\workspace-sts-2.9.0.RELEASE\sriniv as>sh target/bin/webapp Exception in thread "main" java.lang.NoClassDefFoundError: launch/Main Caused by: java.lang.ClassNotFoundException: launch.Main at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: launch.Main. Program will exit.

@james sir please do help am getting this error

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)

sir my 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>

and am using same Main.java,HelloServlet.java,index.jsp

4

3 回答 3

4

在 Windows 上,您需要运行:

target\bin\webapp.bat
于 2012-04-16T11:00:08.190 回答
0

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

java -cp <f> launch.Main

<f>包含启动目录的文件夹的路径在哪里(例如 target/bin)

于 2012-04-16T06:23:47.347 回答
0

不知道你是否还关心这个,但你有没有这样做:

set REPO=%UserProfile%\.m2\repository

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

于 2013-01-02T22:36:25.460 回答