2

I already checked other stackoverflow answers but none of them had an answer for JSF facescontext so I had to put a question. We had jdk 6, jsf 1.2 and mySQL 5.5 and now we have upgraded to java 8 and mySQL 5.7. For that, I have replaced mySql-connector jar from 3.1.11 to 5.1.18. But when I start tomcat, it is throwing exception as below:

SEVERE: Exception sending context initialized event to listener instance of class [com.sun.faces.config.ConfigureListener]
java.lang.VerifyError: Inconsistent stackmap frames at branch target 922
Exception Details:
  Location:
    web/clerk/webapp/iucs/officer/bean/OfficerScheduleBean.addOfficerSchedule()Ljava/lang/String; @922: invokestatic
  Reason:
    Type top (current frame, locals[41]) is not assignable to integer (stack map, locals[41])
  Current Frame:
    bci: @904
    flags: { }
    locals: { 'web/clerk/webapp/iucs/officer/bean/OfficerScheduleBean', 'java/lang/String', 'java/io/InputStream', 'java/util/List', 'java/io/BufferedReader', 'javax/servlet/http/HttpSession', 'web/clerk/webapp/iucs/userprofile/pojo/UserProfile', 'java/util/Map', 'java/util/List', 'web/clerk/webapp/iucs/officer/pojo/OfficerSchedule', 'java/lang/String', '[Ljava/lang/String;', integer, integer, 'java/util/Map', 'java/util/Set', integer, integer, 'web/clerk/webapp/iucs/officer/pojo/OfficerSchedule', 'java/util/Iterator', 'java/util/List', 'web/clerk/webapp/iucs/schedule/pojo/CourtType', 'web/clerk/webapp/iucs/schedule/pojo/Location', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'web/clerk/webapp/iucs/general/pojo/County', 'java/lang/String', integer, top, 'web/clerk/webapp/iucs/general/pojo/County', 'web/clerk/webapp/iucs/officer/pojo/OfficerSchedule', integer, integer, integer, integer, integer, integer }
    stack: { 'web/clerk/webapp/iucs/general/pojo/County' }
  Stackmap Frame:
    bci: @922
    flags: { }
    locals: { 'web/clerk/webapp/iucs/officer/bean/OfficerScheduleBean', 'java/lang/String', 'java/io/InputStream', 'java/util/List', 'java/io/BufferedReader', 'javax/servlet/http/HttpSession', 'web/clerk/webapp/iucs/userprofile/pojo/UserProfile', 'java/util/Map', 'java/util/List', 'web/clerk/webapp/iucs/officer/pojo/OfficerSchedule', 'java/lang/String', '[Ljava/lang/String;', integer, integer, 'java/util/Map', 'java/util/Set', integer, integer, 'web/clerk/webapp/iucs/officer/pojo/OfficerSchedule', 'java/util/Iterator', 'java/util/List', 'web/clerk/webapp/iucs/schedule/pojo/CourtType', 'web/clerk/webapp/iucs/schedule/pojo/Location', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'web/clerk/webapp/iucs/general/pojo/County', 'java/lang/String', integer, top, 'web/clerk/webapp/iucs/general/pojo/County', 'web/clerk/webapp/iucs/officer/pojo/OfficerSchedule', integer, integer, integer, integer, integer, integer, top, integer }
    stack: { }
  Bytecode:
    0x0000000: bb00 a559 2ab6 00a7 b600 adb8 00b2 b700
    0x0000010: b813 0720 b600 bcb6 00c0 b800 c312 fb4c
    0x0000020: 2ab6 0722 c600 112a b607 22b9 05c4 0100
    0x0000030: 0994 9a00 2a13 0725 12fb b802 ecbb 00a5
    0x0000040: 592a b600 a7b6 00ad b800 b2b7 00b8 1307.....

Digging up the code, I found what inside erroring method, FacesContext.getCurrentInstance(); code is erroring. When I checked the corresponding jar, it is pointing to jsf-api.jar. Now I know one such solution is to add -noverify argument to VM, But still, that might be a patch looking into my production environment, I can not figure out what is the root cause and what can be the solution?

Aakash Patel
  • 549
  • 5
  • 19
  • Which Java8 version exactly? Tried newer? Why is this a bug in FacesContext.getCurrentInstance() and not a bug in your way of using it? The error is pointing to your class, not to the FacesContext class. – BalusC Nov 01 '18 at 10:42
  • 1
    Do we really still have to say that in 2018? Update every tool, library, or framework which does bytecode processing. Java 6 supported falling back to the old verifier, if verifying stack maps failed; starting with Java 8, there is no such fallback anymore. There has been more than a decade to update. – Holger Nov 01 '18 at 10:55
  • @BalusC We have upgraded to Java 1.8.0181. About faces: Yes, error is showing exception in my method. But I have traced to exact line and came to conclusion and found the exact line of error, which is `FacesContext.getCurrentInstance();` – Aakash Patel Nov 01 '18 at 12:04
  • @Holger I can not upgrade every tool: Actually that is what our initial idea was but, we found that we have to change almost all code lines in order to upgrade jsf from 1.2 to 2.2 which was not possible in deadline given. So now we are only upgrading java and mySQL in backend. – Aakash Patel Nov 01 '18 at 12:06
  • I don’t know whether jsf delegates to another library for the bytecode processing, so you could update only that library. But anyway, you still have to options, 1) stay with Java 6, as it doesn’t matter which outdated Java version you use, or 2) just live with the error. – Holger Nov 01 '18 at 12:26

1 Answers1

1

Found the right argument: Actually I tried adding webdir to environment variable from safe mode, but it dod not work either. So I removed that and added -Xverify:none to tomcat's argument and it started working.

enter image description here

Aakash Patel
  • 549
  • 5
  • 19