I'm on or-tools 7.4 on the java version, using the cp-sat solver. Invoking CpModel.model() (or any other way to access the underlying proto) throws the below exception.
Adding the protobuf-java 3.9.0 or 3.10.0 dependencies to my build doesn't seem to fix the problem. Any idea what dependency I'm missing here?
java.lang.NoClassDefFoundError: com/google/protobuf/AbstractMessageLite$InternalOneOfEnum
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3172)
at java.base/java.lang.Class.getMethodsRecursive(Class.java:3313)
at java.base/java.lang.Class.getMethod0(Class.java:3299)
at java.base/java.lang.Class.getMethod(Class.java:2112)
at com.google.protobuf.GeneratedMessageV3.getMethodOrDie(GeneratedMessageV3.java:1752)
at com.google.protobuf.GeneratedMessageV3.access$1000(GeneratedMessageV3.java:79)
at com.google.protobuf.GeneratedMessageV3$FieldAccessorTable$RepeatedMessageFieldAccessor.<init>(GeneratedMessageV3.java:2742)
at com.google.protobuf.GeneratedMessageV3$FieldAccessorTable.ensureFieldAccessorsInitialized(GeneratedMessageV3.java:1867)
at com.google.ortools.sat.CpModelProto.internalGetFieldAccessorTable(CpModelProto.java:156)
at com.google.protobuf.GeneratedMessageV3.getAllFieldsMutable(GeneratedMessageV3.java:140)
at com.google.protobuf.GeneratedMessageV3.getAllFields(GeneratedMessageV3.java:216)
at com.google.protobuf.TextFormat$Printer.print(TextFormat.java:293)
at com.google.protobuf.TextFormat$Printer.access$000(TextFormat.java:278)
at com.google.protobuf.TextFormat.print(TextFormat.java:67)
at com.google.protobuf.TextFormat.printToString(TextFormat.java:134)
at com.google.protobuf.AbstractMessage.toString(AbstractMessage.java:111)
at java.base/java.lang.String.valueOf(String.java:3042)
at java.base/java.io.PrintStream.println(PrintStream.java:897)
can you try running the examples ?
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00
Le mar. 10 déc. 2019 à 19:42, Lalith Suresh notifications@github.com a
écrit :
I'm on or-tools 7.4 on the java version, using the cp-sat solver. Invoking
CpModel.model() (or any other way to access the underlying proto) throws
the below exception.Adding the protobuf-java 3.9.0 or 3.10.0 dependencies to my build doesn't
seem to fix the problem. Any idea what dependency I'm missing here?java.lang.NoClassDefFoundError: com/google/protobuf/AbstractMessageLite$InternalOneOfEnum
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3172)
at java.base/java.lang.Class.getMethodsRecursive(Class.java:3313)
at java.base/java.lang.Class.getMethod0(Class.java:3299)
at java.base/java.lang.Class.getMethod(Class.java:2112)
at com.google.protobuf.GeneratedMessageV3.getMethodOrDie(GeneratedMessageV3.java:1752)
at com.google.protobuf.GeneratedMessageV3.access$1000(GeneratedMessageV3.java:79)
at com.google.protobuf.GeneratedMessageV3$FieldAccessorTable$RepeatedMessageFieldAccessor.(GeneratedMessageV3.java:2742)
at com.google.protobuf.GeneratedMessageV3$FieldAccessorTable.ensureFieldAccessorsInitialized(GeneratedMessageV3.java:1867)
at com.google.ortools.sat.CpModelProto.internalGetFieldAccessorTable(CpModelProto.java:156)
at com.google.protobuf.GeneratedMessageV3.getAllFieldsMutable(GeneratedMessageV3.java:140)
at com.google.protobuf.GeneratedMessageV3.getAllFields(GeneratedMessageV3.java:216)
at com.google.protobuf.TextFormat$Printer.print(TextFormat.java:293)
at com.google.protobuf.TextFormat$Printer.access$000(TextFormat.java:278)
at com.google.protobuf.TextFormat.print(TextFormat.java:67)
at com.google.protobuf.TextFormat.printToString(TextFormat.java:134)
at com.google.protobuf.AbstractMessage.toString(AbstractMessage.java:111)
at java.base/java.lang.String.valueOf(String.java:3042)
at java.base/java.io.PrintStream.println(PrintStream.java:897)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/1779?email_source=notifications&email_token=ACUPL3M6PMLSLKS4PAU7EMDQX7PIXA5CNFSM4JZDCST2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H7RMVQQ,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACUPL3LPQ6MRIWP4GRTR2YDQX7PIXANCNFSM4JZDCSTQ
.
Yes. As with my code, works fine as long as I don't call model.model().
For example, I ran this as a test: https://github.com/google/or-tools/blob/stable/ortools/sat/samples/SimpleSatProgram.java
@Test
public void repro() {
// Create the model.
// [START model]
CpModel model = new CpModel();
// [END model]
// Create the variables.
// [START variables]
int numVals = 3;
IntVar x = model.newIntVar(0, numVals - 1, "x");
IntVar y = model.newIntVar(0, numVals - 1, "y");
IntVar z = model.newIntVar(0, numVals - 1, "z");
// [END variables]
// Create the constraints.
// [START constraints]
model.addDifferent(x, y);
// [END constraints]
// Create a solver and solve the model.
// [START solve]
CpSolver solver = new CpSolver();
CpSolverStatus status = solver.solve(model);
// [END solve]
System.out.println(model.model()); // <----- exception thrown here
if (status == CpSolverStatus.FEASIBLE) {
System.out.println("x = " + solver.value(x));
System.out.println("y = " + solver.value(y));
System.out.println("z = " + solver.value(z));
}
}
Java is 64 bit ?
Yes.
$: java -version
openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
Can you try an older version of java ?
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00
Le jeu. 19 déc. 2019 à 22:10, Lalith Suresh notifications@github.com a
écrit :
Yes.
$: java -version
openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/1779?email_source=notifications&email_token=ACUPL3J3GIRUVDWDS64L3UDQZPPKXA5CNFSM4JZDCST2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHLBJHI#issuecomment-567678109,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACUPL3OJBHKWLV3KGBUY52DQZPPKXANCNFSM4JZDCSTQ
.
Found the bug. It had to do with the protobuf version on the classpath. I'm on or-tools 7.5 now, where bumping the version to 3.10.0 from 3.8.0 worked.
Thanks!
Most helpful comment
Found the bug. It had to do with the protobuf version on the classpath. I'm on or-tools 7.5 now, where bumping the version to 3.10.0 from 3.8.0 worked.
Thanks!