Class not found: org.springframework.context.ApplicationContext





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-1

















I am new on Spring Framework. I had followed by instructions given in book Spring 4 for Professionals. In book author configured framework via xml, but I want configure it with Java. While running I'm getting ClassNotFoundException



Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more


I have published my code in
github.
What I'm doing wrong?










share|improve this question

























  • just try refresh you gradle dependencies

    – Peter Jurkovic
    May 4 '17 at 12:12











  • I did it many times :), but result was same

    – Bakhtiyor Begmatov
    May 4 '17 at 12:13













  • Clean up your gradle cache ~/.gradle/caches and import your project again

    – Peter Jurkovic
    May 4 '17 at 12:17


















-1

















I am new on Spring Framework. I had followed by instructions given in book Spring 4 for Professionals. In book author configured framework via xml, but I want configure it with Java. While running I'm getting ClassNotFoundException



Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more


I have published my code in
github.
What I'm doing wrong?










share|improve this question

























  • just try refresh you gradle dependencies

    – Peter Jurkovic
    May 4 '17 at 12:12











  • I did it many times :), but result was same

    – Bakhtiyor Begmatov
    May 4 '17 at 12:13













  • Clean up your gradle cache ~/.gradle/caches and import your project again

    – Peter Jurkovic
    May 4 '17 at 12:17














-1












-1








-1










I am new on Spring Framework. I had followed by instructions given in book Spring 4 for Professionals. In book author configured framework via xml, but I want configure it with Java. While running I'm getting ClassNotFoundException



Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more


I have published my code in
github.
What I'm doing wrong?










share|improve this question


















I am new on Spring Framework. I had followed by instructions given in book Spring 4 for Professionals. In book author configured framework via xml, but I want configure it with Java. While running I'm getting ClassNotFoundException



Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more


I have published my code in
github.
What I'm doing wrong?







java spring gradle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 9:06









thepurpleowl

101112




101112










asked May 4 '17 at 12:09









Bakhtiyor BegmatovBakhtiyor Begmatov

14619




14619













  • just try refresh you gradle dependencies

    – Peter Jurkovic
    May 4 '17 at 12:12











  • I did it many times :), but result was same

    – Bakhtiyor Begmatov
    May 4 '17 at 12:13













  • Clean up your gradle cache ~/.gradle/caches and import your project again

    – Peter Jurkovic
    May 4 '17 at 12:17



















  • just try refresh you gradle dependencies

    – Peter Jurkovic
    May 4 '17 at 12:12











  • I did it many times :), but result was same

    – Bakhtiyor Begmatov
    May 4 '17 at 12:13













  • Clean up your gradle cache ~/.gradle/caches and import your project again

    – Peter Jurkovic
    May 4 '17 at 12:17

















just try refresh you gradle dependencies

– Peter Jurkovic
May 4 '17 at 12:12





just try refresh you gradle dependencies

– Peter Jurkovic
May 4 '17 at 12:12













I did it many times :), but result was same

– Bakhtiyor Begmatov
May 4 '17 at 12:13







I did it many times :), but result was same

– Bakhtiyor Begmatov
May 4 '17 at 12:13















Clean up your gradle cache ~/.gradle/caches and import your project again

– Peter Jurkovic
May 4 '17 at 12:17





Clean up your gradle cache ~/.gradle/caches and import your project again

– Peter Jurkovic
May 4 '17 at 12:17












1 Answer
1






active

oldest

votes


















2














Works fine here, Hello World! is printed when I run it.

How do you try to run it?

I guess you tried to do java -jar spring-framework-example.jar.

This of course does not work because you miss the libraries in your classpath then.



If you exchange



jar {
manifest {
attributes 'Main-Class': 'com.bakhtiyor.sample.Application'
}
}


with



apply plugin: 'application'

mainClassName = 'com.bakhtiyor.sample.Application'


and then use gradle run, the application works fine.



PS: You should always use the Gradle Wrapper, even in the tiniest project. Then it is easier for others to build your project because nothing needs to be installed to build and the build always run with the Gradle version the build is designed for.






