Hi Mirza,
it seems like the Grizzly 2 jars are missing at the class-path.
I do not use Eclipse, but the standalone mvn compile exec:java command
works fine for me (no need to specify any additional attribute).
Compile scoped dependencies from the following list
should be on the class-path, when you run the command in Eclipse.
HTH,
~Jakub
[INFO] com.sun.jersey.samples:helloworld:jar:1.9-SNAPSHOT
[INFO] +- com.sun.jersey:jersey-grizzly2:jar:1.9-SNAPSHOT:compile
[INFO] | +- org.glassfish.grizzly:grizzly-http:jar:2.1.1:compile
[INFO] | | \- org.glassfish.grizzly:grizzly-framework:jar:2.1.1:compile
[INFO] | | \- org.glassfish.gmbal:gmbal-api-only:jar:3.0.0-b023:compile
[INFO] | | \-
org.glassfish.external:management-api:jar:3.0.0-b012:compile
[INFO] | +- org.glassfish.grizzly:grizzly-http-server:jar:2.1.1:compile
[INFO] | | \- org.glassfish.grizzly:grizzly-rcm:jar:2.1.1:compile
[INFO] | +- org.glassfish.grizzly:grizzly-http-servlet:jar:2.1.1:compile
[INFO] | | \-
org.glassfish.grizzly:grizzly-framework:jar:tests:2.1.1:compile
[INFO] | +- org.glassfish:javax.servlet:jar:3.1:compile
[INFO] | \- com.sun.jersey:jersey-server:jar:1.9-SNAPSHOT:compile
[INFO] | +- asm:asm:jar:3.1:compile
[INFO] | \- com.sun.jersey:jersey-core:jar:1.9-SNAPSHOT:compile
[INFO] \-
com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly2:jar:1.9-SNAPSHOT:test
[INFO] \-
com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.9-SNAPSHOT:test
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] \- com.sun.jersey:jersey-client:jar:1.9-SNAPSHOT:test
On 19.8.2011 7:39, Mirza Irwan wrote:
> Hi all,
>
> Please help:
> I downloaded the sample code from svn. I imported the maven project
> into eclipse indigo. I edited the run configuration:
>
> *Goals:* compile exec:java
>
> *Parameters name* *Value*
> exec.mainClass com.sun.jersey.samples.helloworld.Main
>
> When I clicked run, I get the following failed messages
>
> [ERROR] Failed to execute goal
> org.codehaus.mojo:exec-maven-plugin:1.1:java (default-cli) on project
> helloworld: An exception occured while executing the Java
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
> execute goal org.codehaus.mojo:exec-maven-plugin:1.1:java
> (default-cli) on project helloworl
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
> at
> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
> at
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
> Caused by: org.apache.maven.plugin.MojoExecutionException: An
> exception occured while executing the Java class. null
> at
> org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:345)
> at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
> ... 19 more
> Caused by: java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:290)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: java.lang.NoClassDefFoundError:
> org/glassfish/grizzly/http/util/Chunk
> at
> org.glassfish.grizzly.servlet.ServletHandler.<clinit>(ServletHandler.java:127)
> at
> com.sun.jersey.api.container.grizzly2.GrizzlyWebContainerFactory.create(GrizzlyWebContainerFactory.java:221)
> at
> com.sun.jersey.api.container.grizzly2.GrizzlyWebContainerFactory.create(GrizzlyWebContainerFactory.java:140)
> at
> com.sun.jersey.samples.helloworld.Main.startServer(Main.java:79)
> at com.sun.jersey.samples.helloworld.Main.main(Main.java:83)
> ... 6 more
> Caused by: java.lang.ClassNotFoundException:
> org.glassfish.grizzly.http.util.Chunk
> 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 java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> ... 11 more