2012-04-16 150 views
1

,我在這裏做示例應用程序https://github.com/heroku/devcenter-embedded-tomcatHeroku的示例應用程序錯誤

我一直在使用「MVN包」運行應用程序,當我使用「sh的目標/斌/ web應用程序運行該腳本的版本是success..but 「然後我得到以下error.Sir請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.

@詹姆斯先生請你幫助我得到這個錯誤

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的

回答

0

的JVM告訴你它找不到類launch.Main。您需要設置的類路徑JVM找到它:

java -cp <f> launch.Main 

其中<f>是路徑到包含啓動目錄(例如,目標/箱)

+0

Thank you sir..am going in the right way..please help..first am new project as「dynamic web project」in my spring source tool suite ..然後我只有'src'文件夾..i沒有得到這些文件夾「src/main/java/launch」..我需要手動創建這些文件夾?? ..請幫助這是正確的方式? – user1160126 2012-04-16 06:29:50

+0

我不熟悉春天,但源文件夾應該是好的(源代碼編譯好,你有一個運行時錯誤) – Attila 2012-04-16 06:51:14

+0

先生在同一個應用程序在pom.xml ..這些都顯示..我可以得到這些文件?請幫我 com.heroku.sample embeddedTomcatSample 1.0快照 embeddedTomcatSample的Maven的webapp http://maven.apache.org <依賴性> org.apache。 tomcat.embed user1160126 2012-04-16 07:40:33

4

在Windows上,你需要運行的文件夾:

target\bin\webapp.bat 
+0

先生。請仔細查看我的更新代碼。 – user1160126 2012-04-16 14:45:49

+0

::: term web:sh target/bin/webapp ..... sir如何在windows中創建一個procfile? procfile是一個類文件或它正是請求幫助 – user1160126 2012-04-16 15:09:07

+2

@ user1160126 - 從目錄'C:\ Documents and Settings \ srinivasa \ Documents \ workspace-sts-2.9.0.RELEASE \ run'運行'target \ bin \ webapp.bat'。 testheroku',而不是來自目標/ bin目錄的'webapp.bat' – Attila 2012-04-16 15:20:28

0

不知道,如果你還在乎這個,但是你做的事:

set REPO=%UserProfile%\.m2\repository 

? appassembler生成的target/bin/webapp腳本依賴於該環境變量。