user1160126
user1160126

Reputation: 195

heroku sample application error

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

Upvotes: 1

Views: 2462

Answers (3)

Joshua Davies
Joshua Davies

Reputation: 1081

Don't know if you still care about this, but did you do:

set REPO=%UserProfile%\.m2\repository

? The target/bin/webapp script that appassembler generates relies on that environment variable.

Upvotes: 0

James Ward
James Ward

Reputation: 29433

On Windows you need to run:

target\bin\webapp.bat

Upvotes: 4

Attila
Attila

Reputation: 28762

The JVM tells you that it cannot find the class launch.Main. You need to set the classpath for the JVM to find it:

java -cp <f> launch.Main

where <f> is the path to the folder that contains the launch directory (e.g. target/bin)

Upvotes: 0

Related Questions