HbnContainer Container$Indexed

Hi there,
I’m a very beginner with Vaadin and Java too.
I downloaded the sample application “WorkoutLog” to learn how to play with database, hibernate and hbncontainer. Then I build my own small application with few database transactions via hibernate and it was OK. Then I tried to add a HbnContainer to my application but at run-time I have the exception “ClassNotFound: com/vaadin/data/Container$Indexed”.
Can anybody help me?

This sounds like a classpath problem, but it is very strange that this particular interface would not be found but the rest of Vaadin is.

Which versions are you using (Vaadin, HbnContainer and your application server)?
Is it possible that you would e.g. have multiple versions of the Vaadin JAR on your classpath or something similar.

Yes Henri, I think I have a bit of confusion in my path.
I’m using Eclipse with Tomcat 6.0.29.
As soon as I started to build my application when I had a “ClassNotFound” error, searching the web, I downloaded the .jars that seem good for me and add to “lib” folder in tomcat installation.
Answering your question: I use vaadin 6.4.1, hbncontainer 1.0.1

That’s what’s in my tomcat lib:

Il volume nell’unit… C non ha etichetta.
Numero di serie del volume: 283B-536E

Directory di C:\Commesse\apache-tomcat-6.0.29\lib

24/08/2010 12.12 .
24/08/2010 12.12 …
19/07/2010 14.59 15.240 annotations-api.jar
18/08/2010 12.36 443.432 antlr-2.7.6.jar
11/08/2010 17.10 16.777 asm-attrs.jar
11/08/2010 17.10 26.360 asm.jar
18/08/2010 12.47 608.376 c3p0-0.9.1.jar
19/07/2010 14.59 53.752 catalina-ant.jar
19/07/2010 14.59 129.627 catalina-ha.jar
19/07/2010 14.59 235.004 catalina-tribes.jar
19/07/2010 14.59 1.191.060 catalina.jar
11/08/2010 17.10 282.338 cglib-2.1.3.jar
18/08/2010 12.36 278.682 cglib-2.2.jar
11/08/2010 17.10 559.366 commons-collections-3.1.jar
11/08/2010 17.10 38.015 commons-logging-1.0.4.jar
11/08/2010 17.10 313.898 dom4j-1.6.1.jar
18/08/2010 12.46 264.400 ehcache-1.5.0.jar
11/08/2010 17.10 50.583 ejb3-persistence.jar
19/07/2010 14.59 32.384 el-api.jar
11/08/2010 14.59 70.216 hbncontainer-1.0.1.jar
18/08/2010 13.10 3.926.729 hibernate3.jar
11/08/2010 17.10 699.936 hsqldb.jar
18/08/2010 12.56 966.498 infinispan-core-4.0.0.FINAL.jar
19/07/2010 14.59 108.570 jasper-el.jar
19/07/2010 14.59 1.407.902 jasper-jdt.jar
19/07/2010 14.59 525.001 jasper.jar
11/08/2010 17.10 471.005 javassist-3.4.GA.jar
18/08/2010 12.36 597.476 javassist-3.9.0.GA.jar
18/08/2010 12.47 1.168.922 jbosscache-core-3.2.1.GA.jar
20/08/2010 15.25 98.356 jpa-api-2.0-cr-1.jar
19/07/2010 14.59 76.693 jsp-api.jar
11/08/2010 17.10 13.236 jta-1.1.jar
11/08/2010 17.10 10.205 jta.licence.txt
30/03/2010 23.16 481.534 log4j-1.2.16.jar
18/08/2010 12.47 114.308 oscache-2.1.jar
18/08/2010 12.48 475.943 proxool-0.8.3.jar
19/07/2010 14.59 88.224 servlet-api.jar
05/07/2010 22.25 25.496 slf4j-api-1.6.1.jar
05/07/2010 22.25 9.753 slf4j-log4j12-1.6.1.jar
05/07/2010 22.25 7.669 slf4j-simple-1.6.1.jar
19/04/2010 10.08 537.303 sqljdbc4.jar
18/08/2010 12.47 30.602 swarmcache-1.0RC2.jar
19/07/2010 14.59 758.137 tomcat-coyote.jar
19/07/2010 14.59 249.650 tomcat-dbcp.jar
19/07/2010 14.59 70.035 tomcat-i18n-es.jar
19/07/2010 14.59 51.966 tomcat-i18n-fr.jar
19/07/2010 14.59 55.037 tomcat-i18n-ja.jar
46 File 17.635.696 byte
2 Directory 5.851.713.536 byte disponibili

If your Vaadin JAR is in your own project, then HbnContainer should be as well. If you want to have HbnContainer in the shared lib directory, then the Vaadin JAR should be there, too.

Classes in your project can find classes in the Tomcat lib directory, but not vice versa at least with the default settings due to the different classloaders used for them.

Thanks Henri,
so I place vaadin-6.4.1.jar in tomcat lib and I have no error at run-time.
What I have is a notification: “Internal error” after creating a panel with two combobox with HbnContainer as datasource.
After this error seem to be no comunication between client and erver.

what I do is:

Panel pl_body_left = CostruzioneScelteCategorie();

// add the panel to a mainWindow layout

public Panel CostruzioneScelteCategorie() {
	final Panel p = new Panel();
	
    final HbnContainer<PrimaCategoria> pc;
    pc = new HbnContainer<PrimaCategoria>(PrimaCategoria.class, this);

    final HbnContainer<SecondaCategoria> sc;
    sc = new HbnContainer<SecondaCategoria>(SecondaCategoria.class, this);
 
    ComboBox c_pc = new ComboBox("Categoria");
    c_pc.setContainerDataSource(pc);
    ComboBox c_sc = new ComboBox("SottoCategoria");
    c_sc.setContainerDataSource(sc);
    
    c_pc.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH);
    c_sc.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH);
    c_pc.setNullSelectionAllowed(false);
    c_sc.setNullSelectionAllowed(false);
    
	VerticalLayout vl_combo = new VerticalLayout();
	vl_combo.addComponent(c_pc);
	vl_combo.addComponent(c_sc);
	p.addComponent(vl_combo);
	
	return p;
}

I did few tests again.
If I populate combobox with an IndexedContainer (filled iterating on a HbnContainer object) it’s all OK.
I use a table and I set the ContainerDataSource to an HbnContainer I have the following error:
Class com.vaadin.data.hbnutil.HbnContainer does not implement the requested interface com.vaadin.data.Container

Eureka!!
I imported in my project HbnContainer.java found in WorkoutLog folders and all seem working.
I did not understand the reason: may HbnContainer.java is newer than hbncontainer-1.0.1.jar?

You probably had Vaadin JAR both in the tomcat lib directory and deployed with your project. They are loaded with different classloaders, and the classes are not seen as the same by the JVM.

You could try removing the JARs from the tomcat lib directory and having them only in the project, or making sure that you are not deploying the Vaadin JAR with the project (i.e. not having it in WEB-INF/lib but somewhere else on the classpath).

OK Henri, I removed vaadin JAR from tomcat lib and now all is working fine.
My I ask another question? I’m using TMXResourceBundle to have translations in my application.
I refer to a sample file “tmx/italian_tmx.xml” in my code. At run-time I have a “File not found” exception.
I don’t know how to say Eclipse to include that file in order to find it at run-time.
Or do I have to put it in a folder somewhere in tomcat installation or workspace directories?
Thanks in advance, I’m sorry, I feel a bit stupit making such a questions but I’m wasting a lot of time.