GoogleSearchBox

Custom Search

Friday, July 12, 2013

How to know whether a WebService WSDL file is of SOAP version 1.1 or 1.2 compliant

If your WSDL file has a namespace named "soap12" inside the <wsdl:definitions   tag, as shown below:

<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"



Then the wsdl is SOAP 1.2 version compliant /compatible.


References:
http://schemas.xmlsoap.org/wsdl/soap12/soap12WSDL.htm

validate a webservice wsdl file online

Below are some sites to validate the WSDL file hosted some where in the internet.

1. http://www.validwsdl.com/
2. http://xmethods.net/ve2/Tools.po



Thursday, July 4, 2013

Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog.

SEVERE: Parse Fatal Error at line 2 column 1: Content is not allowed in prolog.

org.xml.sax.SAXParseException: Content is not allowed in prolog.

        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)

        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)

        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)

        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)

        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)

        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)

        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)

        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)

        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)

        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)

        at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1642)

        at org.apache.catalina.startup.Catalina.load(Catalina.java:524)

        at org.apache.catalina.startup.Catalina.load(Catalina.java:562)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

        at java.lang.reflect.Method.invoke(Unknown Source)

        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261)

        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Jul 4, 2013 3:43:44 PM org.apache.catalina.startup.Catalina load

WARNING: Catalina.start using conf/server.xml:

org.xml.sax.SAXParseException: Content is not allowed in prolog.

        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)


We get this error, due to some characters in the xml file (in my case it was server.xml file) are not liked by the Parser. Even when you open the same file in IE browser, it will not open up. Also IDE like MyEclipse also shows same error "Content is not allowed in prolog."

I could not find out, which character or line are not liked by the parser.
So the solution for me : I took another same xml file (which was working) and replaced it and made changes as per my requirement.

That's it !!

Wednesday, July 3, 2013

java.lang.NullPointerException at org.apache.jsp.index_jsp._jspInit(index_jsp.java:22) and javax.servlet.ServletException: java.lang.LinkageError

SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException at org.apache.jsp.index_jsp._jspInit(index_jsp.java:22) at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
 at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164) 
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 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:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
 at java.lang.Thread.run(Thread.java:619)
Jul 3, 2013 5:27:29 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception


I googled it, found some suggestions like,
we have jsp-api.jar and servlet-api.jar placed inside the project’s WEB-INF/lib directory and That’s causing the issue. Because it should not be there as Tomcat has it already these jars in its lib.
But removing that jar from the projects   gives me this below error:


















And Sometimes, when you delete some conflicting jars (but still some conflicts remains there), then you may get below exception :

javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;

" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext,
have different Class objects for the type javax/el/ExpressionFactory used in the signature
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:343)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

 java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature


Now the root cause of this issue is jar files conflict.
Basically identical jar's located inside server's (like Tomcat's) lib directory conflict with same jars found in your deployed application's WEB-INF/lib/ directory.
Below jars in my case above were causing the issue.
1. servlet-api.jar
2. jsp-api.jar
3. el-api.jar

I had these in the BuildPath of my MyEclipse, because of class files had dependency on these.. so could not delete from there. But when I deploy the application, these jars get copied into the TOMCAT_HOME/webapps/myproject/WEB-INF/lib/

And by default my TOMCAT_HOME/lib/  directory had these jars.

Now, I can not delete the servlet-api and jsp-api jars from my MyEclipse build path, otherwise my code will have so many compile errors due to classNotFound.

So the solution I used is:
1. I deleted  servlet-api and jsp-api jars from my MyEclipse build path, and in place of these, I used javaee.jar (which had all the required class files for my project to compile).
2. Also completely deleted the el-api.jar  file too from the build path

Hope that helps for you too!!

References:
http://stackoverflow.com/questions/8487048/java-lang-linkageerror-javax-servlet-jsp-jspapplicationcontext-getexpressionfac

spring / JSTL $ variable does not display the value Or Spring $ variable not carrying into view / JSP

The expression language (EL, $ syntax) like ${message} doesn't work in my JSP / JSTL tags while working with Spring!
 I noticed this issue while working with Spring demo.

Lets discuss first what was my settings and what I tried to make it work, then will take about the solution.
I was setting the variable in the spring Controller like below:

 @RequestMapping("/hello")
 public ModelAndView helloWorld() {
  String message = "HELLO SPRING MVC";
  return new ModelAndView("abcd", "msg", message);
 }
 
        /* Even I tried below way of setting the variable msg */
 @RequestMapping("/welcome")
 public String welcomeWorld(Model m) {
  String s = "HELLO SPRING MVC";
  m.addAttribute("msg", s);
  return "welcome";
 }

And I was trying to use the "msg" variable  in the JSP (abcd.jsp) as below:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>

<html>
<body>
Message is: <%= request.getAttribute("msg") %> <br/>
Message is: <c:out value="${msg}" /> <br/>
Message is: ${"msg"} <br/>
Message is: ${msg} <br/>
</body>
</html>


Tried every possible combination of displaying the variable in the jsp.
 But I was not getting any value corresponding to the variable when used along with the EL $, I used to get below response through JSP page when run under tomcat 5.5.x:












So, after googling out, I found that, its the Servlet and JSP versions not compatible with the server.
Basically in my web.xml I had declared the version of Servlet I am using is 2.5 as below:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

   <servlet>
  <servlet-name>spring</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
  <servlet-name>spring</servlet-name>
  <url-pattern>*.html</url-pattern>
 </servlet-mapping>
</web-app>


But, I was deploying above application on a Tomcat server of version 5.5.x (which supports Servlets version 2.4). And that was the main root cause.

So, When I deployed the application to Tomcat 6.x (supporting Servlets 2.5 and a higher version of JSP and EL), It worked fine.

Now I am getting the expected result of the above JSP (abcd.jsp) page, the output is shown below:











Hope this helps you too!!

References I followed:
http://stackoverflow.com/tags/jstl/info