-2

I'm not sure what i'm doing wrong here... i downloaded this sample project which is basically the simplest possible working example of an annotation based controller. I downloaded Tomcat and started the server no problem in eclipse. I downloaded Spring 4.3.7 from here (i'm not using Maven nor do i want to). Added as external JARs under libraries.

When i go run the application i get a ClassNotFoundException for the ServletDispatcher class so i followed the instructions here to resolve this. But when i add the Spring JARs then my server times out with the following error sure enough in the deployment assembly there are being deployed to WEB-INF. So i removed the JARs, and i added them one by one based on the ClassNotFoundException. First i added spring-beans, then context, then webmvc and it seems when i add core this is when the error switches from the ClassNotFoundException to the server timeout error... I'm not sure what to do?

EDIT: Found out that my compiler was set to 1.7 while my JDK was set to 1.8. I changed this and now get a java.lang.NoClassDefFoundError: org/springframework/core/env/EnvironmentCapable error. I tried adding the core JAR but then i continue to get the server timing out error.

Community
  • 1
  • 1
Ben Arnao
  • 153
  • 4
  • 14
  • 1
    You are searching for jars and dependencies yourself... Which is something you really don't want to do... I strongly suggest to use something like Maven or Gradle which really makes your life a lot easier and saves you a lot of headaches. Next to that I would suggest following [this guide](https://spring.io/guides/gs/serving-web-content/) to learn MVC. – M. Deinum Mar 17 '17 at 13:59
  • Also instead of adding a lot of links, add some code/screenshots.config now people who want to help you need to click to a lot of other sites. – M. Deinum Mar 17 '17 at 14:00
  • So when i download the framework there are other dependencies for that? Also what would you like to know? – Ben Arnao Mar 17 '17 at 14:20
  • commons-logging is a dependency others depend on what you use. So generally you don't want to go searching the internet for those dependencies and trying to get the versions right. Hence the reason for people to use Maven/Gradle like tooling. All the information might be there, but I need to be clicking all those links before I have a full understanding. I don't want to need clicking all those links I want to read a single post which contains the necessary information. – M. Deinum Mar 17 '17 at 14:39
  • i didn't mean to make the post overly complex i just wanted to provide any relevant information i could. I will try to provide the info directly in the post next time. I guess the TLDR; is that it's not practical to use Spring without Maven/Gradle? – Ben Arnao Mar 17 '17 at 14:43
  • That not only applies to Spring it applies to java application development in general. – M. Deinum Mar 17 '17 at 14:45

2 Answers2

-1

You need to add the Java build path in the Deployment Assembly

1) Right click on your project, select Properties

2) Select Deployment Assembly. Click Add button.

3) Click on "Java Build Path Entries"

4) Select yours jars

5) click Finish

Clean build your project and restart tomcat.

Jon Sampson
  • 1,473
  • 1
  • 21
  • 31
hicham abdedaime
  • 346
  • 2
  • 15
-1

In Project Properties.

Check your java build path it should contain

JRE system library: JDK 1.7 or above Server Run time: Tomcat

Check your Java Compiler

It should be 1.7 or above

  • I did see the compiler was 1.7 and the jdk in my build path was 1.8. However after that i ran the app but got a different error this time... java.lang.NoClassDefFoundError: org/springframework/core/env/EnvironmentCapable. When i add the core .jar i get the same server timing out error. – Ben Arnao Mar 17 '17 at 13:05