Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes scala affect AspectJ/Spring AOP at all? I'm having a thread locking problem when running tests when an @Configurable is being called
    text
    copied!<p>I have a strange problem where when I run my tests using maven, it locks whenever a test method calls into an object with an annotation @Configurable. I can run the tests fine in IDEA using the AspectJ Weaver plugin (remarkably), but I cannot do it with maven (whether I execute them in IDEA or just in a terminal).</p> <p>Even weirder, if I press ctrl-c, it does not kill the process. It just keeps a 500meg process in memory for eternity until I kill it using the System Monitor in Ubuntu.</p> <p>This problem never happened until I added Scala to my Java project. Note, I'm not compiling Scala code - just including jars that were compiled with scala and I'm including the Scala compiler/library jars as part of the classpath.</p> <p>Basically, Maven will run a bunch of tests and then hang:</p> <pre><code>Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.206 sec Running jobprep.domain.student.ActiveQuestionTests Tests run: 26, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.065 sec Running jobprep.domain.sysadmin.WebpageValidationTests Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.225 sec Running jobprep.domain.question.openended.OpenEndedStudentSubmissionDeserializerTests </code></pre> <p>When it comes to OpenEndedStudentSubmissionDeserializerTests, it freezes. It would appear that the reason why is that OpenEndedStudentSubmissionDeserializer is using @Configurable. If I comment out the test class and run the tests again, it'll just freeze on the next test class that uses @Configurable.</p> <p><strong>EDIT</strong>: It's interesting enough, if I tell maven to just run the tests in the "jobprep.domain.question.openended" package, it works 100%. If I tell it to run everything in "jobprep.domain", it still works! If I tell it to run everything in "jobprep", then the problem happens.</p> <p>Is there something I should be aware of with Scala, AspectJ, Spring, etc. when it comes to this root package?</p> <p>In Maven, if I tell surefire to load only a subset of my tests, it works. 893 out of the 1096 tests in my test suite will <strong>run</strong> and <strong>pass</strong>. This isn't perfect though because I need to get the remaining tests to work still:</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;2.6&lt;/version&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;version&gt;4.8.1&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;configuration&gt; &lt;includes&gt; &lt;include&gt;**/dao/*Tests.java&lt;/include&gt; &lt;include&gt;**/domain/*Tests.java&lt;/include&gt; &lt;include&gt;**/domain/**/*Tests.java&lt;/include&gt; &lt;include&gt;**/service/*Tests.java&lt;/include&gt; &lt;include&gt;**/service/**/*Tests.java&lt;/include&gt; &lt;include&gt;**/validator/*Tests.java&lt;/include&gt; &lt;/includes&gt; &lt;excludes&gt; &lt;exclude&gt;**/Abstract*Tests*.java&lt;/exclude&gt; &lt;exclude&gt;**/DatabaseTests.java&lt;/exclude&gt; &lt;exclude&gt;**/ControllerTests.java&lt;/exclude&gt; &lt;exclude&gt;**/ValidationTests.java&lt;/exclude&gt; &lt;/excludes&gt; &lt;skipTests&gt;false&lt;/skipTests&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre> <p>It sucks that I have to be this fine-grained, but I don't know any other way to go about solving this problem. </p> <p>Anyway, once I add this line, it starts to lock up at the OpenEndedSubmissionDeserializerTests like before:</p> <pre><code>&lt;include&gt;**/controllers/*Tests.java&lt;/include&gt; </code></pre> <p>You know what's curious though? If I run the tests for controllers <em>only</em>, it works! Bloody hell! Could this mean they both run separately, but not together?!?</p> <p>Anyway, when maven frezes, if I press CTRL-\ in linux instead of CTRL-C, this is what happens:</p> <pre><code>"com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1" daemon prio=10 tid=0x00007f190cb1e800 nid=0x77d in Object.wait() [0x00007f191015b000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on &lt;0x00007f191b06e4b8&gt; (a com.mchange.v2.async.ThreadPoolAsynchronousRunner) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:534) - locked &lt;0x00007f191b06e4b8&gt; (a com.mchange.v2.async.ThreadPoolAsynchronousRunner) "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0" daemon prio=10 tid=0x00007f190c7fb800 nid=0x77c in Object.wait() [0x00007f191025c000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on &lt;0x00007f191b06e4b8&gt; (a com.mchange.v2.async.ThreadPoolAsynchronousRunner) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:534) - locked &lt;0x00007f191b06e4b8&gt; (a com.mchange.v2.async.ThreadPoolAsynchronousRunner) "Timer-0" daemon prio=10 tid=0x00007f190d396800 nid=0x77b in Object.wait() [0x00007f191035d000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on &lt;0x00007f191b073aa8&gt; (a java.util.TaskQueue) at java.util.TimerThread.mainLoop(Timer.java:509) - locked &lt;0x00007f191b073aa8&gt; (a java.util.TaskQueue) at java.util.TimerThread.run(Timer.java:462) "Low Memory Detector" daemon prio=10 tid=0x00007f190c025800 nid=0x740 runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE "CompilerThread1" daemon prio=10 tid=0x00007f190c023000 nid=0x73f waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "CompilerThread0" daemon prio=10 tid=0x00007f190c020000 nid=0x73e waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "Signal Dispatcher" daemon prio=10 tid=0x00007f190c01e000 nid=0x73d waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "Finalizer" daemon prio=10 tid=0x0000000040c03800 nid=0x73c in Object.wait() [0x00007f19119e8000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on &lt;0x00007f19181046f8&gt; (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118) - locked &lt;0x00007f19181046f8&gt; (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134) at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159) "Reference Handler" daemon prio=10 tid=0x0000000040c01000 nid=0x73b in Object.wait() [0x00007f1911ae9000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on &lt;0x00007f1918104670&gt; (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Object.java:485) at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116) - locked &lt;0x00007f1918104670&gt; (a java.lang.ref.Reference$Lock) "main" prio=10 tid=0x0000000040b78800 nid=0x735 waiting on condition [0x00007f193bc5e000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for &lt;0x00007f191d8b6a58&gt; (a java.util.concurrent.CountDownLatch$Sync) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158) at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811) at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:969) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1281) at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:207) at org.hsqldb.lib.CountUpDownLatch.await(Unknown Source) at org.hsqldb.Session.executeCompiledStatement(Unknown Source) at org.hsqldb.Session.execute(Unknown Source) - locked &lt;0x00007f191d8b6358&gt; (a org.hsqldb.Session) at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source) at org.hsqldb.jdbc.JDBCPreparedStatement.executeQuery(Unknown Source) - locked &lt;0x00007f19313c0b70&gt; (a org.hsqldb.jdbc.JDBCPreparedStatement) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1869) at org.hibernate.loader.Loader.doQuery(Loader.java:718) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270) at org.hibernate.loader.Loader.loadEntity(Loader.java:1953) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3270) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:269) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:997) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:990) at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:519) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:512) at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:506) at jobprep.dao.BaseDaoSupport.find(BaseDaoSupport.java:65) at jobprep.dao.BaseDaoSupport.mandatoryFind(BaseDaoSupport.java:69) at jobprep.domain.question.openended.OpenEndedStudentSubmissionDeserializer.parseActiveQuestion(OpenEndedStudentSubmissionDeserializer.java:42) at jobprep.domain.question.openended.OpenEndedStudentSubmissionDeserializer.deserialize(OpenEndedStudentSubmissionDeserializer.java:30) at jobprep.domain.question.openended.OpenEndedStudentSubmissionDeserializerTests.deserialize(OpenEndedStudentSubmissionDeserializerTests.java:44) at jobprep.domain.question.openended.OpenEndedStudentSubmissionDeserializerTests.deserializeWithNoText(OpenEndedStudentSubmissionDeserializerTests.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102) at org.apache.maven.surefire.Surefire.run(Surefire.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021) "VM Thread" prio=10 tid=0x0000000040bfc800 nid=0x73a runnable "GC task thread#0 (ParallelGC)" prio=10 tid=0x0000000040b8b800 nid=0x736 runnable "GC task thread#1 (ParallelGC)" prio=10 tid=0x0000000040b8d800 nid=0x737 runnable "GC task thread#2 (ParallelGC)" prio=10 tid=0x0000000040b8f000 nid=0x738 runnable "GC task thread#3 (ParallelGC)" prio=10 tid=0x0000000040b91000 nid=0x739 runnable "VM Periodic Task Thread" prio=10 tid=0x00007f190c028800 nid=0x741 waiting on condition JNI global references: 1517 Heap PSYoungGen total 126336K, used 74112K [0x00007f192d220000, 0x00007f19378c0000, 0x00007f1937cc0000) eden space 82880K, 88% used [0x00007f192d220000,0x00007f19319620d0,0x00007f1932310000) from space 43456K, 2% used [0x00007f1932310000,0x00007f193242e040,0x00007f1934d80000) to space 41728K, 0% used [0x00007f1935000000,0x00007f1935000000,0x00007f19378c0000) PSOldGen total 278464K, used 184803K [0x00007f1917cc0000, 0x00007f1928cb0000, 0x00007f192d220000) object space 278464K, 66% used [0x00007f1917cc0000,0x00007f1923138df8,0x00007f1928cb0000) PSPermGen total 86016K, used 57644K [0x00007f19128c0000, 0x00007f1917cc0000, 0x00007f1917cc0000) object space 86016K, 67% used [0x00007f19128c0000,0x00007f191610b3c8,0x00007f1917cc0000) </code></pre> <p>Here's the aop.xml:</p> <pre><code>&lt;aspectj&gt; &lt;weaver options="-showWeaveInfo -XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler"&gt; &lt;include within="jobprep.domain.question.finite.FiniteStudentSubmissionDeserializer"/&gt; &lt;include within="jobprep.domain.question.openended.OpenEndedQuestion"/&gt; &lt;include within="jobprep.domain.question.openended.OpenEndedResult"/&gt; &lt;include within="jobprep.domain.question.openended.OpenEndedStudentSubmissionDeserializer"/&gt; &lt;include within="jobprep.domain.question.category.CategoryStudentSubmissionDeserializer"/&gt; &lt;include within="jobprep.domain.question.fill.FillInTheBlankStudentSubmissionDeserializer"/&gt; &lt;include within="jobprep.domain.keywords.GroupedKeywords"/&gt; &lt;/weaver&gt; &lt;/aspectj&gt; </code></pre> <p>Here's the maven plugin to get aspectj to work, which I know actually works because it's been working for a really long time:</p> <pre><code> &lt;!-- AspectJ --&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt; &lt;version&gt;1.3&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;goals&gt; &lt;goal&gt;compile&lt;/goal&gt; &lt;goal&gt;test-compile&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;configuration&gt; &lt;complianceLevel&gt;1.6&lt;/complianceLevel&gt; &lt;aspectLibraries&gt; &lt;aspectLibrary&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt; &lt;/aspectLibrary&gt; &lt;/aspectLibraries&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre> <p>Can I get some help with this? What information do I need to give you guys? </p> <p>I am scared to build this project and deploy to the server even though all the tests work in the IDE... because if the Aspects/AOP is locking up in tests, it probably doesn't work if I were to build and package the project using maven.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload