File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes XML parser issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "XML parser issue" Watch "XML parser issue" New topic
Author

XML parser issue

sharath thyagaraja
Greenhorn

Joined: Dec 28, 2010
Posts: 8
Is there any XML parsers required when redirecting a link a newer version of the server ??
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
What exactly are you talking about here?

Is this a SOAP request you want to redirect? A RESTful service? A request for a WSDL document?

Are you trying something that is not working or is this one of those speculative questions we get from time to time?

Bill
sharath thyagaraja
Greenhorn

Joined: Dec 28, 2010
Posts: 8
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
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
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?

How are clients supposed to reach your server?

Bill
sharath thyagaraja
Greenhorn

Joined: Dec 28, 2010
Posts: 8
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)

Resin/4.0.13 Server: 'default'


sharath thyagaraja
Greenhorn

Joined: Dec 28, 2010
Posts: 8
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
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
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?
sharath thyagaraja
Greenhorn

Joined: Dec 28, 2010
Posts: 8
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.

sharath thyagaraja
Greenhorn

Joined: Dec 28, 2010
Posts: 8
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 .


package com.aish.pladmin.repository;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class SQLMapInitializer
{

private static SqlMapClient db1SqlMap = null;


public SQLMapInitializer()
{
}

public static SqlMapClient getSQLMap()
{
return db1SqlMap;
}

static
{
try
{
String resourceName = "SQLMapConfig.xml";
java.io.Reader reader = Resources.getResourceAsReader(resourceName);
db1SqlMap = SqlMapClientBuilder.buildSqlMapClient(reader); // LINE CAUSING EXCEPTION
}

catch(Exception e)
{
e.printStackTrace();
throw new RuntimeException((new StringBuilder("Error initializing Cause: ")).append(e).toString()); // Runtime EXCEPTION thrown at the console
}

}
}
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
.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 .


Seems unlikely - the XML specification has been stable for years.

If this was my problem, I would now try to verify exactly what the reader created in these lines actually reads:


I would comment out the buildSqlMapClient... line and instead read all the contents while dumping them to a log or the console.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: XML parser issue