Java App Does Not Load Data from PostgreSQL -
my java app works fine locally, when have deployed on ec2 instance (ubuntu 14, tomcat 8, postgresql 9.3), getting following error (see below). back-end written developer no longer part of team. basically, needs display data once value chosen dropdown menu.
i've been google-ing issue crazy have found no solution. thinking may related jdbc:postgresql://localhost:5432/dbname
. tried inserting actual ip instead of localhost
still no luck. me, seems issue connecting database rather code. mentioned, running fine locally on computer.
any guidance appreciated not java expert. help.
the full error log below:
java.lang.nullpointerexception com.app.data.connectionpool.freeconnection(connectionpool.java:52) com.app.data.appdb.getdata(appdb.java:155) com.app.servlets.getappservlet.processrequest(getappservlet.java:42) com.app.servlets.getappservlet.doget(getappservlet.java:67) javax.servlet.http.httpservlet.service(httpservlet.java:622) javax.servlet.http.httpservlet.service(httpservlet.java:729) org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:607) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:315) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ java.lang.thread.run(thread.java:745)
based on little have provided, best guess connection.close()
method mention being called in finally
block there isn't check see whether connection
null
.
i imagine code looks following:
connection connection = null; try { connection = getdatabaseconnectionsomehow(...); // stuff database } { connectionpool.freeconnection(connection); }
if calll getdatabaseconnectionsomehow(...)
throws exception, connection
null
when finally
block entered. code presented above doesn't check see whether connection
null
, , if freeconnection
method fails check whether connection null
before closing it, nullpointerexception.
an exception thrown within finally
block replace exception thrown within corresponding try
block. in case, don't see real exception getting database connection because nullpointerexception gets in way.
hopefully, adding suitable null-check should figure out real problem here.
Comments
Post a Comment