Skip navigation

[CF8] java.lang.NullPointerException

Oct 2, 2007 6:13 AM

  Latest reply: Ultimatorx, Feb 1, 2012 10:13 AM
Replies 1 2 3 Previous Next
  • Currently Being Moderated
    15. ,
    Apr 9, 2008 12:06 AM   in reply to FastmusicJimmy
    Hi,

    It would be great if you could post the sample code and provide us with the details about the environment setup, so that we can try reproducing the issue, since it happens to be an inconsistent issue.

    Thanks,
    Hareni
    Adobe CF Team
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2008 8:42 AM   in reply to yogonaise
    Hi Hareni,

    I believe I finally found a solution. In my advanced settings for the datasource I turn "Maintain connections across client requests" off and it seems to work.

    My code is very similar to the code posted in this thread and my error is the same as well. If it will help I'm on CF Standard 8,0,0,176276. Changed the JVM to 1.5.0_15 for faster object creation. Using MySQL 5.0.22.

    On the server where my code was working without DB errors I'm using CF Developer 8,0,0,176276 , MySQL 5.0.51a-community-nt and the same JVM.

    Thanks,

    Jimmy
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2008 9:59 AM   in reply to yogonaise
    @Jimmy - I would consider that a temporary workaround, but not a solution. With "Maintain connections" unchecked, CF is now creating a new connection with each query. You can imagine the performance degradation on high-traffic sites that will result. The fact that the error manifests after a lull in activity, and that unchecking "Maintain connections" fixes it, would point to a bug in CF's connection pool handling for MySQL.

    @Hareni - We are seeing the error in both CF 8 and CF 8.0.1, on both Windows XP and Mac OSX Leopard. We're connecting to MySQL 5.0.22. It could happen on any query, so I don't really have a code sample for you. But it always happens after a pause in activity - if I hit reload over and over, it won't happen, but if I step away for 10 minutes and come back, it probably will.

    My datasource settings are all the default settings for MySQL. I tried setting Connection String to autoReconnect=true&autoReconnectForPools=true, but that does not help.
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2008 1:33 PM   in reply to rich.thibault
    I may be on to something. I extracted the MySQL driver c:\coldfusion8\lib\mysql-connector-java-commercial-5.0.5-bin.jar and opened the file Statement.class using a decompiler. The constructor looks like this:

    public Statement(com.mysql.jdbc.Connection c, String catalog) throws SQLException
    {
    cancelTimeoutMutex = new Object();
    wasCancelled = false;
    charConverter = null;
    charEncoding = null;
    connection = null;
    connectionId = 0L;
    currentCatalog = null;
    doEscapeProcessing = true;
    eventSink = null;
    fetchSize = 0;
    isClosed = false;
    lastInsertId = -1L;
    maxFieldSize = MysqlIO.getMaxBuf();
    maxRows = -1;
    maxRowsChanged = false;
    openResults = new ArrayList();
    pedantic = false;
    profileSQL = false;
    results = null;
    resultSetConcurrency = 0;
    resultSetType = 0;
    timeoutInMillis = 0;
    updateCount = -1L;
    useUsageAdvisor = false;
    warningChain = null;
    holdResultsOpenOverClose = false;
    batchedGeneratedKeys = null;
    retrieveGeneratedKeys = false;
    continueBatchOnError = false;
    if(c == null || c.isClosed())
    throw SQLError.createSQLException(Messages.getString("Statement.0"), "08003");
    connection = c;
    connectionId = connection.getId();
    currentCatalog = catalog;
    pedantic = connection.getPedantic();
    continueBatchOnError = connection.getContinueBatchOnError();
    if(!connection.getDontTrackOpenResources())
    connection.registerStatement(this);
    if(connection != null)
    {
    maxFieldSize = connection.getMaxAllowedPacket();
    int defaultFetchSize = connection.getDefaultFetchSize();
    if(defaultFetchSize != 0)
    setFetchSize(defaultFetchSize);
    }
    if(connection.getUseUnicode())
    {
    charEncoding = connection.getEncoding();
    charConverter = connection.getCharsetConverter(charEncoding);
    }
    boolean profiling = connection.getProfileSql() || connection.getUseUsageAdvisor();
    if(connection.getAutoGenerateTestcaseScript() || profiling)
    statementId = statementCounter++;
    if(profiling)
    {
    pointOfOrigin = new Throwable();
    profileSQL = connection.getProfileSql();
    useUsageAdvisor = connection.getUseUsageAdvisor();
    eventSink = ProfileEventSink.getInstance(connection);
    }
    int maxRowsConn = connection.getMaxRows();
    if(maxRowsConn != -1)
    setMaxRows(maxRowsConn);
    0
    }

    There appears to be an extraneous 0 at the end.


     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2008 2:21 PM   in reply to yogonaise
    Hey BKBK,

    I think that's an artifact from your decompiler - MySQL source code doesn't have that 0, and it would prevent compiling anyway:

    http://svn.mysql.com/svnpublic/connector-j/tags/5.0.5/connector-j/src/ com/mysql/jdbc/Statement.java

    But your post got me looking at their source code. The NPE happens at line 2178, which I believe is this line inside setMaxRows():

    this.connection.unsetMaxRows(this);

    So it looks like CF is invoking setMaxRows() after the connection has already gone dead (null). It should be detecting the dead connection, removing it from the pool, and starting a new one.
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2008 9:02 PM   in reply to yogonaise
    rich.thibault wrote:
    I think that's an artifact from your decompiler

    You are right about the decompiler error. It has been confirmed on the same decompiler, but not on two others.(Thanks, Jack).

    ...MySQL source code doesn't have that 0, and it would prevent compiling anyway:
    I was thinking more of a bug in the binary, Statement.class, in the Coldfusion lib package. I expect the constructor to handle the case where the connection is null.

    P.S.: I have received four reactions (three in an hour!) repeating your point about the MySQL source code. To clarify, I thought of a bug in Coldfusion's jar because no other MySQL users are reporting the error. It's as simple as that.








     
    |
    Mark as:
  • Currently Being Moderated
    May 24, 2008 11:29 PM   in reply to yogonaise
    Any news on this bug?

    Maybe it's in the mysql 5 version or mysql 5 settings. I have 5.0.45-community-nt in production which has the errors and 5.0.51a-3buntu5 in development.

    I found the following differences between the mysql servers (mysql administrator->startup params->advanc network or Mysql administrator->health-server variables->connection)
    Dev box (working):
    Interactive timeout: 28800
    Wait timeout: 28800
    Production (not working):
    Interactive timeout: 30
    Wait timeout: 15
     
    |
    Mark as:
  • Currently Being Moderated
    May 25, 2008 12:41 AM   in reply to yogonaise
    Ok, I'm able to reproduce consistently on my devbox. The culprit is the wait timeout. If I set it to 15 seconds I get the error if I wait more then 15 seconds between request. If I set it to something like 21 seconds I get the error precisely after waiting more the 21 seconds between requests.

    The default coldfusion timeout is 1200 seconds. So the solution is to set the mysql wait timeout to something >1200.

    You can change it via the mysql administrator->startup parameters (select mysqld if asked)->tab advanced networking.
     
    |
    Mark as:
  • Currently Being Moderated
    May 27, 2008 2:56 PM   in reply to ChillyWillyReal
    Thanks ChillyWilly,

    Unfortunately that fix didn't work for us....our servers are already using 28800, but we still get the error.

    rich
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 17, 2008 10:08 PM   in reply to rich.thibault
    Anyone have any insights into this? I am using dailyrazor as my host and am getting the error, exactly as described. Once in a while..refresh works fine...

    java.lang.NullPointerException
    at com.mysql.jdbc.Statement.setMaxRows(Statement.java:2178)
    at coldfusion.server.j2ee.sql.JRunStatement.setMaxRows(JRunStatement.jav a:214)
    at coldfusion.sql.Executive.executeQuery(Executive.java:1276)
    at coldfusion.sql.Executive.executeQuery(Executive.java:1008)
    at coldfusion.sql.Executive.executeQuery(Executive.java:939)
    at coldfusion.sql.SqlImpl.execute(SqlImpl.java:325)
    at coldfusion.tagext.sql.QueryTag.executeQuery(QueryTag.java:831)
    at coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:521)
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2008 4:25 AM   in reply to yogonaise
    In the settings page in the Coldfusion Administrator for that particular datasource, choose to Show Advanced Settings. In the Connection String field, enter: autoReconnectForPools=true

    Press Submit to register the change. Does it solve the problem?


     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2008 7:26 AM   in reply to yogonaise
    I already had something in the connection string, so I tried to add another, with a semi-colon in between and am getting:

    zeroDateTimeBehavior=convertToNull;autoReconnectForPools=true

    Warning: gyro4_content: java.sql.SQLException: The connection property 'zeroDateTimeBehavior' only accepts values of the form: 'exception', 'round' or 'convertToNull'. The value 'convertToNull;autoReconnectForPools=true' is not in this set.

    Is a semi-colon not the value for multiple entries?

    If I uncheck this value, it 'solves' the problem, but I was reading about the possible performance issues with it:

    "Maintain connections across client requests"

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2008 7:35 AM   in reply to yogonaise
    zeroDateTimeBehavior='convertToNull';autoReconnectForPools=true
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2008 7:36 AM   in reply to yogonaise
    Oh, and ensure "Maintain connections across client requests" is checked.


     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2008 10:08 AM   in reply to yogonaise
    The Plesk control panel still doesn't like that:

    zeroDateTimeBehavior='convertToNull';autoReconnectForPools=true

    Warning: gyro4_content: java.sql.SQLException: The connection property 'zeroDateTimeBehavior' only accepts values of the form: 'exception', 'round' or 'convertToNull'. The value ''convertToNull';autoReconnectForPools=true' is not in this set.

    I'll have to check into whats different about plesk.
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2008 10:43 AM   in reply to yogonaise
    try zeroDateTimeBehavior=convertToNull&autoReconnectForPools=true ?

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2008 10:52 AM   in reply to dennis longnecker
    Try an ampersand....I believe these are like URL params:

    zeroDateTimeBehavior=convertToNull&autoReconnectForPools=true
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2008 7:01 AM   in reply to yogonaise
    .. if it still complains, then slap it with

    autoReconnectForPools=true;zeroDateTimeBehavior=convertToNull
    or
    autoReconnectForPools=true&zeroDateTimeBehavior=convertToNull
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2008 7:26 AM   in reply to yogonaise
    DOesn't accept the first format..same error message as before. When I try the second one, my code bombs because of the null date issue, so it is not converting it to null.
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2008 10:03 AM   in reply to yogonaise
    Do you mean that

    zeroDateTimeBehavior=convertToNull

    and

    autoReconnectForPools=true

    work, but

    autoReconnectForPools=true&zeroDateTimeBehavior=convertToNull

    fails?


     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2008 10:17 AM   in reply to yogonaise
    zeroDateTimeBehavior=convertToNull fixes a error with zerodate's, but I have the connection issue.

    autoReconnectForPools=true fixes the connection problem, but I have the zerodate issue.

    autoReconnectForPools=true&zeroDateTimeBehavior=convertToNull I have both the connection isse and the zerodate problem. Its like its not doing either...but then it doesn't complain about it as a value either.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2008 1:28 AM   in reply to yogonaise
    Quite odd. What if you apply no connection string in the administrator, but do the following instead.

    Open the file {CF_installation_dir}/lib/neo-datasource.xml in a text editor. (Make a back-up). Locate the URL(s) which correspond to the datasources to which you want to apply the connection string.

    Suppose one such URL is

    jdbc:mysql://127.0.0.1:3306/my_orders?

    Modify the line to

    jdbc:mysql://127.0.0.1:3306/my_orders?autoReconnectForPools=true&zeroD ateTimeBehavior=convertToNull

    Restart Coldfusion.


     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2008 8:10 AM   in reply to dennis longnecker
    Previously, I was using ColdFusion 6.1 and I'm sure an older version of mySQL. I transferred hosting to dailyrazor with ColdFusion 8 as my host and am getting the error:

    quote:

    The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.

    Null Pointers are another name for undefined values.
    500

    ROOT CAUSE:
    java.lang.NullPointerException



    When I refresh the page the error goes away for a while. Then it comes back after a while. It happens on all sorts of pages and it never happened before I migrated the site to the new host.

    quote:

    Originally posted by: dennis longnecker
    Anyone have any insights into this? I am using dailyrazor as my host and am getting the error, exactly as described. Once in a while..refresh works fine...

    java.lang.NullPointerException
    at com.mysql.jdbc.Statement.setMaxRows(Statement.java:2178)
    at coldfusion.server.j2ee.sql.JRunStatement.setMaxRows(JRunStatement.jav a:214)
    at coldfusion.sql.Executive.executeQuery(Executive.java:1276)
    at coldfusion.sql.Executive.executeQuery(Executive.java:1008)
    at coldfusion.sql.Executive.executeQuery(Executive.java:939)
    at coldfusion.sql.SqlImpl.execute(SqlImpl.java:325)
    at coldfusion.tagext.sql.QueryTag.executeQuery(QueryTag.java:831)
    at coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:521)



     
    |
    Mark as:
  • Currently Being Moderated
    Jun 28, 2008 11:06 AM   in reply to drjamiii
    We are experiencing the same issue on Crystaltech shared ColdFusion hosting. From reviews of the Crystaltech forum, this issue seems to have cropped up since the upgrade to CF8.1? This is a serious issue. It is crippling for sites with heavy data input capabilities, because the error forces the user to re-enter all the information from the submitting page. I've created a workaround cftry/cfcatch, but this only works effectively for display pages. Any form submission page which generates the error loses all the form data. Unacceptable.

    Adobe? Hello? Help us out here.
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 17, 2008 12:25 PM   in reply to Max_Donnelly
    I am having this same error
    =================================
    java.lang.NullPointerException at com.mysql.jdbc.Statement.setMaxRows(Statement.java:2178) at coldfusion.server.j2ee.sql.JRunStatement.setMaxRows(JRunStatement.jav a:214) at... etc... etc..
    =================================

    Is there any help on this topic? Adobe? Please?
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 11, 2008 6:15 AM   in reply to Fusecast
    We are having the same issues in our shop. We are running CF 8 on Solaris using Oracle as the database. The error and the inconsistency of the error is exactly how you describe. It started happening immediately after the upgrade.

    Has Adobe provided any guidance on this yet?
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 8, 2008 6:23 PM   in reply to dennis longnecker
    i have the same problem on a daily razor server. every now and then it throws a 500 error for no reason. saying there is a problem with either some system code or programming code.

    then when i refresh its fine :S
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2008 8:34 AM   in reply to Joshua_Russell
    Hey all,

    The only way I found to solve this problem thus far was to go into the Data Source Menu in the CF Admin and UNCHECK the "Maintain Connections" check box (in the Advanced settings). I know it is said this may cause other issues but I have not see any since I made the change to several virtual host account DSN's. So far it's worked great for me. You'll be the better judge in each of your different circumstances. I hope this helps cause nothing else I've tried to this point has.
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2008 10:10 AM   in reply to yogonaise
    Same problem for us - detailed description is at (created before I found this thread):

    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1 &catid=7&threadid=1391203&highlight_key=y&keyword1=jdbc%2EStatement%2E setMaxRows

    Unchecking "maintain connections" is not a viable solution for us. We have a very heavy database environment.

    Does anyone else have a solution?

    Has anyone with a support contract reported it to Adobe? What's their answer.
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2008 11:55 AM   in reply to yogonaise
    I completely understand the frustration. It is a pain and to date I have yet to see a fix or any real help. This issue and an alternative to Dreamweaver (that's not CFEclipse) is what I have been asking Adobe to help CF developers out with for some time. I miss Homesite. ;)
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2008 12:36 PM   in reply to yogonaise
    Let's follow another strategy. Run the following query on the MySQL database

    show variables;

    What value do you get for wait_timeout and for interactive_timeout ? Each has a default value of 28800, that is, 8 hours, converted into seconds.

    Is either of the values much lower for your MySQL server? If so, increase it or have it increased. You can do so, for example, by adding the line

    wait_timeout=28800

    or the line

    interactive_timeout=28800

    or both to the [mysqld] section of the my.ini configuration file. Restart the MySQL server for the changes to take effect.



     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2008 12:53 PM   in reply to BKBK
    quote:

    What value do you get for wait_timeout and for interactive_timeout ? Each has a default value of 28800, that is, 8 hours, converted into seconds.




    This is a new server using Red Hat, default installation and values - both wait_timeout and internactive_timeout are 100 (not 28800). I'll change these values and do some testing and report back.
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2008 1:46 PM   in reply to yogonaise

    Maybe Helm uses a newer and|or better driver then ships with ColdFusion!
    Since, while Adobe provides the drivers, they do not write them. Other
    companies write the drivers. (P.S. this is a large reason for the price
    difference between standard and enterprise ColdFusion, the licensee fees
    paid by Adobe to Oracle for the native Oracle driver included in
    Enterprise)

    Adobe nee Macromedia nee Alaire provide documentation on how to
    update|change database drivers anytime it is desirable to do so.
    Especially since a stable ColdFusion server can easily live much longer
    then the lifespan of a driver version.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2008 2:54 PM   in reply to Newsgroup_User
    quote:

    Originally posted by: Newsgroup User

    Since, while Adobe provides the drivers, they do not write them. Other
    companies write the drivers.



    Newsgroup User - Do you work for Adobe? Hope not, as I hope this is not a common view point with them.

    --- Rant mode ON ----
    Adobe charges $7,500 for this product to run on a single server and says it works with MySQL 4 or 5. We make purchasing decisions based on these claims. We don't care if they write the DB driver or acquire it. It needs to work as advertised and as it did on prior CF releases. The view that "if MySQL access does not work, you can try and find drivers yourself" is B.S. The number of people that have reported this problem and the length of time without Adobe comment/help or intervention is shameful.

    We had planned to open an incident ($500) with Adobe to get a resolution to this but getting a "not our problem - we did not write the driver" response is not something I care to drop $500 on.

    We have 3 licenses of CF Enterprise we have to decide on for a customer in 17 days. Looks like our response will be to not use CF for this client and save the $22,500 . Unfortunately we have quite a few other clients that it will be tougher to migrate off CF.
    --- Rant mode OFF ----

    BKBK - thanks for the suggestion. We will try that and if it works, or not, will report back.
     
    |
    Mark as:
Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points