SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-356
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Shay Banon
Reporter: Ismael Juma
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Compass

IllegalArgumentException when using @SearchableComponent with root = false, cascade and toplink-essentials.

Created: 14/Jan/07 07:35 PM   Updated: 15/Jan/07 05:48 AM
Component/s: None
Affects Version/s: 1.1 M3
Fix Version/s: 1.1 RC1

Environment: JDK6, Linux, toplink-essentials.


 Description  « Hide
I am not sure if this is a Compass bug, but the following seems a bit suspicious. So, feel free to close this if I am off-track. I am seeing an IllegalArgumentException when using cascade annotations in @SearchableComponent where the component itself has the root = false. It works fine, if root = true.

A description of the problem follows. TopLinkEssentialsJpaEntityLifeCycleInjector has the following line (117):

if (gps.hasMappingForEntityForMirror(mappedClass, CascadeMapping.Cascade.ALL))

In other words, it passes Cascade.ALL that will always result in an exception unless the entity has root = false. The reason is that AbstractRefAliasMapping#shouldCascade has the following:

public boolean shouldCascade(Cascade cascade) {
if (cascades == null) { return false; }
if (cascade == Cascade.CREATE) { return shouldCascadeCreate(); } else if (cascade == Cascade.SAVE) { return shouldCascadeSave(); } else if (cascade == Cascade.DELETE) { return shouldCascadeDelete(); } else { throw new IllegalArgumentException("Should cascade can't handle [" + cascade + "]"); }
}

So, it cannot handle Cascade.ALL, but that's what TopLinkEssentialsJpaEntityLifeCycleInjector has passed. (Note that it doesn't matter what cascades I define for the @SearchableComponent. As long as there is a single cascade, this will happen).

The stack trace follows:

exception is java.lang.IllegalArgumentException: Should cascade can't handle [ALL]
Caused by: java.lang.IllegalArgumentException: Should cascade can't handle [ALL]
at org.compass.core.mapping.osem.AbstractRefAliasMapping.shouldCascade(AbstractRefAliasMapping.java:188)
at org.compass.core.mapping.AbstractResourceMapping.operationAllowed(AbstractResourceMapping.java:205)
at org.compass.gps.impl.AbstractCompassGps.hasMappingForEntity(AbstractCompassGps.java:86)
at org.compass.gps.impl.SingleCompassGps.hasMappingForEntityForMirror(SingleCompassGps.java:172)
at org.compass.gps.device.jpa.lifecycle.TopLinkEssentialsJpaEntityLifecycleInjector.injectLifecycle(TopLinkEssentialsJpaEntityLifecycleInjector.java:117)
at org.compass.gps.device.jpa.JpaGpsDevice.doStart(JpaGpsDevice.java:170)
at org.compass.gps.device.AbstractGpsDevice.start(AbstractGpsDevice.java:124)
at org.compass.gps.device.support.parallel.AbstractParallelGpsDevice.start(AbstractParallelGpsDevice.java:66)
at org.compass.gps.device.AbstractGpsDeviceWrapper.start(AbstractGpsDeviceWrapper.java:64)
at org.compass.gps.impl.AbstractCompassGps.start(AbstractCompassGps.java:164)
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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:273)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
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.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:214)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 15/Jan/07 02:06 AM
Yep. What I mean for was when passing ALL, if the cascading mappings has ANY mappings, than it will mean that the operation is allowed. I fixed it, can you give it a go?

Ismael Juma added a comment - 15/Jan/07 05:37 AM
Makes sense. This works now. Thanks.