Getting Error with Upgrade recipe #1359
Replies: 2 comments 4 replies
-
Hello @robAttrell, and thanks for reaching out! I heard a similar report recently, in fact so similar that I think Geoffrey was just telling me about you. :-) Based on that, I ran the migration scripts on OptaPlanner Quickstarts repository, both on One difference between our two environments seems to be the operating system - I am on MacOS, you are on Windows. Unfortunately, I do not have a Windows machine handy to try to reproduce this. Another difference could be a version of Java we're using. I'm on Unfortunately, the exception message is also telling me the problem is probably not on Timefold's side - I do not see how a well-written recipe which works on 1 platform could trigger this issue inside OpenRewrite. With all of that said, I'm afraid I don't have any recommendations for you - I can't even reproduce your problem. :-( Maybe asking the folks at OpenRewrite could help? Perhaps they've seen this error before and would be able to provide additional clues. Perhaps @timtebeek would have an idea? |
Beta Was this translation helpful? Give feedback.
-
I believe your classpath is messed up. Looks like you might have two openrewrite classes coming from different openrewrite versions in play. Normally I would recommend to run
|
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to update my OptaPlanner codebase to Timefold to try it out, but running into an issue with the upgrade recipe. I don't really know much about this process, but it's supposed to be quite straightfoward, and it's very possible I'm missing a very simple step that just isn't documented.
First, I ran the recipe on my existing codebase (with Maven), which has all the examples I'm not using stripped out (I'm using meeting scheduling as the basis for my optimization). This gave an error when it was running the recipe (I'll document the full text of the error I am getting later). I thought it might be because I was running it on a stripped-down version of the full codebase, so I downloaded a clean version from the OptaPlanner website and extracted the files, and ran the upgrade recipe command again.
The upgrade still didn't work, failing at the same point. Next, I did some reading on the error I had been getting, and it indicated that if I was using PowerShell instead of the command line, I should escape the command arguments with ticks (`), so I did that and ran it again with the escaped command but that still didn't work. Next, I tried running the recipe on the same clean build but just using the command prompt, but I was still getting an error, which I will post below:
[INFO] Running recipe(s)... [ERROR] The recipe produced an error. Please report this to the recipe author. [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:18 min [INFO] Finished at: 2025-01-27T09:45:53-05:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:6.0.0:run (default-cli) on project optaplanner-examples: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:6.0.0:run failed: Error while visiting src\main\java\ai\timefold\solver\examples\common\persistence\AbstractXlsxSolutionFileIO.java: java.lang.ClassCastException: class org.openrewrite.java.tree.J$MemberReference cannot be cast to class org.openrewrite.java.tree.J$MethodInvocation (org.openrewrite.java.tree.J$MemberReference and org.openrewrite.java.tree.J$MethodInvocation are in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @272013a1) [ERROR] ai.timefold.solver.migration.v8.ConstraintRefRecipe$1.visitExpression(ConstraintRefRecipe.java:61) [ERROR] ai.timefold.solver.migration.v8.ConstraintRefRecipe$1.visitExpression(ConstraintRefRecipe.java:50) [ERROR] org.openrewrite.java.JavaVisitor.visitMemberReference(JavaVisitor.java:818) [ERROR] org.openrewrite.java.JavaIsoVisitor.visitMemberReference(JavaIsoVisitor.java:219) [ERROR] org.openrewrite.java.JavaIsoVisitor.visitMemberReference(JavaIsoVisitor.java:30) [ERROR] org.openrewrite.java.tree.J$MemberReference.acceptJava(J.java:3476) [ERROR] org.openrewrite.java.tree.J.accept(J.java:59) [ERROR] org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250) [ERROR] org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320) [ERROR] org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1367) [ERROR] org.openrewrite.java.JavaVisitor.lambda$visitContainer$35(JavaVisitor.java:1417) [ERROR] org.openrewrite.internal.ListUtils.map(ListUtils.java:243) [ERROR] org.openrewrite.internal.ListUtils.map(ListUtils.java:265) [ERROR] org.openrewrite.java.JavaVisitor.visitContainer(JavaVisitor.java:1417) [ERROR] org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:914) [ERROR] org.openrewrite.java.JavaIsoVisitor.visitMethodInvocation(JavaIsoVisitor.java:229) [ERROR] ... [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Happy to take any advice on getting this to run.
Beta Was this translation helpful? Give feedback.
All reactions