share|improve this answer
























  • Thank you for your quick response to my question. My project is working now with gradle run. One more question again, how enable Gradle Wrapper?

    – Bakhtiyor Begmatov
    May 4 '17 at 12:31













  • docs.gradle.org/current/userguide/…

    – Vampire
    May 4 '17 at 12:54











  • Thank you for your answer. It' working with gradle run. But how do I make an exportable, shareable jar now?

    – shredding
    Feb 16 '18 at 11:02











  • You don't make a "runnable" fat jar. Those have many drawbacks and are an abuse of Java that rape its possibilities. With the application plugin applied you use the distZip or distTar task to generate a proper distribution archive. You could of course also try to read documentation before asking such questions. ;-)

    – Vampire
    Feb 16 '18 at 22:11












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43782535%2fclass-not-found-org-springframework-context-applicationcontext%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Works fine here, Hello World! is printed when I run it.

How do you try to run it?

I guess you tried to do java -jar spring-framework-example.jar.

This of course does not work because you miss the libraries in your classpath then.



If you exchange



jar {
manifest {
attributes 'Main-Class': 'com.bakhtiyor.sample.Application'
}
}


with



apply plugin: 'application'

mainClassName = 'com.bakhtiyor.sample.Application'


and then use gradle run, the application works fine.



PS: You should always use the Gradle Wrapper, even in the tiniest project. Then it is easier for others to build your project because nothing needs to be installed to build and the build always run with the Gradle version the build is designed for.






share|improve this answer
























  • Thank you for your quick response to my question. My project is working now with gradle run. One more question again, how enable Gradle Wrapper?

    – Bakhtiyor Begmatov
    May 4 '17 at 12:31













  • docs.gradle.org/current/userguide/…

    – Vampire
    May 4 '17 at 12:54











  • Thank you for your answer. It' working with gradle run. But how do I make an exportable, shareable jar now?

    – shredding
    Feb 16 '18 at 11:02











  • You don't make a "runnable" fat jar. Those have many drawbacks and are an abuse of Java that rape its possibilities. With the application plugin applied you use the distZip or distTar task to generate a proper distribution archive. You could of course also try to read documentation before asking such questions. ;-)

    – Vampire
    Feb 16 '18 at 22:11
















2














Works fine here, Hello World! is printed when I run it.

How do you try to run it?

I guess you tried to do java -jar spring-framework-example.jar.

This of course does not work because you miss the libraries in your classpath then.



If you exchange



jar {
manifest {
attributes 'Main-Class': 'com.bakhtiyor.sample.Application'
}
}


with



apply plugin: 'application'

mainClassName = 'com.bakhtiyor.sample.Application'


and then use gradle run, the application works fine.



PS: You should always use the Gradle Wrapper, even in the tiniest project. Then it is easier for others to build your project because nothing needs to be installed to build and the build always run with the Gradle version the build is designed for.






share|improve this answer
























  • Thank you for your quick response to my question. My project is working now with gradle run. One more question again, how enable Gradle Wrapper?

    – Bakhtiyor Begmatov
    May 4 '17 at 12:31













  • docs.gradle.org/current/userguide/…

    – Vampire
    May 4 '17 at 12:54











  • Thank you for your answer. It' working with gradle run. But how do I make an exportable, shareable jar now?

    – shredding
    Feb 16 '18 at 11:02











  • You don't make a "runnable" fat jar. Those have many drawbacks and are an abuse of Java that rape its possibilities. With the application plugin applied you use the distZip or distTar task to generate a proper distribution archive. You could of course also try to read documentation before asking such questions. ;-)

    – Vampire
    Feb 16 '18 at 22:11














2












2








2







Works fine here, Hello World! is printed when I run it.

How do you try to run it?

I guess you tried to do java -jar spring-framework-example.jar.

This of course does not work because you miss the libraries in your classpath then.



If you exchange



jar {
manifest {
attributes 'Main-Class': 'com.bakhtiyor.sample.Application'
}
}


with



apply plugin: 'application'

