Hi there, I'm trying to do a retrieve on an object with java because I am building a string dynamically at runtime to use as a path. I've used the retrieveByPath function to return a list of the objects I want to retrieve. I couldn't find a lot of clear documentation on this so I might be making a mistake in my code. Either its the code or the path. CODE : public class Java_RetrievePRUsByXPath extends UserAction<java.util.List<IMendixObject>> { private String XPath; private IMendixObject __InputPRU; private jobs.proxies.PropertyRentableUnit InputPRU; public Java_RetrievePRUsByXPath(String XPath, IMendixObject InputPRU) { super(); this.XPath = XPath; this.__InputPRU = InputPRU; } @Override public java.util.List<IMendixObject> executeAction() throws Exception { this.InputPRU = __InputPRU == null ? null : jobs.proxies.PropertyRentableUnit.initialize(getContext(), __InputPRU); // BEGIN USER CODE List<IMendixObject> list = Core.retrieveByPath(this.getContext(), __InputPRU, XPath); return list; // END USER CODE } STACKTRACE: An error has occurred while handling the request. [User 'Anonymous_c9c5d48d-63f0-4f7f-9e63-7588fd1494ba' with roles 'AnonymousUser'] la: com.mendix.core.CoreRuntimeException: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: requirement failed: path '[Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_PropertyType/Jobs.PropertyType/PropertyTypeID=2][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_Region/Jobs.Region/RegionID=4][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_SubRegion/Jobs.SubRegion/SubRegionID=3]' does not refer to a valid association at {} at Reports.IVK_Vacancy_Search (JavaAction : 'Call 'Java_RetrievePRUsByXPath'') Advanced stacktrace: at mg.a(SourceFile:188) Caused by: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: requirement failed: path '[Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_PropertyType/Jobs.PropertyType/PropertyTypeID=2][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_Region/Jobs.Region/RegionID=4][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_SubRegion/Jobs.SubRegion/SubRegionID=3]' does not refer to a valid association at com.mendix.core.Core.execute(SourceFile:225) Caused by: com.mendix.core.CoreRuntimeException: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: requirement failed: path '[Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_PropertyType/Jobs.PropertyType/PropertyTypeID=2][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_Region/Jobs.Region/RegionID=4][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_SubRegion/Jobs.SubRegion/SubRegionID=3]' does not refer to a valid association at hC.b(SourceFile:194) Caused by: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: requirement failed: path '[Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_PropertyType/Jobs.PropertyType/PropertyTypeID=2][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_Region/Jobs.Region/RegionID=4][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_SubRegion/Jobs.SubRegion/SubRegionID=3]' does not refer to a valid association at hC.b(SourceFile:194) Caused by: java.lang.IllegalArgumentException: requirement failed: path '[Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_PropertyType/Jobs.PropertyType/PropertyTypeID=2][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_Region/Jobs.Region/RegionID=4][Jobs.PropertyRentableUnit_Property/Jobs.Property/Jobs.Property_SubRegion/Jobs.SubRegion/SubRegionID=3]' does not refer to a valid association at scala.Predef$.require(Predef.scala:214) at hm.a(SourceFile:23) at hm.executeAction(SourceFile:15) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:183) at com.mendix.core.Core.retrieveByPath(SourceFile:985) at javaactionsredefine.actions.Java_RetrievePRUsByXPath.executeAction(Java_RetrievePRUsByXPath.java:39) at javaactionsredefine.actions.Java_RetrievePRUsByXPath.executeAction(Java_RetrievePRUsByXPath.java:1) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:183) at com.mendix.core.Core.execute(SourceFile:219) at lh.a(SourceFile:69) at mg.a(SourceFile:73) at mf.executeAction(SourceFile:101) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:183) at com.mendix.core.Core.execute(SourceFile:219) at gm.execute(SourceFile:186) at iW.a(SourceFile:304) at com.mendix.externalinterface.connector.RequestDispatching$Worker.a(SourceFile:141) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.a(SourceFile:133) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.apply(SourceFile:131) at akka.actor.Actor$class.apply(Actor.scala:545) at com.mendix.externalinterface.connector.RequestDispatching$Worker.apply(SourceFile:127) at akka.actor.LocalActorRef.invoke(ActorRef.scala:910) at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25) at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:223) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:123) at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:195) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:123) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:192)
asked
Alistair Crawford
3 answers
2
The problem here is that you're using retrieve by path which allows you to retrieve objects over associations, but are actually adding an xpath-like constraint in the end.
I think you are really looking to use xpath (including //Module.Entity) and not the retrieve by path functionality. Judging by your java action name and parameters this is what you intended to do anyway. Core.retrieveByPath is not xpath. Also see the javadoc belonging to retrieveByPath here
answered
Sebastiaan van den Broek
1
Did you try pasting the path in the modeler?
'[Jobs.PropertyRentableUnitProperty/Jobs.Property/Jobs.PropertyPropertyType/Jobs.PropertyType/PropertyTypeID=2][Jobs.PropertyRentableUnitProperty/Jobs.Property/Jobs.PropertyRegion/Jobs.Region/RegionID=4][Jobs.PropertyRentableUnitProperty/Jobs.Property/Jobs.PropertySubRegion/Jobs.SubRegion/SubRegionID=3]' does not refer to a valid association
answered
Bart Tolen
0
The community commons library has a query builder.