1

I am using Eclipse with the Google App Engine plugin. I'm trying to run a simple program with added joda time. It seems like the error relates to the build path and I followed the instructions in: https://stackoverflow.com/a/12105417/3255963 but I am still getting the error below. What do I need to do to next?

package test;
import java.io.IOException;
import javax.servlet.http.*;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

@SuppressWarnings("serial")
public class testServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

        DateTime newYears = new DateTime (2014, 1, 1, 0, 0);

        resp.setContentType("text/plain");
        resp.getWriter().println("Hello, world");

    }

}       

Error:

java.lang.NoClassDefFoundError: org/joda/time/DateTime

I see the joda-time-2.3.jar in the project explorer and the build path.

I also tried selecting it under order and export.

Community
  • 1
  • 1
CarbonandH20
  • 361
  • 1
  • 3
  • 13

1 Answers1

2

NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time. Please ck whether u have the req. jars under \WebContent\WEB-INF\lib in the project explorar as well as on the project build path.

Kushal
  • 48
  • 10
  • Thanks! That did it. Is there no automatic way to do this in the future? Do I need also need to have the jar in the libs folder too? (I would upvote you but my reputation's not high enough yet.) – CarbonandH20 Mar 01 '14 at 18:34
  • As far as my knowledge there is no automatic way to do this, every time you are using a jar in your java web application you need to add this to the lib folder as well as to the Build path. This is because when you are importing your project in the form of war file, the IDE will automatically pack the jars under lib folder to your web app. – Kushal Mar 01 '14 at 18:41