Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6990539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:21:58+00:00 2026-05-27T19:21:58+00:00

i am working on a standalone application build with maven , and i add

  • 0

i am working on a standalone application build with maven, and i add the dependencies to the target jar in a lib folder using maven-dependency-plugin with maven-assembly-plugin the application runs fine from eclipse with no problems, but when trying to run the generated jar file from command line, i am getting following exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/support/ClassPathXmlApplicationContext
        at com.spring.sample.MainClass.main(MainClass.java:11)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.support.ClassPathXmlApplicationContext
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more

i looked inside the generated jar lib folder, and i found that the spring-context-support.jar is already there, so i am wondering why i am getting such exception.

here’s my maven build configuration:

<build>

  <resources>

            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>

  </resources>

      <plugins>


          <plugin> 
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/classes/lib</outputDirectory>                       
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>com.myapp.MainClass</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install</id>
                        <phase>install</phase>
                        <goals>
                            <goal>sources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-resources-plugin</artifactId>
               <version>2.5</version>
               <configuration>
               <encoding>UTF-8</encoding>
               </configuration>
            </plugin>


           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>create-my-bundle</id>
                                <phase>package</phase>
                                    <goals>
                                        <goal>single</goal>
                                    </goals>
                         <configuration>
                           <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                           </descriptorRefs>

                         </configuration>
                        </execution>
                   </executions>

            </plugin> 


      </plugins>
  </build>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:21:59+00:00Added an answer on May 27, 2026 at 7:21 pm

    You’ve got kind of a mess of a POM there, and you’re building two jars.

    One of the jars is built by first copying your dependencies into target/classes/lib–a questionable practice to begin with–and letting the default execution of the jar plugin build its normal jar. This jar has all your code in it like a normal jar but also has all your dependency jars inside it at /lib. It also has a manifest that specifies a Main-Class and a Class-Path listing all the required jars at a relative path of lib/...jar. It sounds like this is the one you’re trying to run. The reason it can’t find the classes it needs is that a class path for a standalone Java app is a list of folders or jar files on the file system that contain class files. In other words, it won’t find jar files inside another jar file, which is what this you have. For this to work how you expect, you’d need a lib directory right next to your jar file which has all the dependencies in it. This is what’s causing your present problem.

    The other jar is built by the assembly plugin. Because of your earlier antics with the dependency plugin, this one should also have all the dependency jars in it at /lib, which I’ve already explained won’t accomplish anything, but because of how the jar-with-dependencies descriptor works, it will also have extracted all those jars and put all of their classes into your jar along with your own classes. If you were to run this jar, you’d probably get past the ClassNotFoundException, but there are well-known problems with “fat jars” like this that mean you shouldn’t do this unless you have some really compelling reasons for it. One such problem is described in the following question:

    Maven and Spring = Unable to create application context: Unable to locate Spring NamespaceHandler

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a standalone application which I have deployed using the Maven release plugin.
Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.
I am working on a C# application that involves using XML schema file as
I'm working with a flash application that runs as a standalone executable by way
I'm working at a helpdesk application where i have a standalone script that queries
This is a standalone java application. I am using the configuration file below and
i am developing a standalone application using html and want to call method residing
Hi I want to know how I can working using c# application with yahoo
I am working on a simple standalone desktop application which would generate report based
I'm working on a unique windows desktop application that requires both a standalone and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.