So if you download the versions I mentioned in the subject and try to generate a default project by seam-gen (including db access) then there wil be a surprise for you. Deploying this project to jboss won't actually work. When it wants to connect to the database it will suddenly go:
EntityManagerFactory not found in JNDI
Googling that string was quite painful, but after couple of hours I finally got a result!
Someone commented out something from jboss codebase and seam doesn't know about it =)
So if you're looking for a solution, you should be using another way of binding your entity manager, not jndi. To do that in j2ee enviroment (which i suppose you would have running jboss) you need to create a small helper class that will translate the entitymanager from jboss world to seam world:
@Stateless
@Name("entityManagerFactory")
public class EntityManagerFactoryHackBean implements EntityManagerFactoryHackLocal {
@PersistenceUnit(name="main")
EntityManagerFactory factory;
@Unwrap
public EntityManagerFactory getEntityMangagerFactory()
{
return factory;
}
}
see, having both stateless and name annotations it serves like a bridge between two worlds.
then you have to use it in your components.xml instead of jndi name:
<persistence:managed-persistence-context name="entityManager"
entity-manager-factory="#{entityManagerFactory}"
scope="conversation" auto-create="true" />
Thanks for this thread on jboss forum
There is another thread which has a solution without ugly hacks,
Комментариев нет:
Отправить комментарий