EJB3 with Toolkit (Your CRUD article)

Hello!

I’ve been struggling with binding my data to your components and noticed that you got an article on how to use use hibernate with Toolkit components. This feels a bit like overkill but I like to make things the right way and decided to give it a try… So, I read your article from
http://dev/wiki/Articles/UsingHibernateWithToolkit
and downloaded Eclipse workspace zip. I imported the project and as I like to enjoy from lightning fast Jetty instead of bulky Tomcat on my development environment I did the following:

  1. Added Jetty jars under WebContent/WEB-INF/lib:
    jetty-6.1.7.jar, jetty-util-6.1.7.jar and servlet-api-2.5-6.1.7.jar

  2. Added Start.java:


package com.itmill.toolkit.demo.workoutlog;

import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class Start {

	public static void main(String[] args) {

		try {
			final Server server = new Server();
			final Connector connector = new SelectChannelConnector();
			connector.setPort(8888);
			server.setConnectors(new Connector[] { connector });
			final WebAppContext webappcontext = new WebAppContext();
			webappcontext.setContextPath("");
			webappcontext.setWar("WebContent");
			server.setHandler(webappcontext);
			server.start();
		} catch (final Exception e) {
			e.printStackTrace();
		}

	}

}

Then I execute Start.java as standard Java application which starts up my Servlet Container but when I load http://localhost:8888/ I do get application loaded to my screen but

  1. containers seem to be empty
  2. I get following exception when application starts up, what gives?

2008-04-17 18:22:35.570::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2008-04-17 18:22:36.647::INFO:  jetty-6.1.7
2008-04-17 18:22:36.872::INFO:  NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet
2008-04-17 18:22:36.049::INFO:  Started SelectChannelConnector@0.0.0.0:8888
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select count(*) as y0_ from Workout this_
2008-04-17 18:22:44.121::WARN:  /
java.lang.ClassCastException: com.itmill.toolkit.demo.workoutlog.WorkoutLog$1
	at com.itmill.toolkit.terminal.gwt.server.WebApplicationContext.endTransaction(WebApplicationContext.java:210)
	at com.itmill.toolkit.terminal.gwt.server.ApplicationServlet.service(ApplicationServlet.java:500)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
2008-04-17 18:22:44.170::WARN:  /favicon.ico
java.lang.ClassCastException: com.itmill.toolkit.demo.workoutlog.WorkoutLog$1
	at com.itmill.toolkit.terminal.gwt.server.WebApplicationContext.endTransaction(WebApplicationContext.java:210)
	at com.itmill.toolkit.terminal.gwt.server.ApplicationServlet.service(ApplicationServlet.java:500)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
2008-04-17 18:22:45.528::WARN:  /UIDL/
java.lang.ClassCastException: com.itmill.toolkit.demo.workoutlog.WorkoutLog$1
	at com.itmill.toolkit.terminal.gwt.server.WebApplicationContext.endTransaction(WebApplicationContext.java:210)
	at com.itmill.toolkit.terminal.gwt.server.ApplicationServlet.service(ApplicationServlet.java:500)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)

Arrrghh, got my Eclipse into “Not Responding” state after adding few rows and deleting some :slight_smile:

Had to kill it forcefully!

Please check Competence Management System from http://dev.itmill.com/svn/incubator/cms/ . It is still work being developed but I know people have tried it out with Jetty too.

I suspect you got some kind of conflict with Jetty classes and Hibernate example classes.