Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

Nullpointer exception when posting a form due to unconnected datasourceManager

The "WCB: Java development" forum contains threads on issues that are related to Java while programming a WCB (WebManager Component Bundle). If you have questions that have impact on Java code, post them in this forum. Some example topics: authorization, the different component types, setting up component dependencies, data access, and so forth.

Answered
Not marked as answered yet

Forums  >  WCB: Java development  >  Nullpointer exception when posting a form due to unconnected datasourceManager


Author Nullpointer exception when posting a form due to unconnected datasourceManager
rong


Posts: 2

Posted: 03-06-2010 10:40


I get a Nullpointer exception on posting a form with a formdefinition that is defined in a jsp-file.
This Nullpointer exception is caused by due to a not set myDatasourceManager.

The error shown in the log is:

java.lang.NullPointerException
at com.gx.webmanager.handlers.DESHTTPResponseHandler.getSecretKey(DESHTTPResponseHandler.java:240)
at com.gx.webmanager.handlers.DESHTTPResponseHandler.init(DESHTTPResponseHandler.java:102)
at nl.gx.webmanager.handler.forms.foundation.FormFactory.getFormComponents(FormFactory.java:231)
at nl.gx.webmanager.handler.forms.foundation.FormFactory.getForm(FormFactory.java:85)
at nl.gx.webmanager.handler.forms.foundation.FormProcessor.getFormDefinition(FormProcessor.java:367)
at nl.gx.webmanager.handler.forms.foundation.FormValuesHandler.doFilter(FormValuesHandler.java:121)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at nl.gx.webmanager.handler.servlet.multipart.MultiPartFilter.doFilter(MultiPartFilter.java:114)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at nl.gx.webmanager.servlet.PathInfoFilter.doFilter(PathInfoFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at nl.gx.filter.RequestLogger.doFilter(RequestLogger.java:95)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at nl.gx.webmanager.handler.servlet.FriendlyURLFilter.doFilter(FriendlyURLFilter.java:148)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at nl.gx.filter.signing.SecureFormsCheckingFilter.doFilter(SecureFormsCheckingFilter.java:215)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at nl.gx.webmanager.handler.servlet.SessionSecurityFilter.doFilter(SessionSecurityFilter.java:179)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at nl.gx.filter.signing.SecureFormsSigningFilter.doFilter(SecureFormsSigningFilter.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at nl.gx.webmanager.servlet.DefaultEncodingFilter.doFilter(DefaultEncodingFilter.java:90)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.gx.webmanager.filter.RequestFilter.doFilter(RequestFilter.java:147)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:393)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Unknown Source)


The used code looks something like this:

private DataSourceManager myDatasourceManager;

/**
* @param webid
* @return String
*/
private String getSecretKey(String webid) {
...

Connection connection = null;
PreparedStatement statement = null;

LOG.warning("DESHTTPResponseHandler.java: GO CONNECT: " + DATASOURCE);

try {
LOG.warning("DESHTTPResponseHandler.java: GO CONNECT-AAA-1");
DataSource xxx = myDatasourceManager.getDataSource(DATASOURCE);

LOG.warning("DESHTTPResponseHandler.java: GO CONNECT-BBB");
connection = xxx.getConnection();

LOG.warning("DESHTTPResponseHandler.java: GO CONNECT-CCC");


statement = connection.prepareStatement(query);
statement.setString(1, webid);
ResultSet rs = statement.executeQuery();

if (rs.next()) {
secretKey = rs.getString("chess_secret");
}

} catch (SQLException e) {
LOG.warning("SQL Exception caught :" + e.getMessage());
} finally {
try {
Utility.close(statement, connection);
} catch (SQLException e) {/* ignore */
}
}

return secretKey;

}

/**
* @param datasourceManager
*/
public void setDatasourceManager(DataSourceManager datasourceManager) {
this.myDatasourceManager = datasourceManager;
}


One never reaches: LOG.warning("DESHTTPResponseHandler.java: GO CONNECT-BBB").


Does anyone have some ideas why the datasourceManager is not connected?
What is the correct way to set the datasourceManager?

williamb



Posts: 310

Posted: 09-06-2010 12:19

Ron,

did you see http://connect.gxsoftware.com/Forums/Forum-WCB-Java-Development.htm?db....

Try to add the set a dependency on the DataSourceManager in the Activator, so it will be injected.

William

Back to top

New message: "Nullpointer exception when posting a form due to unconnected datasourceManager"
Message:
bold boitalicd underline url quote code smile cool eek grin mad razz sad wink
 
© 2012 GX Software B.V.

Disclaimer

This website (Connect.gxsoftware.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.