Hi Lance, I hear ya, same here. Okay I'm going to provide all the code and the full exception.
***** AppModuleTest ***** public class AppModuleTest { public static void bind(ServiceBinder binder) { try { ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); List<Class<?>> daos = PackageEnumerator.getClassesForPackage("org.healthresearch.etss.dao"); for (Class<?> dao : daos) { String pkg = dao.getPackage().getName(); String cls = dao.getSimpleName(); try { Class impl = contextClassLoader.loadClass(pkg + ".impl." + cls + "Impl"); binder.bind(dao, impl); } catch (ClassNotFoundException e) { // Ignore, we just won't bind that class. } } } catch (ClassNotFoundException e) { } // binder.bind(MyServiceInterface.class, MyServiceImpl.class); binder.bind(UserInfoService.class, UserInfoServiceImpl.class); binder.bind(TimeSheetService.class, TimeSheetServiceImpl.class); binder.bind(TsLogService.class, TsLogServiceImpl.class); binder.bind(ApplicationStateService.class, ApplicationStateServiceImpl.class); binder.bind(PropertyAccessService.class, PropertyAccessServiceImpl.class); binder.bind(ListModelFactory.class, ListModelFactoryImpl.class); //Search services binder.bind(SearchService.class, SearchServiceImpl.class); binder.bind(TimeSheetSearchService.class, TimeSheetSearchServiceImpl.class); binder.bind(EmployeeProfileSearchService.class, EmployeeProfileSearchServiceImpl.class); binder.bind(UserProfileSearchService.class, UserProfileSearchServiceImpl.class); binder.bind(HrPersonnelMasterSearch.class, HrPersonnelMasterSearchImpl.class); binder.bind(AccrualSearchService.class, AccrualSearchServiceImpl.class); binder.bind(LDAPQueue.class, LDAPQueueImpl.class); binder.bind(ScheduleJobs.class, ScheduleJobsImpl.class); binder.bind(EmployeeProfileService.class, EmployeeProfileServiceImpl.class); binder.bind(AccrualBalanceService.class, AccrualBalanceServiceImpl.class); binder.bind(HolidayService.class, HolidayServiceImpl.class); binder.bind(OfficeLocationService.class, OfficeLocationServiceImpl.class); binder.bind(CompOTService.class, CompOTServiceImpl.class); binder.bind(DateCheckingService.class, DateCheckingServiceImpl.class); binder.bind(TimeSheetValidationService.class, TimeSheetValidationServiceImpl.class); // MailServices binder.bind(EmailService.class, EmailServiceImpl.class); binder.bind(JavaxMailService.class, JavaxMailServiceImpl.class); binder.bind(EmailHelper.class, EmailHelperImpl.class); binder.bind(ProfileValidationService.class, ProfileValidationServiceImpl.class); binder.bind(GenericValidationService.class, GenericValidationServiceImpl.class); binder.bind(WarningService.class, WarningServiceImpl.class); binder.bind(Indexer.class, IndexerImpl.class); binder.bind(ImportJob.class, ImportJobImpl.class); binder.bind(PDFService.class, PDFServiceImpl.class).scope(ScopeConstants.PERTHREAD); } public static void contributeApplicationDefaults(MappedConfiguration<String, Object> configuration, Logger logger) throws IOException { configuration.add(SymbolConstants.PRODUCTION_MODE, "false"); configuration.add(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED, "true"); } public static void contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer> configuration) { configuration.add("trecstest1", new TestHibernateConfigurer()); } public static void contributeHibernateEntityPackageManager(org.apache.tapestry5.ioc.Configuration<String> config) { config.add("org.healthresearch.etss.entities"); } @Scope(ScopeConstants.PERTHREAD) public static FullTextSession buildFullTextSession(HibernateSessionManager sessionManager) { return Search.getFullTextSession(sessionManager.getSession()); } /** * This is a service definition, the service will be named "TimingFilter". * The interface, RequestFilter, is used within the RequestHandler service * pipeline, which is built from the RequestHandler service configuration. * Tapestry IoC is responsible for passing in an appropriate Logger * instance. Requests for static resources are handled at a higher level, so * this filter will only be invoked for Tapestry related requests. * <p/> * < * p/> * Service builder methods are useful when the implementation is inline as * an inner class (as here) or require some other kind of special * initialization. In most cases, use the static bind() method instead. * <p/> * < * p/> * If this method was named "build", then the service id would be taken from * the service interface and would be "RequestFilter". Since Tapestry * already defines a service named "RequestFilter" we use an explicit * service id that we can reference inside the contribution method. */ public RequestFilter buildTimingFilter(final Logger log) { return new RequestFilter() { public boolean service(Request request, Response response, RequestHandler handler) throws IOException { long startTime = System.currentTimeMillis(); try { // The responsibility of a filter is to invoke the corresponding method // in the handler. When you chain multiple filters together, each filter // received a handler that is a bridge to the next filter. return handler.service(request, response); } finally { long elapsed = System.currentTimeMillis() - startTime; log.info(String.format("Request time: %d ms", elapsed)); } } }; } public static void contributeApplicationDefaults(MappedConfiguration<String, Object> config) { config.add(HibernateSymbols.DEFAULT_CONFIGURATION, false); } @Match("*DAO") public static void adviseTransactions(HibernateTransactionAdvisor advisor, MethodAdviceReceiver receiver) { advisor.addTransactionCommitAdvice(receiver); } } ***** RegisteryBuilderTest ***** public abstract class RegisteryBuilderTest { protected final Registry buildRegistry(Class... moduleClasses) { RegistryBuilder builder = new RegistryBuilder(); builder.add(moduleClasses); return builder.build(); } protected abstract void cleanup(); } ***** EmailServiceImplTest ***** public class EmailServiceImplTest extends RegisteryBuilderTest { private Registry registry; private HibernateSessionManager sessionManager; private EmailService emailService; @BeforeClass protected void before() { registry = buildRegistry(AppModuleTest.class, HibernateCoreModule.class); emailService = registry.getService(EmailService.class); sessionManager = registry.getService(HibernateSessionManager.class); buildData(); } /** * Test of sendEmailReport method, of class EmailServiceImpl. */ @Test public void testSendEmailReport() { List<TimeSheetEntity> timeSheets = getCurrentSession().createCriteria(TimeSheetEntity.class) .createAlias("formState", "formState") .add(Restrictions.eq("formState.stateCode", ETSSEnum.STATE_SUPERVISOR_REVIEW)).list(); emailService.sendSupervisorReminderEmail(timeSheets); //assertEquals(timeSheets.size(), 1); } public Session getCurrentSession() { return sessionManager.getSession(); } public void buildData() { FormStateEntity state1 = getFormState("draft"); FormStateEntity state2 = getFormState(ETSSEnum.STATE_SUPERVISOR_REVIEW); FormStateEntity state3 = getFormState("final"); WorksiteEntity worksite = getWorksite("menands"); UserProfile userProfileTest1 = getUserProfile(1L, "xxx07", "First1", "Last1", "M", "xx...@domain.org"); UserProfile userProfileTest2 = getUserProfile(2L, "xxx02", "First2", "Last2", "A", "xx...@domain.org"); UserProfile userProfileTest3 = getUserProfile(3L, "xxx07", "First3", "Last3", "B", "x...@domain.org"); UserProfile userProfileTest4 = getUserProfile(4L, "xxx06", "First4", "Last4", "C", "xx...@domain.org"); UserProfile userProfileTest5 = getUserProfile(5L, "xxx01", "First5", "Last5", "D", "xx...@domain.org"); EmployeeProfile employeeTest1 = getEmployeeProfile(1L, userProfileTest1, userProfileTest2, userProfileTest3, "emp12222"); EmployeeProfile employeeTest2 = getEmployeeProfile(2L, userProfileTest2, userProfileTest2, userProfileTest3, "emp23333"); EmployeeProfile employeeTest3 = getEmployeeProfile(3L, userProfileTest3, userProfileTest2, userProfileTest3, "emp34444"); EmployeeProfile employeeTest4 = getEmployeeProfile(4L, userProfileTest4, userProfileTest5, userProfileTest3, "emp45555"); EmployeeProfile employeeTest5 = getEmployeeProfile(5L, userProfileTest5, null, userProfileTest5, "emp56666"); getTimeSheet(1L, employeeTest1, userProfileTest2, userProfileTest3, "emp12222", state1, "xxx07", worksite); getTimeSheet(2L, employeeTest2, userProfileTest2, userProfileTest3, "emp23333", state1, "xxx02", worksite); getTimeSheet(3L, employeeTest3, userProfileTest2, userProfileTest3, "emp34444", state3, "xxx07", worksite); getTimeSheet(4L, employeeTest4, null, userProfileTest5, "emp45555", state3, "xxx06", worksite); getTimeSheet(5L, employeeTest5, null, userProfileTest5, "emp56666", state2, "xxx01", worksite); sessionManager.commit(); } public FormStateEntity getFormState(String value) { FormStateEntity formState = new FormStateEntity(); formState.setName(value); formState.setStateCode(value); getCurrentSession().save(formState); return formState; } public EmployeeProfile getEmployeeProfile(Long id, UserProfile userProfile, UserProfile manager, UserProfile supervisor, String empId) { EmployeeProfile employeeProfile = new EmployeeProfile(); employeeProfile.setId(id); employeeProfile.setUserProfile(userProfile); employeeProfile.setSupervisor(supervisor); employeeProfile.setManager(manager); employeeProfile.setEmpId(empId); getCurrentSession().save(employeeProfile); return employeeProfile; } public UserProfile getUserProfile(Long id, String shortname, String firstName, String lastName, String middleInitial, String email) { UserProfile userProfile = new UserProfile(); userProfile.setId(id); userProfile.setShortname(shortname); userProfile.setFirstName(firstName); userProfile.setLastName(lastName); userProfile.setMiddleInitial(middleInitial); userProfile.setEmail(email); getCurrentSession().save(userProfile); return userProfile; } public TimeSheetEntity getTimeSheet(Long id, EmployeeProfile employee, UserProfile manager, UserProfile supervisor, String empId, FormStateEntity formState, String shortName, WorksiteEntity worksite) { TimeSheetEntity timeSheetEntity = new TimeSheetEntity(); timeSheetEntity.setId(id); timeSheetEntity.setEmpId(empId); timeSheetEntity.setEmployeeProfile(employee); timeSheetEntity.setSupervisor(supervisor); timeSheetEntity.setSupervisorOriginal(supervisor); timeSheetEntity.setManager(manager); timeSheetEntity.setEndDate(new Date()); timeSheetEntity.setFormState(formState); timeSheetEntity.setShortname(shortName); timeSheetEntity.setWorksite(worksite); getCurrentSession().save(timeSheetEntity); return timeSheetEntity; } public WorksiteEntity getWorksite(String worksite) { WorksiteEntity worksiteEntity = new WorksiteEntity(); worksiteEntity.setLocation(worksite); getCurrentSession().save(worksiteEntity); return worksiteEntity; } @Override @AfterClass protected void cleanup() { registry.cleanupThread(); registry.shutdown(); } } public class EmailServiceImpl implements EmailService { private final GenericDAO genericDAO; public EmailServiceImpl() { } On Wed, Sep 10, 2014 at 2:35 AM, Lance Java <lance.j...@googlemail.com> wrote: > Hmm, very strange. Are you calling registry.shutdown() ever? > > Is this perhaps an issue with registry.cleanupThread()? > > How many @Test annotations in the class? Does the first @Test work and the > second fail? > > Just grasping at straws here! > On 10 Sep 2014 02:05, "George Christman" <gchrist...@cardaddy.com> wrote: > > > Hi lance, I'm just using constructor injection. I have a DAO that uses > > > > public class GenericDAO { > > private final Session session; > > > > public GenericDAOImpl(Session session) { > > this.session = session; > > } > > > > } > > > > in my Module I have > > > > @Scope(ScopeConstants. > > PERTHREAD) > > public static FullTextSession > > buildFullTextSession(HibernateSessionManager sessionManager) { > > return Search.getFullTextSession(sessionManager.getSession()); > > } > > > > In my test class > > > > private Registry registry; > > private GenericDAO genericDAO; > > private EmailService emailService; > > > > @BeforeClass > > protected void before() { > > registry = buildRegistry(AppModuleTest. > > class, HibernateCoreModule.class); > > emailService = registry.getService(EmailService.class); > > genericDAO = registry.getService(GenericDAO.class); > > buildData(); > > } > > > > @Test > > public void SomeTest() { > > genericDAO.get(...) > > } > > > > When I run the test I get that exception. > > > > If I remove FullTextSession from the module or the genericDAO, problem > goes > > away. The strange part is this is not an issue with the rest of the app, > > only the test. > > > > > > On Tue, Sep 9, 2014 at 2:31 PM, Lance Java <lance.j...@googlemail.com> > > wrote: > > > > > From my understanding of the tapestry registry, these are two distinct > > > services (even though one extends the other). > > > > > > Where is this exception occurring? Are you using tapestry's @Inject > > > annotation? Is spring ioc in the mix somewhere? > > > > > > > > > > > -- > > George Christman > > www.CarDaddy.com > > P.O. Box 735 > > Johnstown, New York > > > -- George Christman www.CarDaddy.com P.O. Box 735 Johnstown, New York