Issues with my Maven project

29 views
Skip to first unread message

henry joe

unread,
Mar 9, 2013, 1:10:07 PM3/9/13
to JPassion.com: Java Programming
Hello guys, 

Please, I was trying to build a simple maven project but ran into some difficulty. I was checking out the instructions from this site-> `http://www.mkyong.com/hibernate/quick-start-maven-hibernate-mysql-example/`

but when I took a look at the structure, I discovered in my project structure, I couldn't find the .project and the .classpath  files. I only found the pom.xml. When I ran the project, I hit an eror:

    Exception in thread "main" java.lang.NoClassDefFoundError: com/henry/directory/App
    Caused by: java.lang.ClassNotFoundException: com.henry.directory.App
    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)

Here is my pom.xml file:


      <modelVersion>4.0.0</modelVersion>
      <groupId>com.henry.directory</groupId>
      <artifactId>FirstMaven</artifactId>
      <packaging>jar</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>FirstMaven</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
        
          <!-- MySQL database driver -->
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.9</version>
    </dependency>
     
    <!-- Hibernate framework -->
    <dependency>
    <groupId>hibernate</groupId>
    <artifactId>hibernate3</artifactId>
    <version>3.2.3.GA</version>
    </dependency>
     
     
    <!-- Hibernate library dependecy start -->
    <dependency>
    <groupId>dom4j</groupId>
    <artifactId>dom4j</artifactId>
    <version>1.6.1</version>
    </dependency>
     
    <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
    </dependency>
     
    <dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.1</version>
    </dependency>
     
    <dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib</artifactId>
    <version>2.2</version>
    </dependency>
    <!-- Hibernate library dependecy end -->
     
    <dependency>
    <groupId>javax.transaction</groupId>
    <artifactId>jta</artifactId>
    <version>1.1</version>
    </dependency>   
      </dependencies>
    </project>

I hope someone could help me out at why the class could not be found. Thanks









 

Sang Shin

unread,
Mar 9, 2013, 2:36:31 PM3/9/13
to kan...@gmail.com, JPassion.com: Java Programming
On 3/9/2013 1:10 PM, henry joe wrote:
Hello guys, 

Please, I was trying to build a simple maven project but ran into some difficulty. I was checking out the instructions from this site-> `http://www.mkyong.com/hibernate/quick-start-maven-hibernate-mysql-example/`

but when I took a look at the structure, I discovered in my project structure, I couldn't find the .project and the .classpath  files. I only found the pom.xml. When I ran the project, I hit an eror:

You don't need .project and .classpath files unless you want them to get built
as Eclipse projects as well.



    Exception in thread "main" java.lang.NoClassDefFoundError: com/henry/directory/App
    Caused by: java.lang.ClassNotFoundException: com.henry.directory.App

It is looking for com/henry/directory/App.class in the classpath but cannot find it.
I strongly recommend you to study the "Maven Basics 1" under "Java development tools" course
along with 8623_tools_build_maven1.zip.

-S


--
You received this message because you are subscribed to the Google Groups "JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpassion_jav...@googlegroups.com.
Visit this group at http://groups.google.com/group/jpassion_java?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


-- 
-------------------------------------------------------------------
             Sang Shin, sangshi...@gmail.com
  Founder and Chief Instructor of JPassion.com (JavaPassion.com)
         http://www.linkedin.com/in/javapassion (Linkedin)
          http://twitter.com/javapassion (Tweeter)
            Life is worth living... with Passion!

Free 12-week Webinar series on"Groovy and Grails" starts from March 1st
     Free 10-week Webinar series on "HTML5" starts from March 1st
             http://jpassion.com/webinars       
----------------------------------------------------------------------

Srilaxmi

unread,
Mar 9, 2013, 9:09:23 PM3/9/13
to kan...@gmail.com, JPassion.com: Java Programming
Reply all
Reply to author
Forward
0 new messages