1

We are getting servlet compile errors on Comparator interface after upgrade from Java 1.7 to Java 1.8, using Netbeans and Weblogic 12c. The .jsp files ran fine in Java 1.7. I have read through other similar questions but have not found a solution. I have tried checking the Weblogic Domain configuration JSP Compiler Backwards Compatible with no success. The methods that the compiler is complaining about are default methods so they should not need mentioned, correct? Do the classes implementing Comparator need to be re written for Java 8? If so, please advise.

Errors

 viewFundCites.jsp:151:11: The type compareFundedPrOrderedByPr must implement the inherited abstract method Comparator.thenComparing(Function, Comparator)
    class compareFundedPrOrderedByPr implements Comparator {
          ^-----------------------^

Code

class compareFundedPrOrderedByPr implements Comparator {
    public int compare (Object a, Object b) {
        int ordering = 0;
        FundCite itemA = (FundCite)a;
        FundCite itemB = (FundCite)b;
        if ((null == itemA) && (null == itemB)) {
            ordering = 0;
        } else if ((null == itemA.getPrName()) && (null == itemB.getPrName())) {
            ordering = 0;
        } else if (null == itemA.getPrName()) {
            ordering = -1;
        } else if (null == itemB.getPrName()) {
            ordering = 1;
        } else {
            // Do primary sort by PR Name.
            ordering = itemA.getPrName().compareTo(itemB.getPrName());
            if (0 == ordering) {
                // Do secondary sort by CLIN.
                if ((null == itemA.getClin()) && (null == itemB.getClin())) {
                    ordering = 0;
                } else if (null == itemA.getClin()) {
                    ordering = -1;
                } else if (null == itemB.getClin()) {
                    ordering = 1;
                } else {
                    ordering = itemA.getClin().compareTo(itemB.getClin());
                }
            }
        }
        return ordering;
    }
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
JCover
  • 11
  • 1
  • Does this message appear when your application is build and packaged in NetBeans, or in Weblogic log? – Alexey Jul 06 '16 at 21:45
  • This message appears when trying to run the jsp. There are no errors during build. – JCover Jul 07 '16 at 16:00
  • Then, probably, the following happens: you compile your classes with Java SE 1.8, then you deploy your application to WebLogic, then it tries to compile JSP pages and fails for some reason. Maybe the version of Java SE that is used to run WebLogic is not 1.8? – Alexey Jul 07 '16 at 16:17
  • Netbeans compiles the code using jdk-8u74 and throws no errors. Weblogic uses the same jdk. all other versions of java have been uninstalled. This error is only in .jsp appearing at runtime. – JCover Jul 07 '16 at 16:37
  • I think, Java of an earlier (pre-1.8) version is somehow involved, but I do not know how exactly. If it was not, why would compiler complain about a `default` method. – Alexey Jul 07 '16 at 16:49
  • The code base was developed and compiled using java 1.7. This error is happening as we are trying to upgrade to java 1.8 – JCover Jul 07 '16 at 17:37

0 Answers0