I was able to solve this by using Spring's
AbstractTransactionalJUnit4SpringContextTests (to cache the
applicationContext) and adding a new ModuleDef to PageTester. Unfortunately,
SpringModuleDef seems to take ApplicationContext as a constructor argument
in 5.0.18, but not in 5.1.05.
@ContextConfiguration(locations = {
"classpath:/applicationContext-resources.xml",
"classpath:/applicationContext-dao.xml",
"classpath:/applicationContext-service.xml",
"classpath*:/applicationContext.xml",
"/WEB-INF/applicationContext*.xml"})
public abstract class BasePageTestCase extends
AbstractTransactionalJUnit4SpringContextTests {
protected PageTester tester;
protected Document doc;
protected Map<String, String> fieldValues;
protected final Log log = LogFactory.getLog(getClass());
protected static final String MESSAGES = Constants.BUNDLE_KEY;
private int smtpPort = 25250;
@Before
public void before() {
String appPackage = "org.appfuse.webapp";
String appName = "app";
tester = new PageTester(appPackage, appName, "src/main/webapp") {
@Override
protected ModuleDef[] provideExtraModuleDefs() {
return new ModuleDef[]{new
SpringModuleDef(applicationContext)};
}
};
fieldValues = new HashMap<String, String>();
smtpPort = smtpPort + (int) (Math.random() * 100);
// change the port on the mailSender so it doesn't conflict with an
// existing SMTP server on localhost
JavaMailSenderImpl mailSender = (JavaMailSenderImpl)
applicationContext.getBean("mailSender");
mailSender.setPort(getSmtpPort());
mailSender.setHost("localhost");
}
@After
public void after() {
if (tester != null) {
tester.shutdown();
}
tester = null;
}
protected int getSmtpPort() {
return smtpPort;
}
}
Is there a better way to do this if I want to upgrade to Tapestry Spring
5.1.0.5?
Thanks,
Matt
mraible wrote:
>
> I tried changing to locator.proxy and direct instantiation, but no dice.
> For proxy(), I used:
>
> public static void
> contributeMasterObjectProvider(OrderedConfiguration<ObjectProvider>
> configuration,
> ObjectLocator
> locator) {
> configuration.add("spring", locator.proxy(ObjectProvider.class,
> SpringObjectProvider.class));
> }
>
> For direct instantiation, I used:
>
> public static void
> contributeMasterObjectProvider(OrderedConfiguration<ObjectProvider>
> configuration,
> ObjectLocator
> locator) {
> TypeCoercer coercer = locator.getService(TypeCoercer.class);
> configuration.add("spring", new SpringObjectProvider(coercer));
> }
>
> As I mentioned earlier, everything works fine when using Hibernate or JPA,
> but not with iBATIS. It hangs for a while (30+ seconds) and then spits out
> the error mentioned below). If I run the failed tests by themselves,
> everything works fine.
>
> I could change my surefire settings to fork a new JVM for each test, but
> that doesn't seem right.
>
> Is anyone testing their pages with PageTester and injecting Spring beans
> as part of that test? If so, are you using a SpringObjectProvider?
>
> Thanks,
>
> Matt
>
>
>
> Howard Lewis Ship wrote:
>>
>> There will be a trace in the console of what Tapestry IoC was doing
>> when it hit the issue.
>>
>> However, this looks like the culprit:
>>
>>
>> public static void contributeMasterObjectProvider(
>> OrderedConfiguration<ObjectProvider> configuration,
>> ObjectLocator locator) {
>> configuration.add("spring", locator
>> .autobuild(SpringObjectProvider.class));
>> }
>>
>>
>> autobuilding will attmpt to instantiat SpringObjectProvider ... but
>> that will itself require injection that falls into the
>> MasterObjectProvider. Either instantiate SOP yourself, or use the
>> proxy() method, which builds a proxy that can defer instantiation of
>> SOP until it is actually needed.
>>
>>
>> On Tue, Nov 10, 2009 at 1:55 PM, mraible <[email protected]> wrote:
>>>
>>> Hello all,
>>>
>>> I'm in the process of writing tests for AppFuse's Tapestry 5 integration
>>> and
>>> I've run into an interesting issue. When I use Hibernate or JPA as
>>> backends,
>>> my tests pass just fine. However, when I use iBATIS, they take forever
>>> and I
>>> get an OOM error and the following shows up in my logs:
>>>
>>> Construction of service 'InternalRequestGlobals' has failed due to
>>> recursion: the service depends on itself in some way. Please check
>>> org.apache.tapestry5.internal.services.InternalRequestGlobalsImpl() (at
>>> InternalRequestGlobalsImpl.java:22) via
>>> org.apache.tapestry5.internal.services.InternalModule.bind(ServiceBinder)
>>> (at InternalModule.java:65) for references to another service that is
>>> itself
>>> dependent on service 'InternalRequestGlobals'.
>>>
>>> Looking at the dependencies differences, my first guess is AspectJ is
>>> causing this, but I'm not sure.
>>>
>>> [INFO] +- org.appfuse:appfuse-ibatis:jar:2.1-SNAPSHOT:compile
>>> [INFO] | +- org.appfuse:appfuse-data-common:jar:2.1-SNAPSHOT:compile
>>> [INFO] | | +- javax.persistence:persistence-api:jar:1.0:compile
>>> [INFO] | | +- javax.xml.bind:jaxb-api:jar:2.2:compile
>>> [INFO] | | | \- javax.xml.stream:stax-api:jar:1.0-2:compile
>>> [INFO] | | \- org.compass-project:compass:jar:2.1.3:compile
>>> [INFO] | | \- org.apache.lucene:lucene-core:jar:2.4.1:compile
>>> [INFO] | +- org.apache.ibatis:ibatis-sqlmap:jar:2.3.4.726:compile
>>> [INFO] | +- org.aspectj:aspectjweaver:jar:1.6.6:compile
>>> [INFO] | +- org.aspectj:aspectjrt:jar:1.6.6:compile
>>> [INFO] | +- org.springframework:spring-aspects:jar:2.5.6:compile
>>> [INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.1:compile
>>> [INFO] | +- org.springframework:spring-jdbc:jar:2.5.6:compile
>>> [INFO] | | \- org.springframework:spring-tx:jar:2.5.6:compile
>>> [INFO] | \- org.springframework:spring-orm:jar:2.5.6:compile
>>>
>>>
>>> [INFO] +- org.appfuse:appfuse-hibernate:jar:2.1-SNAPSHOT:compile
>>> [INFO] | +- org.appfuse:appfuse-data-common:jar:2.1-SNAPSHOT:compile
>>> [INFO] | | +- javax.persistence:persistence-api:jar:1.0:compile
>>> [INFO] | | +- javax.xml.bind:jaxb-api:jar:2.2:compile
>>> [INFO] | | | \- javax.xml.stream:stax-api:jar:1.0-2:compile
>>> [INFO] | | \- org.compass-project:compass:jar:2.1.3:compile
>>> [INFO] | | \- org.apache.lucene:lucene-core:jar:2.4.1:compile
>>> [INFO] | +- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
>>> [INFO] | | +-
>>> org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA:compile
>>> [INFO] | | +- org.slf4j:slf4j-api:jar:1.4.2:compile
>>> [INFO] | | \- dom4j:dom4j:jar:1.6.1:compile
>>> [INFO] | +- org.hibernate:hibernate-core:jar:3.3.1.GA:compile
>>> [INFO] | | +- antlr:antlr:jar:2.7.6:compile
>>> [INFO] | | \- javax.transaction:jta:jar:1.1:compile
>>> [INFO] | +- javassist:javassist:jar:3.4.GA:compile
>>> [INFO] | +- org.slf4j:slf4j-log4j12:jar:1.5.2:compile
>>> [INFO] | +- org.hibernate:hibernate-ehcache:jar:3.3.1.GA:compile
>>> [INFO] | +- net.sf.ehcache:ehcache-core:jar:1.7.0:compile
>>> [INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.1:compile
>>> [INFO] | +- org.springframework:spring-jdbc:jar:2.5.6:compile
>>> [INFO] | | \- org.springframework:spring-tx:jar:2.5.6:compile
>>> [INFO] | \- org.springframework:spring-orm:jar:2.5.6:compile
>>>
>>> I also suspect it might be coming from my SpringObjectProvider (used for
>>> testing).
>>>
>>> http://source.appfuse.org/browse/~raw,r=trunk/appfuse/trunk/web/tapestry/src/test/java/org/appfuse/webapp/services/SpringObjectProvider.java
>>>
>>> This is added by an IntegrationTestModule:
>>>
>>> public class IntegrationTestModule {
>>>
>>> // contribution master object provider
>>> public static void contributeMasterObjectProvider(
>>> OrderedConfiguration<ObjectProvider> configuration,
>>> ObjectLocator locator) {
>>> configuration.add("spring", locator
>>> .autobuild(SpringObjectProvider.class));
>>> }
>>> }
>>>
>>> And wired into PageTester as follows:
>>>
>>> String appPackage = "com.mycompany.webapp";
>>> String appName = "app";
>>> tester = new PageTester(appPackage, appName, "src/main/webapp",
>>> IntegrationTestModule.class);
>>>
>>> Any help is appreciated.
>>>
>>> Thanks,
>>>
>>> Matt
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Construction-of-service-%27InternalRequestGlobals%27-has-failed-due-to-recursion%3A-tp26291936p26291936.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>>
>>
>> --
>> Howard M. Lewis Ship
>>
>> Creator of Apache Tapestry
>>
>> The source for Tapestry training, mentoring and support. Contact me to
>> learn how I can get you up and productive in Tapestry fast!
>>
>> (971) 678-5210
>> http://howardlewisship.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
>
>
--
View this message in context:
http://old.nabble.com/Construction-of-service-%27InternalRequestGlobals%27-has-failed-due-to-recursion%3A-tp26291936p26296274.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]