[jboss-user] [JBoss Seam] - javassist related exception during Test
taskin.tas
do-not-reply at jboss.com
Tue Oct 23 20:57:50 EDT 2007
Hi to All,
I have been developing an application with seam for sometime and now I am trying to introduce testing. Everything seems to work ok with the testing environment and configuration. However I am getting the following exception while implementing tests using TestNG.
Caused by: org.hibernate.MappingException: Unknown entity: Category_$$_javassist_1
| at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
| at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
| at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180)
| at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:512)
| at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:80)
| at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
| at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
| at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
| at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
| at org.jboss.seam.persistence.HibernateSessionProxy.saveOrUpdate(HibernateSessionProxy.java:338)
| at CategoryAction.save(CategoryAction.java:142)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
| at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
| at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:37)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:54)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
| at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
| at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
| at CategoryAction_$$_javassist_0.save(CategoryAction_$$_javassist_0.java)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at com.sun.el.parser.AstValue.invoke(AstValue.java:174)
hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
| <!DOCTYPE hibernate-configuration PUBLIC
| "-//Hibernate/Hibernate Configuration DTD//EN"
| "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
|
| <hibernate-configuration>
| <session-factory name="session">
|
| <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/dummydatabase</property>
| <property name="hibernate.connection.driver_class">org.postgresql.ds.PGSimpleDataSource</property>
| <property name="hibernate.connection.user">user</property>
| <property name="hibernate.connection.password">password</property>
|
| <property name="hbm2ddl.auto">create-drop</property>
| <property name="show_sql">true</property>
| <property name="transaction.flush_before_completion">true</property>
| <property name="connection.release_mode">after_statement</property>
| <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
| <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
| <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
| <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
|
| <!-- Mapping files -->
| <!--mapping resource="category.hbm.xml"/-->
| <mapping resource="variable.hbm.xml"/>
| <mapping resource="value.hbm.xml"/>
| <mapping resource="item.hbm.xml"/>
| </session-factory>
| </hibernate-configuration>
components.xml
<?xml version="1.0" encoding="UTF-8"?>
|
| <components xmlns="http://jboss.com/products/seam/components"
| xmlns:core="http://jboss.com/products/seam/core"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="
| http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd
| http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd
| ">
|
|
| <core:init jndi-pattern="java:comp/env/payroll-ejb/#{ejbName}/local" debug="false"/>
|
| <core:manager conversation-timeout="120000"
| concurrent-request-timeout="500"
| conversation-id-parameter="cid"
| conversation-is-long-running-parameter="clr"/>
|
| <core:transactionListener/>
| <core:ejb installed="true"/>
|
|
| <core:hibernate-session-factory name="hibernateSessionFactory"/>
| <core:managed-hibernate-session name="session" auto-create="true" session-factory-jndi-name="session"/>
| </components>
Test File Source Code
import datassist.payroll.entity.Category;
| import org.jboss.seam.contexts.Contexts;
| import org.jboss.seam.mock.SeamTest;
| import org.jboss.seam.mock.SeamTest.FacesRequest;
| import org.testng.annotations.Test;
|
| public class TestIntact extends SeamTest {
|
| @Test
| public void facesTestIntact_I() throws Exception {
|
| new FacesRequest() {
|
| @Override
| protected void invokeApplication() throws Exception {
| assert invokeMethod("#{categoryAction.nevv(\"U\")}").equals("categoryDefine");
| }
|
| }.run();
|
| String id = new FacesRequest("/categoryDefine.xhtml") {
|
| @Override
| protected void updateModelValues() throws Exception {
| setValue("#{category.name}","TEST MANIA");
| }
|
| @Override
| protected void invokeApplication() {
| assert invokeMethod("#{categoryAction.save}").equals("categoryTree");
|
| }
|
| @Override
| protected void renderResponse(){
| assert true;
| }
|
| }.run();
| }
|
| }
CategoryAction.java
@End
| public String save(){
| category.stripUnusedValues();
| if (isUpdateState())
| category.arrangeValues(lastEffectiveDate);
| session.saveOrUpdate(category);
| Category parent=category.getParentCategory();
| if (parent!=null && !parent.getChildCategories().contains(category))
| parent.addToChildCategories(category);
| session.flush();
| Events.instance().raiseEvent("categoryTreeRefresh");
| category.blur();
| return "categoryTree";
| }
Version of javassist: 3.6
I am getting the exception when executing the line session.saveOrUpdate(category) on CategoryAction.java
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098094#4098094
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098094
More information about the jboss-user
mailing list