V
Vivek
Hi all
I am using struts 1.2 and mySql as the database, when i try to make a
connection an error message gets displayed on my server(jboss-4.0.0)
console.
I am putting my code and error message so that it will be easy to
understand.
Code is as follows
package com.actions;
import org.apache.struts.action.Action;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LoginAction extends Action {
// Global Forwards
public static final String GLOBAL_FORWARD_getName ="getName";
// Local Forwards
private static final String FORWARD_success ="success";
Connection con=null;
Statement st = null;
ResultSet rs= null;
public LoginAction() {
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String userid = ((com.actionforms.LoginForm)form).getUserid();
String password =
((com.actionforms.LoginForm)form).getPassword();
DataSource ds = getDataSource(request,"codexhibit");
Connection con=ds.getConnection();
Statement st=con.createStatement();
System.out.println("************************The Connection is
esatablished******************"+con);
ResultSet rs=st.executeQuery("Select * from login_valid");
return mapping.findForward(FORWARD_success);
}
}
Now when i click on login button of my webpage it gives the following
error on the console
Error message:
15:30:29,093 ERROR [Engine] StandardWrapperValve[action]:
Servlet.service() for
servlet action threw exception
java.lang.NullPointerException
at org.apache.struts.tiles.xmlDefinition.FactorySet.getDefinition(Factor
ySet.java:116)
at org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper
..getDefinition(ComponentDefinitionsFactoryWrapper.java:86)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(
TilesRequestProcessor.java:153)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(Ti
lesRequestProcessor.java:300)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:231)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:116
4)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecur
ityMgrRealm.java:275)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:16
0)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:536)
*******************************************************************************
I have checked my struts config.xml and the various jar files they
seem to be fine.
Please suggest
With Regards
Vivek.
I am using struts 1.2 and mySql as the database, when i try to make a
connection an error message gets displayed on my server(jboss-4.0.0)
console.
I am putting my code and error message so that it will be easy to
understand.
Code is as follows
package com.actions;
import org.apache.struts.action.Action;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LoginAction extends Action {
// Global Forwards
public static final String GLOBAL_FORWARD_getName ="getName";
// Local Forwards
private static final String FORWARD_success ="success";
Connection con=null;
Statement st = null;
ResultSet rs= null;
public LoginAction() {
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String userid = ((com.actionforms.LoginForm)form).getUserid();
String password =
((com.actionforms.LoginForm)form).getPassword();
DataSource ds = getDataSource(request,"codexhibit");
Connection con=ds.getConnection();
Statement st=con.createStatement();
System.out.println("************************The Connection is
esatablished******************"+con);
ResultSet rs=st.executeQuery("Select * from login_valid");
return mapping.findForward(FORWARD_success);
}
}
Now when i click on login button of my webpage it gives the following
error on the console
Error message:
15:30:29,093 ERROR [Engine] StandardWrapperValve[action]:
Servlet.service() for
servlet action threw exception
java.lang.NullPointerException
at org.apache.struts.tiles.xmlDefinition.FactorySet.getDefinition(Factor
ySet.java:116)
at org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper
..getDefinition(ComponentDefinitionsFactoryWrapper.java:86)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(
TilesRequestProcessor.java:153)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(Ti
lesRequestProcessor.java:300)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:231)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:116
4)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecur
ityMgrRealm.java:275)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:16
0)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:536)
*******************************************************************************
I have checked my struts config.xml and the various jar files they
seem to be fine.
Please suggest
With Regards
Vivek.