7 Replies Latest reply: Apr 18, 2011 5:00 AM by yilin chai RSS

    the ShrinkWrap and the NoClassDefFoundError

    yilin chai Newbie

      hi guys,

       

      i am a ShrinkWrap novice and just want to try the simplest example for novice ShrinkWrap (not with Arquillian), so the method:

       

          public static void main(String[] args) {

              JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class,

                      "test.jar");

              javaArchive = javaArchive.addClasses(WordItem.class, WordItemDAO.class);

              javaArchive = javaArchive.addAsManifestResource("persistence.xml",

                      ArchivePaths.create("persistence.xml"));

              System.out.println(javaArchive.toString());

          }

       

      the class got complied but the execution immediately stop at first line: JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class,"test.jar");

      and the exception:

       

      Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/shrinkwrap/api/spec/JavaArchive

          at org.cyl.english.ffl.Entities.WordItemTest.main(WordItemTest.java:25)

      Caused by: java.lang.ClassNotFoundException: org.jboss.shrinkwrap.api.spec.JavaArchive

          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:307)

          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

          at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

          ... 1 more

       

      what wrong with the code?