Question

When I configure maven surefire plugin to print the full stack trace using

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.15</version>
  <configuration>
    <trimStackTrace>false</trimStackTrace>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <useFile>false</useFile>
    <redirectTestOutputToFile>false</redirectTestOutputToFile>
  </configuration>
</plugin>

It doesn't seem to influence the nested stacks as they're still cut, example:

org.apache.openejb.OpenEjbContainer$AssembleApplicationException: org.apache.openejb.OpenEJBException: Creating application failed: /mnt/DATA/richter/NetBeansProjects/issue-openwebbeans: couldn't start owb context
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:427)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
at de.pgalise.issue.openwebbeans.TestUtils.getContainer(TestUtils.java:50)
at de.pgalise.issue.openwebbeans.CityCtrlTest.setUp(CityCtrlTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.openejb.OpenEJBException: Creating application failed: /mnt/DATA/richter/NetBeansProjects/issue-openwebbeans: couldn't start owb context
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:901)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:616)
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:423)
... 20 more
Caused by: org.apache.openejb.OpenEJBRuntimeException: couldn't start owb context
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:161)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:40)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:803)
... 22 more
Caused by: org.apache.openejb.OpenEJBRuntimeException: javax.enterprise.event.ObserverException: Caught Exception while handling event object with type : org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:187)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:159)
... 24 more
Caused by: javax.enterprise.event.ObserverException: Caught Exception while handling event object with type : org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl
at org.apache.webbeans.event.NotificationManager.fireEvent(NotificationManager.java:501)
at org.apache.webbeans.container.BeanManagerImpl.fireEvent(BeanManagerImpl.java:446)
at org.apache.webbeans.container.BeanManagerImpl.fireLifecycleEvent(BeanManagerImpl.java:436)
at org.apache.webbeans.config.BeansDeployer.fireAfterBeanDiscoveryEvent(BeansDeployer.java:362)
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:199)
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:184)
... 25 more
Caused by: org.apache.webbeans.exception.WebBeansException: java.lang.reflect.InvocationTargetException
at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:272)
at org.apache.webbeans.event.NotificationManager.fireEvent(NotificationManager.java:482)
... 30 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:266)
... 31 more
Caused by: java.lang.NoSuchMethodError: javax.enterprise.inject.spi.BeanManager.getInjectionTargetFactory(Ljavax/enterprise/inject/spi/AnnotatedType;)Ljavax/enterprise/inject/spi/InjectionTargetFactory;
at com.sun.faces.util.cdi11.CDIUtilImpl.createHelperBean(CDIUtilImpl.java:76)
at com.sun.faces.application.view.ViewScopeExtension.afterBeanDiscovery(ViewScopeExtension.java:130)
... 36 more

I assume that the documentation for trimStackTrace "Whether to trim the stack trace in the reports to just the lines within the test, or show the full trace." isn't really sufficient as it doesn't make any distinction between stack and nested stacks. Does one have any possibility to control both?

Was it helpful?

Solution

You already see the full stack trace here I guess ;) About the "... 24 more" patterns in the sample you provide, I don't know and don't think you can get them.

About the role, and what you think of as uneffective, of the surefire configuration "trimStackTrace" property, I struggled a while, not understanding why I was seeing the exception root cause when running a test from IntelliJ, but not when ran from a maven command line. Here you'll see the property is truly effective for enabling the display of exceptions root causes.

Without the "trimStackTrace" (default: false) surefire configuration property, I had this output:

2014-03-27 19:29:30,933 [main] DEBUG  o.h.c.annotations.SimpleValueBinder - Starting fillSimpleValue for lastFetchTime
2014-03-27 19:29:30,933 [main] DEBUG  org.hibernate.cfg.Configuration - Processing fk mappings (*ToOne and JoinedSubclass)
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 5.032 sec (StorageHelper.java:35)
    at com.company.foobar.helper.StorageHelper.getInstance(StorageHelper.java:26)
    at com.company.foobar.StorageHelperTest.foo(StorageHelperTest.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:254)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:149)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)


Results :

Tests in error: 
  StorageHelperTest.foo:40 » Persistence [PersistenceUnit: default-persistence-u...

Setting the "trimStackTrace" property, on "true", I now get the exceptions root causes:

2014-03-27 19:29:30,933 [main] DEBUG  o.h.c.annotations.SimpleValueBinder - Starting fillSimpleValue for lastFetchTime
2014-03-27 19:29:30,933 [main] DEBUG  org.hibernate.cfg.Configuration - Processing fk mappings (*ToOne and JoinedSubclass)
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 5.032 sec (StorageHelper.java:35)
    at com.company.foobar.helper.StorageHelper.getInstance(StorageHelper.java:26)
    at com.company.foobar.StorageHelperTest.foo(StorageHelperTest.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:254)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:149)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: org.hibernate.AnnotationException: A Foreign key refering com.company.foobar.bean.FooBarItemCriterias from com.company.foobar.bean.FooBarOpportunity has the wrong number of column. should be 22
    at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:450)
    at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:117)
    at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1596)
    at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1519)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1420)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
    ... 36 more


Results :

Tests in error: 
  StorageHelperTest.foo:40 » Persistence [PersistenceUnit: default-persistence-u...

By the way, this option is documented as "Whether to trim the stack trace in the reports to just the lines within the test, or show the full trace" which is ambiguous. At first, I thought "reports" were only the XML and text files you can find in "${basedir}/target/surefire-reports/", but it mainly designates the surefire console output, and also those files by extension.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top