Problems with SQL Container Adressbook Demo

Hi

I try to code work the SQL Container Adressbook Demo Tutorial. I created a mysql database called test. after that i executed following sql code:


CREATE TABLE IF NOT EXISTS `city` (
  `id` int(11) NOT NULL DEFAULT '0',
  `name` varchar(64) DEFAULT NULL,
  `version` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


CREATE TABLE IF NOT EXISTS `personaddress` (
  `id` int(11) NOT NULL DEFAULT '0',
  `firstname` varchar(64) DEFAULT NULL,
  `lastname` varchar(64) DEFAULT NULL,
  `email` varchar(64) DEFAULT NULL,
  `phonenumber` varchar(64) DEFAULT NULL,
  `streetaddress` varchar(128) DEFAULT NULL,
  `postalcode` int(11) DEFAULT NULL,
  `cityId` int(11) NOT NULL,
  `version` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `cityId` (`cityId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

then i worked until http://vaadin.com/tutorial/sql/-/page/ch02s02.html and my code is that: http://www.rudolfschmidt.com/upload/demo.zip

it would be nice if you could help me. i get exception 500 executing the application with apache tomcat.

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/vaadin/data/Container$Filter
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.handleServiceException(AbstractApplicationServlet.java:852)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:484)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

dunno where is the error. i hope u can reproduce.

Hi,

you have incompatible jar files. The 1.1.0 version of SQLContainer requires at least Vaadin 6.6.0 due to changes to the filtering API. If you wish to continue to use the Vaadin 6.2.5 you have in your zip file currently, you must downgrade the SQLContainer to version 1.0.1 (and lose some of the filtering features).


Tepi

I have installed vaadin with eclipse plugin. i thought its enough to have the current version.

how to get the latest vaadin version?

Ok I have another Problem. I editet the liberaries. Now i have another error:


DB -> begin transaction
DB -> SELECT * FROM personaddress ORDER BY "id" ASC LIMIT 1 OFFSET 0
DB -> commit
DB -> begin transaction
DB -> SELECT * FROM city ORDER BY "id" ASC LIMIT 1 OFFSET 0
DB -> commit
Fetching count...
DB -> begin transaction
DB -> SELECT COUNT(*) FROM personaddress
DB -> commit
Updated row count. New count is: 0Fetching count...
DB -> begin transaction
DB -> SELECT COUNT(*) FROM city

DB -> commit
Updated row count. New count is: 0
29.07.2011 15:20:10 org.apache.catalina.core.StandardWrapperValve invoke
SCHWERWIEGEND: Servlet.service() for servlet [AddressBook]
 in context with path 
[/AddressBook] threw exception [java.lang.NullPointerException]
 with root cause
java.lang.NullPointerException
	at com.vaadin.demo.tutorial.addressbook.DatabaseHelper.fillContainers(DatabaseHelper.java:122)
	at com.vaadin.demo.tutorial.addressbook.DatabaseHelper.<init>(DatabaseHelper.java:47)
	at com.vaadin.demo.tutorial.addressbook.AddressBookApplication.<init>(AddressBookApplication.java:35)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
	at java.lang.Class.newInstance0(Class.java:372)
	at java.lang.Class.newInstance(Class.java:325)
	at com.vaadin.terminal.gwt.server.ApplicationServlet.getNewApplication(ApplicationServlet.java:82)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.createApplication(AbstractApplicationServlet.java:973)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.findApplicationInstance(AbstractApplicationServlet.java:801)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:456)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:278)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:679)

with that code: http://www.rudolfschmidt.com/upload/demo2.zip

in method fillContainers() in class DatabaseHelper

I also am getting the null pointer exception. Have you found a resolution for this yet?

Hi,

I am unable to reproduce the NPE when using the following:

  • Vaadin 6.6.3
  • SQLContainer 1.1.0
  • AddressBook demo code checked out from Vaadin SVN
  • HSQLDB

I was also unable to access your demo2.zip so I could not check out what could be wrong.

Do note that there may be some errors in the written tutorial. If you have not yet done so, please get the code
from here
and try again.

-Tepi

I’m getting the same problem, just using the packages you linked!

Only thing I changed is the connectionPool…

connectionPool = new SimpleJDBCConnectionPool(
                    "oracle.jdbc.driver.OracleDriver",
                    "jdbc:oracle:thin:@dbsrv1:1521/DEV", "xxx", "yyy", 2, 5);

Is there sth wrong with it? This connection details work for me with every other framework… only vaadin wont work… why?

I haven’t used SQLContainer, but some things that come to my mind:

As you say the only thing you changed is the connection, maybe you are not using com.vaadin.addon.sqlcontainer.query.generator.OracleGenerator. There should be some other forum threads about it.

Also, the example might assume case insensitive identifiers while your database might be case sensitive by default.

Thank you very much for the fast reply!
Sadly I can’t find any posts / tutorials about how to use the oracle generator! :frowning:

Kind Regards

Quickly checking the code, you could try to give “new OracleGenerator()” as the third parameter to TableQuery. In the address book example, the method to modify is DatabaseHelper.initContainers().

The SQLGenerator should be stateless so you can share it between instances of TableQuery - you could have your own TableQuery subclass that takes care of this.

Disclaimer: I still haven’t used the container - this is based on a quick look at the code.