I am trying to move my app to a new server and for now have redirected a single link . For some reason the new version is not connecting to the DB and i am getting a Parser Exception .
William Brogden
,
Author and all-around good cowpoke
If your clients normally reach your server with a POST request, a redirect will not work because all redirects are GETs.
What EXACTLY is the parser exception?
(I will never understand why people say "I got an exception" without posting the actual exception. Java exceptions are well designed to help you figure out what went wrong.)
Why didn't your initial post mention the parser exception?
Sorry new to javaRanch ,,, Had posted the exception earlier but it was in a wrong place . I'll post it now . I have pasted below .
java.lang.RuntimeException: Error initializing Cause: java.lang.RuntimeException:
Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing
XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.
Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause:
org.xml.sax.SAXParseException: Attribute "resultClass" must be declared
for element type "insert".
java.lang.ExceptionInInitializerError
at com.aish.user.repository.EndUserRepository.getLogo(EndUserRepository.java:57)
at com.aish.pladmin.action.PLAdminLoginPageAction.execute(PLAdminLoginPageAction.java:42)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:412)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:96)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:109)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:183)
at com.caucho.server.cache.ProxyCacheFilterChain.doFilter(ProxyCacheFilterChain.java:206)
at com.caucho.server.webapp.AccessLogFilterChain.doFilter(AccessLogFilterChain.java:95)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:287)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:792)
at com.caucho.network.listen.TcpSocketLink.dispatchRequest(TcpSocketLink.java:675)
at com.caucho.network.listen.TcpSocketLink.handleRequestsImpl(TcpSocketLink.java:637)
at com.caucho.network.listen.TcpSocketLink.handleRequests(TcpSocketLink.java:588)
at com.caucho.network.listen.TcpSocketLink$AcceptTask.doTask(TcpSocketLink.java:1175)
at com.caucho.network.listen.TcpSocketLink$ConnectionReadTask.runThread(TcpSocketLink.java:1108)
at com.caucho.network.listen.TcpSocketLink$AcceptTask.run(TcpSocketLink.java:1142)
at com.caucho.env.thread.ResinThread.runTasks(ResinThread.java:182)
at com.caucho.env.thread.ResinThread.run(ResinThread.java:126)
Caused by: java.lang.RuntimeException: Error initializing Cause: java.lang.RuntimeException:
Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing
XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.
Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause:
org.xml.sax.SAXParseException: Attribute "resultClass" must be declared
for element type "insert".
at com.aish.pladmin.repository.SQLMapInitializer.<clinit>(SQLMapInitializer.java:39)
As far as redirect is concerned i am redirecting a link from my live-server to the new server using response.sendRedirect("http://IP:8080);
The control is going to the new server and into the action class .It is then sent to a repository class called EndUserRepository (POJO) .From here a SQLMapInitializer.java class is called which inturn has a SqlMapClientBuilder.buildSqlMapClient(reader) method . The control is executing fine until the control comes to this class file and this particular line which is looking for the SqlMapConfig.xml .
The code is working perfectly fine in the live server with the same Db -code but it failing to connect to the DB when the request is coming from the new server.
William Brogden
,
Author and all-around good cowpoke
The code is working perfectly fine in the live server with the same Db -code but it failing to connect to the DB when the request is coming from the new server.
We are forced to the conclusion that there is some difference between the two servers, but there is no reason to believe that the difference is due to the parser available.
It appears that the xml was found and a DOM created -otherwise you would not have gotten to the XPath attempt.
What are the "insert" element and "resultClass" attributes?
It is suggesting that a result class has to be present for all insert queries . But for any insert queries there are no result classes except when a select key is used . We have a couple of queries with select key but they have a result class .
We received a below query from the network provider :
The exception stack trace is indicating that "resultClass" is not permitted as an attribute of "insert" in your iBatis SQL map file.
This seems to make sense, since there is no "result" on an insert operation.
I have to think that the upgrade to Resin 4.0 or an upgraded XML parser or iBatis library is indicating a configuration problem that was never reported before due to improved XML validation.
We also installed the DB in the new server and tried connecting but ended up with a same error .Is it possible that the newer version of the server had some new xml parsing rules which is not allowing our old code to work . I will paste below the class file and point out the exact line which is causing problem .