welcome to my blog !

My name is Aleksey Maksimov. I am Software Architect with many years of IT experience and architecture experience. I work for a global IT consulting company and live in the United Kingdom. This is my software rants blog. I also have blog about my life happenings, in Russian. I also registered in almost all social networks, usually as ctpeko3a, sometimes as lechat and rarely as drunkenfly. Here is my FriendFeed and View my profile on LinkedIn.

May 07 2009

JBOSS Seam 2.1.1GA on JBOSS AS 5.0.1GA: Table is not mapped

Tagged Under : , , , , , ,

I created sample JBOSS Seam project in Eclipse and decided to generate entity code from  existing database. It worked fine, but when I try to run it, it shows me that Hibernade is not able to map entity beans to the corresponding tables. The error message is like this:

org.hibernate.hql.ast.QuerySyntaxException: <your table> is not mapped

I spent around three hours trying to read all available information on it, but most of it just useless – it looks like people don’t know whats happening, so they recommend bizarre tricks. Like, for example, having empry seam.settings file in each folder, meh.

Finally, I found the solution in Seam Jira: https://jira.jboss.org/jira/browse/JBSEAM-3821

They rocemmend to to force Hibernate to use Seam’s EntityManager by changing two files:

1. components.xml

    <persistence:entity-manager-factory name="bookingDatabase" installed="false"/>
    <!– If Seam loads the persistence unit (JBoss 4.x), the EntityManagerFactory will be resolved from #{bookingDatabase}.
         On JBoss AS 5, the EntityManagerFactory is retrieved from JNDI (the binding occurs during application deployment). –>
    <persistence:managed-persistence-context name="em" auto-create="true"
       entity-manager-factory="#{bookingDatabase}" persistence-unit-jndi-name="java:/bookingEntityManagerFactory"/>

2. persistence.xml

<!– Binds the EntityManagerFactory to JNDI where Seam can look it up.
              This is only relevant when the container automatically loads the persistence unit, as is the case in JBoss AS 5. –>
         <property name="jboss.entity.manager.factory.jndi.name" value="java:/bookingEntityManagerFactory"/>

Hope that Google will find that page and the proper solution would be much more easily found!

blog comments powered by Disqus