-
1. Re: Bijection not working in test environment
pedrosena Nov 24, 2008 8:35 PM (in response to pedrosena)Ops, I forgot the persistence.xml
<persistence-unit name="global"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/GlobalDS</jta-data-source> <class> A couple of classes here... </class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /> <property name="hibernate.connection.username" value="root" /> <property name="hibernate.connection.password" value="" /> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/travelne_global" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" /> <property name="jboss.entity.manager.factory.jndi.name" value="java:/GlobalEntityManagerFactory"/> </properties> </persistence-unit>
-
2. Re: Bijection not working in test environment
chawax Nov 25, 2008 9:33 AM (in response to pedrosena)Did you try removing static keyword ?
-
3. Re: Bijection not working in test environment
perez83 Nov 25, 2008 10:11 AM (in response to pedrosena)try this
@PersistenceContext EntityManager em;
-
4. Re: Bijection not working in test environment
pedrosena Nov 25, 2008 1:58 PM (in response to pedrosena)Hi Guys,
I tried to remove the static, it didn't work also.
I tried the @PersistenceContext but also w/o success.
One interesting thing is:
In my test case, this assertion is true, it is not throwing an assertion error right here:
assert getValue("#{entityManager}") != null;
But in my class:
@Name("MultiSchemaEntityManagerFactory") @Scope(ScopeType.SESSION) public class MultiSchemaEntityManagerFactory implements Serializable { @In private EntityManager entityManager;
It is not working properly. I don't know if I missed something(I'm a seam newbie).
So I would like any kind of help.
Thanks,
Pedro Sena
-
5. Re: Bijection not working in test environment
pedrosena Nov 25, 2008 2:07 PM (in response to pedrosena)For me, what appears to be happening is that my class is not being managed by seam.
Do I need to configure it in some other place ? I thought that just putting the @Name annotaion was enough, Do I need something else?
Thanks
-
6. Re: Bijection not working in test environment
matt.nirgue Nov 25, 2008 2:21 PM (in response to pedrosena)When JBoss starts, you should be able to see each component being initialized... You should see something like that :
... INFO [Initialization] Installing components... INFO [Component] Component: yourComponent, scope: CONVERSATION, type: JAVA_BEAN, class: com.yourproject.YourComponent ...
Look through your logs and try do find your component. If there's no trace of it in your log, then you can (almost) be sure that it's not managed by seam...
-
7. Re: Bijection not working in test environment
pedrosena Nov 25, 2008 10:58 PM (in response to pedrosena)
Matt Nirgue wrote on Nov 25, 2008 14:21:
When JBoss starts, you should be able to see each component being initialized... You should see something like that :... INFO [Initialization] Installing components... INFO [Component] Component: yourComponent, scope: CONVERSATION, type: JAVA_BEAN, class: com.yourproject.YourComponent ...
Look through your logs and try do find your component. If there's no trace of it in your log, then you can (almost) be sure that it's not managed by seam...Hi Matt,
Thanks a lot for your reply.
I'm using embedded jboss, I'm running my test using maven and, at least using maven inside eclipse, this log is not appearing.
So I suppose that my classe is not being managed by seam.
How to achive this ?
Is the @Name annotation not enough ?
I suppose that the problem may be in some XML file.
Thanks,
Pedro Sena
-
8. Re: Bijection not working in test environment
matt.nirgue Nov 26, 2008 9:59 AM (in response to pedrosena)I'm also using JBoss Embedded and Maven for my tests but I still see these logs... I think you should change your logging configuration because the logs often provide useful information. In your case, it'd help you know for sure which components is initialized, etc.
I think it'd be easier to know what's wrong with your configuration... just my opinion though! :)
-
9. Re: Bijection not working in test environment
pedrosena Nov 26, 2008 12:49 PM (in response to pedrosena)
Matt Nirgue wrote on Nov 26, 2008 09:59:
I'm also using JBoss Embedded and Maven for my tests but I still see these logs... I think you should change your logging configuration because the logs often provide useful information. In your case, it'd help you know for sure which components is initialized, etc.
I think it'd be easier to know what's wrong with your configuration... just my opinion though! :)Hi Matt,
Nice tip :)
I changed my log4j.xml and now I'm seeing an interesting thing.
My component is being managed by Seam!!! I believe that the problem is the creation order, at least, in my log, my component is being created BEFORE the entityManager that i'm trying to inject to it.
INFO [org.jboss.seam.Component] Component: MultiSchemaEntityManagerFactory, scope: SESSION, type: JAVA_BEAN, class: br.com.netsar.infra.repository.jpa.MultiSchemaEntityManagerFactory INFO [org.jboss.seam.Component] Component: entityManager, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.persistence.ManagedPersistenceContext
My component is MultiSchemaEntityManagerFactory and I'm trying to inject an entityManager in this component.
I'll see how my component's precedence and as soon as I get a result I'll post here.
Thanks a lot for your info Matt,
Pedro Sena
-
10. Re: Bijection not working in test environment
pedrosena Nov 26, 2008 1:56 PM (in response to pedrosena)LOL!!!
I'm REALLY a Seam newbie :(
I was expecting that, using the new operator, the atribute would be injected.
Now i'm using the correct, installed, version of my component and everything is working fine.
Thanks for all