mainClassName = 'com.bakhtiyor.sample.Application'


and then use gradle run, the application works fine.



PS: You should always use the Gradle Wrapper, even in the tiniest project. Then it is easier for others to build your project because nothing needs to be installed to build and the build always run with the Gradle version the build is designed for.






share|improve this answer













Works fine here, Hello World! is printed when I run it.

How do you try to run it?

I guess you tried to do java -jar spring-framework-example.jar.

This of course does not work because you miss the libraries in your classpath then.



If you exchange



jar {
manifest {
attributes 'Main-Class': 'com.bakhtiyor.sample.Application'
}
}


with



apply plugin: 'application'

mainClassName = 'com.bakhtiyor.sample.Application'


and then use gradle run, the application works fine.



PS: You should always use the Gradle Wrapper, even in the tiniest project. Then it is easier for others to build your project because nothing needs to be installed to build and the build always run with the Gradle version the build is designed for.







share|improve this answer












share|improve this answer



share|improve this answer










answered May 4 '17 at 12:23









VampireVampire

25.5k23774




25.5k23774













  • Thank you for your quick response to my question. My project is working now with gradle run. One more question again, how enable Gradle Wrapper?

    – Bakhtiyor Begmatov
    May 4 '17 at 12:31













  • docs.gradle.org/current/userguide/…

    – Vampire
    May 4 '17 at 12:54











  • Thank you for your answer. It' working with gradle run. But how do I make an exportable, shareable jar now?

    – shredding
    Feb 16 '18 at 11:02











  • You don't make a "runnable" fat jar. Those have many drawbacks and are an abuse of Java that rape its possibilities. With the application plugin applied you use the distZip or distTar task to generate a proper distribution archive. You could of course also try to read documentation before asking such questions. ;-)

    – Vampire
    Feb 16 '18 at 22:11



















  • Thank you for your quick response to my question. My project is working now with gradle run. One more question again, how enable Gradle Wrapper?

    – Bakhtiyor Begmatov
    May 4 '17 at 12:31













  • docs.gradle.org/current/userguide/…

    – Vampire
    May 4 '17 at 12:54











  • Thank you for your answer. It' working with gradle run. But how do I make an exportable, shareable jar now?

    – shredding
    Feb 16 '18 at 11:02











  • You don't make a "runnable" fat jar. Those have many drawbacks and are an abuse of Java that rape its possibilities. With the application plugin applied you use the distZip or distTar task to generate a proper distribution archive. You could of course also try to read documentation before asking such questions. ;-)

    – Vampire
    Feb 16 '18 at 22:11

















Thank you for your quick response to my question. My project is working now with gradle run. One more question again, how enable Gradle Wrapper?

– Bakhtiyor Begmatov
May 4 '17 at 12:31







Thank you for your quick response to my question. My project is working now with gradle run. One more question again, how enable Gradle Wrapper?

– Bakhtiyor Begmatov
May 4 '17 at 12:31















docs.gradle.org/current/userguide/…

– Vampire
May 4 '17 at 12:54





docs.gradle.org/current/userguide/…

– Vampire
May 4 '17 at 12:54













Thank you for your answer. It' working with gradle run. But how do I make an exportable, shareable jar now?

– shredding
Feb 16 '18 at 11:02





Thank you for your answer. It' working with gradle run. But how do I make an exportable, shareable jar now?

– shredding
Feb 16 '18 at 11:02













You don't make a "runnable" fat jar. Those have many drawbacks and are an abuse of Java that rape its possibilities. With the application plugin applied you use the distZip or distTar task to generate a proper distribution archive. You could of course also try to read documentation before asking such questions. ;-)

– Vampire
Feb 16 '18 at 22:11





You don't make a "runnable" fat jar. Those have many drawbacks and are an abuse of Java that rape its possibilities. With the application plugin applied you use the distZip or distTar task to generate a proper distribution archive. You could of course also try to read documentation before asking such questions. ;-)

– Vampire
Feb 16 '18 at 22:11




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43782535%2fclass-not-found-org-springframework-context-applicationcontext%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules