Search code examples
javaeclipseintellij-ideacharsequence

Project works in Eclipse but when imported into IntelliJ IDEA I get the JasperException re: CharSequence


I have been handed an application which is almost 10 years old, for maintenance. A customer (internal) has a requirement change. The app was built and maintained in Eclipse to this point. I need to import it into IntelliJ (the current company "standard") to implement the requirements change.

The app is running on a Websphere server in production, so the local debug environment is Jetty in the project which allows developers to open the app for debugging using localhost:(portNumber). The application will run and debug using Eclipse - I've taken the time to verify this. When I attempt to run or debug it (exact same code on the local harddrive) using IntelliJ, the application will start up, but as soon as I hit a certain JSP and it attempts to load an included JSP, I get the following error message (formatted for legibility):

org.apache.jasper.JasperException: Unable to compile class for JSP||
An error occurred at line: 6 in the jsp file: 
/lookupFiles/myCodes.jsp|Generated servlet error:|
The type java.lang.CharSequence cannot be resolved. 
It is indirectly referenced from required .class files||

I have done the code searches that I can think to do, and I don't have CharSequence anywhere in the application. I have been through the Google searches and numerous recommended solutions (most of which say to roll back from Java version 8 to 7). I am using JDK 1.8.0 build 102 with my environment set to source compatibility for Java 6 (what's on the server). So, I don't think the default methods are the issue.

Here is the code in the included file (line 6 is the opening JSP tag):

<jsp:useBean class="commands.CommandReciever" id="receiver"></jsp:useBean>
<%@page import="my.json.JSONObject,my.json.HTTP"%>
<%@page import="org.json.JSONArray" %>
<%@page import="commands.AjaxCommand" %> 

<%
JSONObject obj = HTTP.toJSONObject(request);
obj.put("operation","select");
obj.put("index",3);
obj.put("tableNumber",100);

AjaxCommand command = new AjaxCommand("username", obj);

receiver.executeCommandSQL(command);
JSONArray jArray = command.getResults();
String keyCodes = "";
String keyValues = "";
  if(jArray.length() > 0){
    int ctr = 0;
    out.println("<option value=\"\"> - </option>");      
    while(ctr < jArray.length()){
        obj = (JSONObject)jArray.getJSONObject(ctr);
        keyCodes =  obj.optString("KEY_ID");
        keyValues = obj.optString("LONG1_TX");
        out.println("<option value=\"" + keyCodes.substring(1) + "\">" + keyCodes + " - " + keyValues + "</option>");
        ctr++;
    }
  }
%>

I have checked the dependencies, the local classes which are imported don't implement any of the CharSequence implementation classes.

Finally, I know there are a lot of things which can be done to make this code "better" but I'm not needing that, I just need to figure out what is causing this JasperException and get past it so I can get the application to debug in IntelliJ.


Solution

  • I have moved past this problem and I want to post the solution that worked for me in CLEAR TERMS. It seems that the other solutions may have been correct, but not CLEAR. There is a bit of explanation, but the final fix is at the end.

    I was developing on JDK1.8.0 bld 102 and setting the application configuration to fall back to build against Java 1.6 standards. I had installed JRE 1.6, JRE 1.7, and JRE 1.8 on my machine. I attempted to run my code against JRE 1.6, as the server is running Java 6, but this didn't help. IntelliJ IDEA was still BUILDING against and using the JVM from JDK1.8. I downloaded JDK1.7 and installed it alongside my JDK1.8 install and reconfigured IntelliJ to use the JDK1.7 for builds AND running the app locally. This fixed my issue.

    So, the final fix was to set my Gradle JVM to use JDK1.7.0_80 rather than JDK1.8.0_102 - the IntelliJ IDEA Project SDK is still set to 1.8.