-
1. Re: TestNG and Hibernate
josief May 14, 2008 10:31 AM (in response to frer)I may be wrong but I'm not sure this is the best way to use Seam. I used to definee DAO classes to access to my deal with my persisted objects but I change my habits now to use class that extends EntityHome.
For instance, this is what I do to deal with the User model object:
1 - Define UserHome as a stateful EJB 3.0 with the conversation scope (that means that I alse have an interface IUserHome). The UserHome class extends EntityHome<User>2 - I get the list of all the Users, I define a UserList class that extends EntityQuery<User>.
3 - I define all my DAO methods into the UserHome and UserList classes. Both have a getEntityManager() method that allow me to do every CRUD action I want.
4 - In TestNG:
If you want to get the user list :@Test public void testPersistNewUserSuccessAdmin() throws Exception { String cid = new FacesRequest() { @Override protected void updateModelValues() throws Exception { final IUserList userList = (IUserList) Component.getInstance("userList"); List<User> listUser = userList.getResultList(); [....] } } }
My explanation is far from perfect but it could help you in your search for answers!
-
2. Re: TestNG and Hibernate
frer May 14, 2008 3:19 PM (in response to frer)Hi Adrian,
Thanks for your answer.
Unfortunately my DAO example was just an example. I wish to know how to inject my Hibernate Session in TestNG in order to be able to use it in my underlying beans...That's what I'm looking for.
I haven't yet settled on my complete architecture so I'm not sure I'll be using DAOs at all.
The only thing I'm sure is that I won't use EJB3.0 entity beans but rather hibernate POJOs.
I tried doing the following:
public void unitTestAuthenticationOK() throws Exception { new ComponentTest() { protected void testComponents() throws Exception { //Create dao and inject session AuthenticationDAO authenticationDAO = new AuthenticationDAO(); HibernateSessionFactory factory = new HibernateSessionFactory(); factory.startup(); Session session = factory.getSessionFactory().openSession(); setField(authenticationDAO, "persistenceSession", session); List<LoginUser> userList = authenticationDAO.getLoginUsers("admin", "admin", localizationContext); assert userList.size() == 1; } }.run(); }
But I get an error:
WARN [main] (SessionFactoryObjectFactory.java:98) - Could not bind factory to JNDI javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) ...
I put my hibernate.cfg.xml in the classpath:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory name="java:persistenceSession"> <property name="show_sql">false</property> <property name="hbm2ddl.auto">none</property> <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="transaction.flush_before_completion">true</property> <property name="connection.release_mode">after_statement</property> <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property> <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/dog</property> <property name="hibernate.connection.username">dog</property> <property name="hibernate.connection.password">dog</property> <mapping class="org.mdarad.system.authentication.entities.LoginGroup"/> <mapping class="org.mdarad.system.authentication.entities.LoginRole"/> <mapping class="org.mdarad.system.authentication.entities.LoginUser"/> </session-factory> </hibernate-configuration>
Anyone has an idea how to do this?
Thank you,
François
-
3. Re: TestNG and Hibernate
pmuir May 14, 2008 3:29 PM (in response to frer)Use an integration test and let Seam/Embedded JBoss handle the creation of your hibernate session as normal
-
4. Re: TestNG and Hibernate
frer May 14, 2008 5:55 PM (in response to frer)Hi Pete,
Thanks for your answer. I am currently trying to set that up and have noticed in the documentation
http://docs.jboss.com/seam/latest/reference/en/html/testing.html#d0e22927that the embedded jboss doesn't work on Java 6. Is this still the case or it is outdated documentation?
This would be quite a problem...because many of the libraries we use internally use Java 6.
Thanks,
François
-
-
6. Re: TestNG and Hibernate
frer May 14, 2008 8:02 PM (in response to frer)Thanks,
That brings me one step further to finally having it to work. I have setup my environment with what is said in your wiki and have followed the jboss documentation referenced earlier but am now getting another exception.
Here is the output from my test:
[Parser] Running: D:\dev\projects\seam\dog\srcTest\java\DogTest.xml WARN 14-05 13:56:33,743 (UnifiedLoaderRepository3.java:addClassLoader:713) -Tried to add non-URLClassLoader. Ignored WARN 14-05 13:56:35,494 (TxControl.java:<clinit>:302) -[com.arjuna.ats.arjuna.coordinator.TxControl_1] - Name of XA node not defined. Using -3f57fe38:c946:482b27d3:0 WARN 14-05 13:56:36,947 (AspectManagerService.java:baseAop:228) -Could not find base-aspects.xml file in the resources of sun.misc.Launcher$AppClassLoader@1a7bf11 WARN 14-05 13:56:41,288 (SecurityMetadataStore.java:checkDefaultSuckerPassword:311) -WARNING! POTENTIAL SECURITY RISK. It has been detected that the MessageSucker component which sucks messages from one node to another has not had its password changed from the installation default. Please see the JBoss Messaging user guide for instructions on how to do this. WARN 14-05 13:56:41,673 (ConnectionFactoryJNDIMapper.java:registerConnectionFactory:155) -supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support failover WARN 14-05 13:56:41,676 (ConnectionFactoryJNDIMapper.java:registerConnectionFactory:161) -supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balancing WARN 14-05 13:56:43,777 (JBossTimerServiceFactory.java:restoreTimerService:112) -TIMER SERVICE IS NOT INSTALLED FAILED: unitTestAuthenticationOK java.lang.NullPointerException at org.jboss.seam.servlet.ServletSessionMap.get(ServletSessionMap.java:54) at org.jboss.seam.contexts.BasicContext.get(BasicContext.java:48) at org.jboss.seam.contexts.Contexts.lookupInStatefulContexts(Contexts.java:199) at org.jboss.seam.Component.getInstance(Component.java:1839) at org.jboss.seam.Component.getInstance(Component.java:1834) at org.jboss.seam.mock.BaseSeamTest.getInstance(BaseSeamTest.java:101) at org.mdarad.system.authentication.unittests.AuthenticationTestCase.access$0(AuthenticationTestCase.java:1) at org.mdarad.system.authentication.unittests.AuthenticationTestCase$1.testComponents(AuthenticationTestCase.java:34) at org.jboss.seam.mock.BaseSeamTest$ComponentTest.run(BaseSeamTest.java:169) at org.mdarad.system.authentication.unittests.AuthenticationTestCase.unitTestAuthenticationOK(AuthenticationTestCase.java:61) ... Removed 22 stack frames =============================================== dog Tests run: 1, Failures: 1, Skips: 0 =============================================== =============================================== dog Total tests run: 1, Failures: 1, Skips: 0 ===============================================
My test case looks like this:
@Test public void unitTestAuthenticationOK() throws Exception { new ComponentTest() { protected void testComponents() throws Exception { AuthenticationAction action = ((AuthenticationAction) getInstance("authenticationAction")); assert action != null; } }.run(); }
The line 34 in the stack trace is the one doing a getInstance() call.
Any clue?
Thanks
-
7. Re: TestNG and Hibernate
frer May 15, 2008 3:42 PM (in response to frer)I've dug a little deeper but am still unable to access my seam components from my test case. When I run the embedded jboss in logging INFO, I don't see my components as being deployed (even though they are in the classpath).
Any clue on what I'm missing?
Thank you
PS: Here is the log of my embedded jboss starting:
[Parser] Running: D:\dev\projects\seam\dog\srcTest\java\DogTest.xml WARN 15-05 09:41:39,711 (UnifiedLoaderRepository3.java:addClassLoader:713) -Tried to add non-URLClassLoader. Ignored INFO 15-05 09:41:41,202 (TransactionManagerService.java:startService:127) -JBossTS Transaction Service (JTA version) - JBoss Inc. INFO 15-05 09:41:41,206 (TransactionManagerService.java:startService:129) -Setting up property manager MBean and JMX layer WARN 15-05 09:41:41,303 (TxControl.java:<clinit>:302) -[com.arjuna.ats.arjuna.coordinator.TxControl_1] - Name of XA node not defined. Using -3f57ff9c:c305:482c3d95:0 INFO 15-05 09:41:41,367 (TransactionStatusManager.java:addService:110) -[com.arjuna.ats.arjuna.recovery.TransactionStatusManager_1] - Starting service com.arjuna.ats.arjuna.recovery.ActionStatusService on port 49925 INFO 15-05 09:41:41,374 (?:?:?) -TransactionStatusManagerItem - host: 192.168.0.100 port: 49925 INFO 15-05 09:41:41,438 (TransactionStatusManager.java:start:161) -[com.arjuna.ats.arjuna.recovery.TransactionStatusManager_3] - TransactionStatusManager started on port 49925 with service com.arjuna.ats.arjuna.recovery.ActionStatusService INFO 15-05 09:41:41,450 (?:?:?) -Registering mbean for module 'arjuna' INFO 15-05 09:41:41,454 (?:?:?) -Initialising JMX agent com.arjuna.ats.internal.jbossatx.agent.LocalJBossAgentImpl INFO 15-05 09:41:41,507 (TransactionManagerService.java:startService:167) -Starting recovery manager INFO 15-05 09:41:41,516 (?:?:?) - --- Start RecoveryActivators INFO 15-05 09:41:41,535 (RecoveryManagerImple.java:<init>:142) -[com.arjuna.ats.internal.arjuna.recovery.ready] RecoveryManagerImple is ready on port 49,926 INFO 15-05 09:41:41,537 (TransactionManagerService.java:startService:172) -Recovery manager started INFO 15-05 09:41:41,538 (TransactionManagerService.java:startService:195) -Binding TransactionManager JNDI Reference WARN 15-05 09:41:43,766 (AspectManagerService.java:baseAop:228) -Could not find base-aspects.xml file in the resources of sun.misc.Launcher$AppClassLoader@1a7bf11 INFO 15-05 09:41:44,444 (AspectDeployer.java:deployXml:151) -Deploying xml into org.jboss.aop.AspectManager@12d73bb for sun.misc.Launcher$AppClassLoader@1a7bf11 INFO 15-05 09:41:45,934 (RARDeployment.java:startService:146) -Required license terms exist, view vfsfile:/D:/dev/projects/seam/dog/bin/deploy/jms-ra.rar/META-INF/ra.xml INFO 15-05 09:41:45,949 (RARDeployment.java:startService:146) -Required license terms exist, view vfsfile:/D:/dev/projects/seam/dog/bin/deploy/jboss-xa-jdbc.rar/META-INF/ra.xml INFO 15-05 09:41:45,958 (RARDeployment.java:startService:146) -Required license terms exist, view vfsfile:/D:/dev/projects/seam/dog/bin/deploy/jboss-local-jdbc.rar/META-INF/ra.xml INFO 15-05 09:41:46,483 (ConnectionFactoryBindingService.java:bindConnectionFactory:160) -Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS' WARN 15-05 09:41:46,938 (SecurityMetadataStore.java:checkDefaultSuckerPassword:311) -WARNING! POTENTIAL SECURITY RISK. It has been detected that the MessageSucker component which sucks messages from one node to another has not had its password changed from the installation default. Please see the JBoss Messaging user guide for instructions on how to do this. INFO 15-05 09:41:47,159 (ServerPeer.java:startService:312) -JBoss Messaging 1.4.0.SP1 server [0] started INFO 15-05 09:41:47,344 (ConnectionFactory.java:startService:224) -Connector bisocket://feric-pc:4457 has leasing enabled, lease period 10000 milliseconds INFO 15-05 09:41:47,345 (ConnectionFactory.java:startService:225) -org.jboss.jms.server.connectionfactory.ConnectionFactory@40d52a started INFO 15-05 09:41:47,361 (QueueService.java:startService:141) -Queue[/queue/DLQ] started, fullSize=200000, pageSize=2000, downCacheSize=2000 INFO 15-05 09:41:47,381 (ConnectionFactory.java:startService:224) -Connector bisocket://feric-pc:4457 has leasing enabled, lease period 10000 milliseconds INFO 15-05 09:41:47,382 (ConnectionFactory.java:startService:225) -org.jboss.jms.server.connectionfactory.ConnectionFactory@14f6e3f started INFO 15-05 09:41:47,385 (QueueService.java:startService:141) -Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000 WARN 15-05 09:41:47,387 (ConnectionFactoryJNDIMapper.java:registerConnectionFactory:155) -supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support failover WARN 15-05 09:41:47,388 (ConnectionFactoryJNDIMapper.java:registerConnectionFactory:161) -supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balancing INFO 15-05 09:41:47,392 (ConnectionFactory.java:startService:224) -Connector bisocket://feric-pc:4457 has leasing enabled, lease period 10000 milliseconds INFO 15-05 09:41:47,393 (ConnectionFactory.java:startService:225) -org.jboss.jms.server.connectionfactory.ConnectionFactory@bb6598 started INFO 15-05 09:41:47,407 (ConnectionFactoryBindingService.java:bindConnectionFactory:160) -Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA' INFO 15-05 09:41:48,427 (ConnectionFactoryBindingService.java:bindConnectionFactory:160) -Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=dog' to JNDI name 'java:dog' INFO 15-05 09:41:49,357 (MCKernelAbstraction.java:install:124) -installing bean: jboss.j2ee:jar=jboss-seam.jar,name=TimerServiceDispatcher,service=EJB3 with dependencies: INFO 15-05 09:41:49,357 (MCKernelAbstraction.java:install:138) - and supplies: INFO 15-05 09:41:49,358 (MCKernelAbstraction.java:install:141) - Class:org.jboss.seam.async.LocalTimerServiceDispatcher INFO 15-05 09:41:49,605 (EJBContainer.java:start:765) -STARTED EJB: org.jboss.seam.async.TimerServiceDispatcher ejbName: TimerServiceDispatcher WARN 15-05 09:41:49,653 (JBossTimerServiceFactory.java:restoreTimerService:112) -TIMER SERVICE IS NOT INSTALLED INFO 15-05 09:41:49,655 (MCKernelAbstraction.java:install:124) -installing bean: jboss.j2ee:jar=jboss-seam.jar,name=EjbSynchronizations,service=EJB3 with dependencies: INFO 15-05 09:41:49,656 (MCKernelAbstraction.java:install:138) - and supplies: INFO 15-05 09:41:49,656 (MCKernelAbstraction.java:install:141) - Class:org.jboss.seam.transaction.LocalEjbSynchronizations INFO 15-05 09:41:49,921 (EJBContainer.java:start:765) -STARTED EJB: org.jboss.seam.transaction.EjbSynchronizations ejbName: EjbSynchronizations INFO 15-05 09:41:51,232 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/async, package: org.jboss.seam.async, prefix: org.jboss.seam.async INFO 15-05 09:41:51,233 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/framework, package: org.jboss.seam.framework, prefix: org.jboss.seam.core.framework INFO 15-05 09:41:51,233 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/theme, package: org.jboss.seam.theme, prefix: org.jboss.seam.theme INFO 15-05 09:41:51,234 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/bpm, package: org.jboss.seam.bpm, prefix: org.jboss.seam.bpm INFO 15-05 09:41:51,234 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/mail, package: org.jboss.seam.mail, prefix: org.jboss.seam.mail INFO 15-05 09:41:51,234 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/security, package: org.jboss.seam.security, prefix: org.jboss.seam.security INFO 15-05 09:41:51,234 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/web, package: org.jboss.seam.web, prefix: org.jboss.seam.web INFO 15-05 09:41:51,235 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/captcha, package: org.jboss.seam.captcha, prefix: org.jboss.seam.captcha INFO 15-05 09:41:51,235 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/navigation, package: org.jboss.seam.navigation, prefix: org.jboss.seam.navigation INFO 15-05 09:41:51,235 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/core, package: org.jboss.seam.core, prefix: org.jboss.seam.core INFO 15-05 09:41:51,235 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/international, package: org.jboss.seam.international, prefix: org.jboss.seam.international INFO 15-05 09:41:51,237 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/jms, package: org.jboss.seam.jms, prefix: org.jboss.seam.jms INFO 15-05 09:41:51,237 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/transaction, package: org.jboss.seam.transaction, prefix: org.jboss.seam.transaction INFO 15-05 09:41:51,237 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/drools, package: org.jboss.seam.drools, prefix: org.jboss.seam.drools INFO 15-05 09:41:51,238 (Initialization.java:addNamespace:787) -Namespace: http://jboss.com/products/seam/persistence, package: org.jboss.seam.persistence, prefix: org.jboss.seam.persistence INFO 15-05 09:41:51,251 (Initialization.java:initComponentsFromXmlDocument:147) -reading /WEB-INF/components.xml INFO 15-05 09:41:51,279 (Initialization.java:initComponentsFromXmlDocuments:131) -reading jar:file:/D:/dev/projects/seam/dog/lib/ear/jboss-seam.jar!/META-INF/components.xml INFO 15-05 09:41:51,285 (Initialization.java:loadFromResource:842) -reading properties from: /seam.properties INFO 15-05 09:41:51,285 (Initialization.java:loadFromResource:842) -reading properties from: /jndi.properties INFO 15-05 09:41:51,288 (Initialization.java:init:567) -initializing Seam INFO 15-05 09:41:51,319 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.transaction.transaction INFO 15-05 09:41:51,321 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.core.manager INFO 15-05 09:41:51,325 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.core.expressions INFO 15-05 09:41:51,328 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.web.isUserInRole INFO 15-05 09:41:51,329 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.security.identity INFO 15-05 09:41:51,329 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.bpm.businessProcess INFO 15-05 09:41:51,330 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.web.userPrincipal INFO 15-05 09:41:51,330 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.persistence.persistenceProvider INFO 15-05 09:41:51,334 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.core.resourceLoader INFO 15-05 09:41:51,336 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.web.parameters INFO 15-05 09:41:51,338 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.transaction.synchronizations INFO 15-05 09:41:51,341 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.core.locale INFO 15-05 09:41:51,342 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.security.entityPermissionChecker INFO 15-05 09:41:51,343 (Initialization.java:addComponentDescriptor:475) -two components with same name, higher precedence wins: org.jboss.seam.core.locale INFO 15-05 09:41:51,381 (Component.java:<init>:246) -Component: org.jboss.seam.core.init, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Init INFO 15-05 09:41:51,414 (Initialization.java:installComponents:899) -Installing components... INFO 15-05 09:41:51,443 (Component.java:<init>:246) -Component: authenticator, scope: EVENT, type: JAVA_BEAN, class: org.mdarad.system.authentication.actions.AuthenticationAction INFO 15-05 09:41:51,736 (Component.java:<init>:246) -Component: dogAction, scope: EVENT, type: JAVA_BEAN, class: org.mdarad.samples.totaltest.actions.DogAction INFO 15-05 09:41:51,760 (Component.java:<init>:246) -Component: hibernateSessionFactory, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.persistence.HibernateSessionFactory INFO 15-05 09:41:51,775 (Component.java:<init>:246) -Component: org.jboss.seam.async.dispatcher, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.async.ThreadPoolDispatcher INFO 15-05 09:41:51,817 (Component.java:<init>:246) -Component: org.jboss.seam.captcha.captcha, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.captcha.Captcha INFO 15-05 09:41:51,834 (Component.java:<init>:246) -Component: org.jboss.seam.captcha.captchaImage, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.captcha.CaptchaImage INFO 15-05 09:41:51,889 (Component.java:<init>:246) -Component: org.jboss.seam.core.ConversationIdGenerator, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationIdGenerator INFO 15-05 09:41:51,906 (Component.java:<init>:246) -Component: org.jboss.seam.core.contexts, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Contexts INFO 15-05 09:41:51,934 (Component.java:<init>:246) -Component: org.jboss.seam.core.conversation, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.Conversation INFO 15-05 09:41:51,950 (Component.java:<init>:246) -Component: org.jboss.seam.core.conversationEntries, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationEntries INFO 15-05 09:41:51,959 (Component.java:<init>:246) -Component: org.jboss.seam.core.conversationListFactory, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationList INFO 15-05 09:41:51,971 (Component.java:<init>:246) -Component: org.jboss.seam.core.conversationPropagation, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationPropagation INFO 15-05 09:41:52,000 (Component.java:<init>:246) -Component: org.jboss.seam.core.conversationStackFactory, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationStack INFO 15-05 09:41:52,009 (Component.java:<init>:246) -Component: org.jboss.seam.core.events, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Events INFO 15-05 09:41:52,020 (Component.java:<init>:246) -Component: org.jboss.seam.core.expressions, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.faces.FacesExpressions INFO 15-05 09:41:52,028 (Component.java:<init>:246) -Component: org.jboss.seam.core.interpolator, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Interpolator INFO 15-05 09:41:52,042 (Component.java:<init>:246) -Component: org.jboss.seam.core.locale, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.international.Locale INFO 15-05 09:41:52,069 (Component.java:<init>:246) -Component: org.jboss.seam.core.manager, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.faces.FacesManager INFO 15-05 09:41:52,105 (Component.java:<init>:246) -Component: org.jboss.seam.core.resourceBundle, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.ResourceBundle INFO 15-05 09:41:52,131 (Component.java:<init>:246) -Component: org.jboss.seam.core.resourceLoader, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.faces.ResourceLoader INFO 15-05 09:41:52,164 (Component.java:<init>:246) -Component: org.jboss.seam.core.validators, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Validators INFO 15-05 09:41:52,183 (Component.java:<init>:246) -Component: org.jboss.seam.exception.exceptions, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.exception.Exceptions INFO 15-05 09:41:52,204 (Component.java:<init>:246) -Component: org.jboss.seam.faces.dataModels, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.faces.DataModels INFO 15-05 09:41:52,218 (Component.java:<init>:246) -Component: org.jboss.seam.faces.facesContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.faces.FacesContext INFO 15-05 09:41:52,252 (Component.java:<init>:246) -Component: org.jboss.seam.faces.facesMessages, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.faces.FacesMessages INFO 15-05 09:41:52,261 (Component.java:<init>:246) -Component: org.jboss.seam.faces.facesPage, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.faces.FacesPage INFO 15-05 09:41:52,269 (Component.java:<init>:246) -Component: org.jboss.seam.faces.httpError, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.faces.HttpError INFO 15-05 09:41:52,277 (Component.java:<init>:246) -Component: org.jboss.seam.faces.redirect, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.faces.Redirect INFO 15-05 09:41:52,286 (Component.java:<init>:246) -Component: org.jboss.seam.faces.switcher, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.faces.Switcher INFO 15-05 09:41:52,314 (Component.java:<init>:246) -Component: org.jboss.seam.faces.uiComponent, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.faces.UiComponent INFO 15-05 09:41:52,329 (Component.java:<init>:246) -Component: org.jboss.seam.faces.validation, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.faces.Validation INFO 15-05 09:41:52,338 (Component.java:<init>:246) -Component: org.jboss.seam.framework.currentDate, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.framework.CurrentDate INFO 15-05 09:41:52,349 (Component.java:<init>:246) -Component: org.jboss.seam.framework.currentDatetime, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.framework.CurrentDatetime INFO 15-05 09:41:52,375 (Component.java:<init>:246) -Component: org.jboss.seam.framework.currentTime, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.framework.CurrentTime INFO 15-05 09:41:52,385 (Component.java:<init>:246) -Component: org.jboss.seam.international.localeSelector, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.international.LocaleSelector INFO 15-05 09:41:52,395 (Component.java:<init>:246) -Component: org.jboss.seam.international.messagesFactory, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.international.Messages INFO 15-05 09:41:52,403 (Component.java:<init>:246) -Component: org.jboss.seam.international.timeZone, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.international.TimeZone INFO 15-05 09:41:52,431 (Component.java:<init>:246) -Component: org.jboss.seam.international.timeZoneSelector, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.international.TimeZoneSelector INFO 15-05 09:41:52,452 (Component.java:<init>:246) -Component: org.jboss.seam.navigation.pages, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.navigation.Pages INFO 15-05 09:41:52,470 (Component.java:<init>:246) -Component: org.jboss.seam.navigation.safeActions, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.navigation.SafeActions INFO 15-05 09:41:52,485 (Component.java:<init>:246) -Component: org.jboss.seam.persistence.persistenceContexts, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.persistence.PersistenceContexts INFO 15-05 09:41:52,525 (Component.java:<init>:246) -Component: org.jboss.seam.persistence.persistenceProvider, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.persistence.HibernatePersistenceProvider INFO 15-05 09:41:52,541 (Component.java:<init>:246) -Component: org.jboss.seam.security.configurationFactory, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.security.Configuration INFO 15-05 09:41:52,556 (Component.java:<init>:246) -Component: org.jboss.seam.security.entityPermissionChecker, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.security.HibernateEntityPermissionChecker INFO 15-05 09:41:52,568 (Component.java:<init>:246) -Component: org.jboss.seam.security.facesSecurityEvents, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.security.FacesSecurityEvents INFO 15-05 09:41:52,596 (Component.java:<init>:246) -Component: org.jboss.seam.security.identity, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.security.Identity INFO 15-05 09:41:52,607 (Component.java:<init>:246) -Component: org.jboss.seam.theme.themeFactory, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.theme.Theme INFO 15-05 09:41:52,616 (Component.java:<init>:246) -Component: org.jboss.seam.theme.themeSelector, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.theme.ThemeSelector INFO 15-05 09:41:52,624 (Component.java:<init>:246) -Component: org.jboss.seam.transaction.synchronizations, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.transaction.SeSynchronizations INFO 15-05 09:41:52,641 (Component.java:<init>:246) -Component: org.jboss.seam.transaction.transaction, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.transaction.HibernateTransaction INFO 15-05 09:41:52,672 (Component.java:<init>:246) -Component: org.jboss.seam.web.exceptionFilter, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.web.ExceptionFilter INFO 15-05 09:41:52,683 (Component.java:<init>:246) -Component: org.jboss.seam.web.isUserInRole, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.faces.IsUserInRole INFO 15-05 09:41:52,697 (Component.java:<init>:246) -Component: org.jboss.seam.web.loggingFilter, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.web.LoggingFilter INFO 15-05 09:41:52,710 (Component.java:<init>:246) -Component: org.jboss.seam.web.multipartFilter, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.web.MultipartFilter INFO 15-05 09:41:52,732 (Component.java:<init>:246) -Component: org.jboss.seam.web.parameters, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.faces.Parameters INFO 15-05 09:41:52,741 (Component.java:<init>:246) -Component: org.jboss.seam.web.redirectFilter, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.web.RedirectFilter INFO 15-05 09:41:52,749 (Component.java:<init>:246) -Component: org.jboss.seam.web.servletContexts, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.web.ServletContexts INFO 15-05 09:41:52,757 (Component.java:<init>:246) -Component: org.jboss.seam.web.session, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.web.Session INFO 15-05 09:41:52,770 (Component.java:<init>:246) -Component: org.jboss.seam.web.userPrincipal, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.faces.UserPrincipal INFO 15-05 09:41:52,812 (Component.java:<init>:246) -Component: org.mdarad.system.authentication.dao.AuthentificationDAO, scope: EVENT, type: JAVA_BEAN, class: org.mdarad.system.authentication.dao.AuthenticationDAOImpl INFO 15-05 09:41:52,838 (Component.java:<init>:246) -Component: org.mdarad.system.authentication.dao.LoginUserDAO, scope: EVENT, type: JAVA_BEAN, class: org.mdarad.system.authentication.dao.LoginUserDAOImpl INFO 15-05 09:41:52,858 (Component.java:<init>:246) -Component: org.mdarad.system.authentication.facades.AuthenticationFacade, scope: EVENT, type: JAVA_BEAN, class: org.mdarad.system.authentication.facades.AuthenticationFacadeImpl INFO 15-05 09:41:52,883 (Component.java:<init>:246) -Component: org.mdarad.system.authentication.facades.LoginUserFacade, scope: EVENT, type: JAVA_BEAN, class: org.mdarad.system.authentication.facades.LoginUserFacadeImpl INFO 15-05 09:41:52,895 (Component.java:<init>:246) -Component: persistenceSession, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.persistence.ManagedHibernateSession INFO 15-05 09:41:52,911 (Component.java:<init>:246) -Component: serviceLocator, scope: EVENT, type: JAVA_BEAN, class: org.mdarad.global.ServiceLocator INFO 15-05 09:41:52,916 (Contexts.java:startup:303) -starting up: org.jboss.seam.security.facesSecurityEvents INFO 15-05 09:41:52,917 (Contexts.java:startup:303) -starting up: org.jboss.seam.navigation.pages INFO 15-05 09:41:52,935 (Contexts.java:startup:303) -starting up: hibernateSessionFactory INFO 15-05 09:41:54,823 (Initialization.java:init:597) -done initializing Seam INFO 15-05 09:41:54,879 (SeamFilter.java:init:96) -Initializing filter: org.jboss.seam.web.redirectFilter INFO 15-05 09:41:54,879 (SeamFilter.java:init:96) -Initializing filter: org.jboss.seam.web.exceptionFilter INFO 15-05 09:41:54,879 (SeamFilter.java:init:96) -Initializing filter: org.jboss.seam.web.multipartFilter INFO 15-05 09:41:54,880 (SeamFilter.java:init:96) -Initializing filter: org.jboss.seam.web.loggingFilter FAILED: integrationTestGetSeamContextComponents java.lang.NullPointerException at org.jboss.seam.servlet.ServletSessionMap.get(ServletSessionMap.java:54) at org.jboss.seam.contexts.BasicContext.get(BasicContext.java:48) at org.jboss.seam.contexts.Contexts.lookupInStatefulContexts(Contexts.java:199) at org.jboss.seam.Component.getInstance(Component.java:1839) at org.mdarad.system.authentication.unittests.AuthenticationTestCase$1.testComponents(AuthenticationTestCase.java:54) at org.jboss.seam.mock.BaseSeamTest$ComponentTest.run(BaseSeamTest.java:169) at org.mdarad.system.authentication.unittests.AuthenticationTestCase.integrationTestGetSeamContextComponents(AuthenticationTestCase.java:57) ... Removed 22 stack frames
-
8. Re: TestNG and Hibernate
frer May 15, 2008 4:15 PM (in response to frer)BTW,
I have tried all these different methods to access my component but they all fail with the same NullPointerException that I listed above.
getInstance("authenticator"); Component.getInstance("authenticator"); Component.getInstance("authenticator", true); getValue("#{authenticator}");
Any help would be greatly appreciated...I'm quite stuck at this point.
Thank you,
-
9. Re: TestNG and Hibernate
pmuir May 15, 2008 11:09 PM (in response to frer)Try doing the test inside a FacesRequest.
-
10. Re: TestNG and Hibernate
frer May 16, 2008 6:29 PM (in response to frer)Hi,
I can't seem to setup the FacesRequest test. I try creating an empty one:
@Test public void integrationTestGetSeamContextComponentsWithFacesRequest() throws Exception { new FacesRequest("/hello.xhtml") { @Override protected void updateModelValues() throws Exception { } @Override protected void invokeApplication() { } @Override protected void renderResponse() { } }.run(); }
But get the following stack trace:
java.lang.NullPointerException at org.jboss.seam.mock.MockExternalContext$3.getAttribute(MockExternalContext.java:361) at org.jboss.seam.mock.MockExternalContext$AttributeMap.get(MockExternalContext.java:385) at org.jboss.seam.contexts.BasicContext.get(BasicContext.java:48) at org.jboss.seam.Component.getInstance(Component.java:1851) at org.jboss.seam.Component.getInstance(Component.java:1829) at org.jboss.seam.web.Session.getInstance(Session.java:122) at org.jboss.seam.contexts.FacesLifecycle.beginRequest(FacesLifecycle.java:54) at org.jboss.seam.jsf.SeamPhaseListener.beforeRestoreView(SeamPhaseListener.java:377) at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:137) at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114) at org.jboss.seam.mock.BaseSeamTest$Request.restoreViewPhase(BaseSeamTest.java:735) at org.jboss.seam.mock.BaseSeamTest$Request.emulateJsfLifecycle(BaseSeamTest.java:597) at org.jboss.seam.mock.BaseSeamTest$Request.access$300(BaseSeamTest.java:184) at org.jboss.seam.mock.BaseSeamTest$Request$2.doFilter(BaseSeamTest.java:530) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:524) at org.mdarad.system.authentication.unittests.AuthenticationTestCase.integrationTestGetSeamContextComponentsWithFacesRequest(AuthenticationTestCase.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580) at org.testng.internal.Invoker.invokeMethod(Invoker.java:478) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110) at org.testng.TestRunner.runWorkers(TestRunner.java:712) at org.testng.TestRunner.privateRun(TestRunner.java:582) at org.testng.TestRunner.run(TestRunner.java:477) at org.testng.SuiteRunner.runTest(SuiteRunner.java:324) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292) at org.testng.SuiteRunner.run(SuiteRunner.java:198) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823) at org.testng.TestNG.runSuitesLocally(TestNG.java:790) at org.testng.TestNG.run(TestNG.java:708) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
Any idea what's wrong with my setup?
Thanks,
François
-
11. Re: TestNG and Hibernate
frer May 20, 2008 5:37 PM (in response to frer)Still not able to get it working.
Here is my latest test that fails:
- Install JDK 1.6.0 06-b02 (which contains correct jaxb version)
- Download Seam 2.0.2.GA
- Use seam-gen to generate a project
- In the generated project replace the bootstrap directory by the one found in the embedded jboss listed in http://in.relation.to/Bloggers/EmbeddedJBossUpdate as well as the three libraries: jboss-embedded-all.jar, thirdparty.jar and hibernate-all.jar)
- Create a simple FacesRequest:
package org.mdarad.samples.totaltest.test; import org.jboss.seam.mock.SeamTest; import org.testng.annotations.Test; public class EmptyTestCase extends SeamTest{ @Override public void begin() { super.begin(); } @Override public void end() { super.end(); } @Test public void integrationTestGetSeamContextComponentsWithFacesRequest() throws Exception { new FacesRequest("/home.xhtml") { @Override protected void updateModelValues() throws Exception { } @Override protected void invokeApplication() { } @Override protected void renderResponse() { } }.run(); } }
- Launch the test case using the ant task provided by seam-gen
I get the same exception as I listed above.
java.lang.NullPointerException at org.jboss.seam.mock.MockExternalContext$3.getAttribute(MockExternalContext.java:361) at org.jboss.seam.mock.MockExternalContext$AttributeMap.get(MockExternalContext.java:385) at org.jboss.seam.contexts.BasicContext.get(BasicContext.java:48) at org.jboss.seam.Component.getInstance(Component.java:1854) at org.jboss.seam.Component.getInstance(Component.java:1832) at org.jboss.seam.web.Session.getInstance(Session.java:122) at org.jboss.seam.contexts.FacesLifecycle.endRequest(FacesLifecycle.java:109) at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:550) at org.mdarad.samples.totaltest.test.EmptyTestCase.integrationTestGetSeamContextComponentsWithFacesReque
Therefore it doesn't seem to be my setup that is incorrect since it is the same as seam-gen.
Any ideas?
-
12. Re: TestNG and Hibernate
frer May 20, 2008 5:55 PM (in response to frer)I've also tried reverting from jdk 1.6 to 1.5 using the same bootstrap and libs as the 2.0.2.GA seam-gen and get the same exception...