aspose file tools*
The moose likes Struts and the fly likes Struts Problem with DAO.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Problem with DAO.." Watch "Struts Problem with DAO.." New topic
Author

Struts Problem with DAO..

sivasakam kumarsakam
Greenhorn

Joined: Sep 07, 2007
Posts: 21

i wrote program using Struts 1.x to connect to Mysql database using DAO pettern to check the User Name and password correct or not, if correct it reach the success.jsp page, else it is in index.jsp, when i am trying to run the following code it gave the errors,this is my entire program code and errors

index.jsp
success.jsp

web.xml
struts-config.xml

com.struts.form.MyActionForm

com.struts.vo.MyVO

com.struts.dao.DaoFactory
com.struts.dao.MysqlDaoFactory

com.struts.dao.LoginDao

com.struts.dao.LoginDaoImpl

com.struts.delegate.MyDelegate

com.struts.action.MyAction



when i am trying to run above code it gave following errors


4 Jan, 2010 10:26:05 AM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
4 Jan, 2010 10:26:08 AM org.apache.struts.action.ActionServlet initChain
INFO: Loading chain catalog from jar:file:/home/sivakumar/NetBeansProjects/StrutsDAO/build/web/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml
4 Jan, 2010 10:26:10 AM org.apache.struts.tiles.TilesPlugin initDefinitionsFactory
INFO: Tiles definition factory loaded for module ''.
4 Jan, 2010 10:26:10 AM org.apache.struts.validator.ValidatorPlugIn initResources
INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml'
4 Jan, 2010 10:26:10 AM org.apache.struts.validator.ValidatorPlugIn initResources
INFO: Loading validation rules file from '/WEB-INF/validation.xml'
---------------------getUname()---------------------
---------------------siva---------------------
---------------------getPass()---------------------
---------------------kumar---------------------
---------------------setUname()---------------------
---------------------setPass()---------------------
---------------------1---------------------
---------------------getUname()---------------------
---------------------siva---------------------
---------------------setUname() of MyVO---------------------
---------------------siva of MyVO---------------------
---------------------getPass()---------------------
---------------------kumar---------------------
---------------------setPass() of MyVO---------------------
---------------------5---------------------
4 Jan, 2010 10:26:29 AM org.apache.struts.tiles.TilesRequestProcessor initDefinitionsMapping
INFO: Tiles definition factory found for request processor ''.
---------------------2---------------------
---------------------mysql---------------------
-------------------------------4----------------------------------
-------------------------------Connected----------------------------------
-------------------------------com.mysql.jdbc.JDBC4Connection@11e98f4----------------------------------
--------------------java.lang.ClassCastException: com.mysql.jdbc.JDBC4Connection cannot be cast to com.nareshit.struts.dao.DaoFactory---------------------
java.lang.ClassCastException: com.mysql.jdbc.JDBC4Connection cannot be cast to com.nareshit.struts.dao.DaoFactory
at com.nareshit.struts.dao.DaoFactory.getDaoFactory(DaoFactory.java:22)
at com.nareshit.struts.delegate.MyDelegate.validateUp(MyDelegate.java:18)
at com.nareshit.struts.action.MyAction.execute(MyAction.java:38)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
--------------------Not mysql---------------------
4 Jan, 2010 10:26:32 AM org.apache.struts.util.PropertyMessageResources loadLocale
WARNING: Resource org/apache/struts/action/ActionResources_en_IN.properties Not Found.
4 Jan, 2010 10:26:32 AM org.apache.struts.util.PropertyMessageResources loadLocale
WARNING: Resource org/apache/struts/action/ActionResources_en.properties Not Found.
4 Jan, 2010 10:26:32 AM org.apache.struts.action.RequestProcessor processException
WARNING: Unhandled Exception thrown: class java.lang.NullPointerException


Thanks....
Zhixiong Pan
Ranch Hand

Joined: Jan 25, 2006
Posts: 239
hi sivasakam,

My attempt to build the environment had a trouble.
To compile class com.struts.dao.DaoFactory, it requires the class com.struts.dao.MysqlDaoFactory. But the class com.struts.dao.MysqlDaoFactory inherits from class com.struts.dao.DaoFactory. It seems they depend on each other.
I am confused about that.


SCJP 1.4 SCJD
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please, please try to limit code to only the code causing the problem. The code causing the problem can be determined by looking at the exception's stack trace.

You're trying to get a DaoFactory and returning a connection.

Your code is pretty difficult to follow.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Problem with DAO..