Wednesday, May 4, 2011

Portlet request dispatcher inclusion error MXParserFactory not found

I would like to share one more experience which I have had with Web services API used with portal environment (using portlets). In this, I prepared a Java Client (Stub) using Axis2 1.5 tool which contains Java classes and XML files. While compiling this code, I faced some issues. At first, I found an error which is,



4/21/11 20:08:58:000 IST] 00000052 PortletReques E com.ibm.ws.portletcontainer.
core.impl.PortletRequestDispatcherImpl internal include EJPPC0172E: Error occurred during portlet request dispatcher inclusion
                                 java.lang.NoClassDefFoundError: javax.xml.stream.XMLStreamException
    at java.lang.J9VMInternals.verifyImpl(Native Method)
    at java.lang.J9VMInternals.verify(J9VMInternals.java:68)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:129)
    at com.yash.ews.connection.EWSBaseConnector.(EWSBaseConnector.java:113)
The resolution of the error is to set JSR173_API.jar in lib directory of your application. Your compile time issues will get resolved. Once you run this application, you will get another error which is,
[4/21/11 20:12:58:232 IST] 00000055 PortletReques E com.ibm.ws.portletcontainer.
core.impl.PortletRequestDispatcherImpl internal include EJPPC0172E: Error occurred during portlet request dispatcher inclusion
                                 javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found
    at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
    at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
    at org.apache.axiom.om.util.StAXUtils$7.run(StAXUtils.java:505)
    at java.security.AccessController.doPrivileged(AccessController.java:197)
    at org.apache.axiom.om.util.StAXUtils.newXMLInputFactory(StAXUtils.java:495)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory_perClassLoader(StAXUtils.java:566)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:172)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:137)
    at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:224)
    at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:218)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:596)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:581)

This error is related with XML parser. In java, we are aware of SAX parser however there is another parser StAX which is now used in latest programs and has the option of pausing and resuming the parsing process. Also works in similar streaming fashion. You can find this parser in sjsxp.jar which resolve this issue.
You can get more knowledge for the same in StAX.

Friday, April 22, 2011

HTTPSender Unable to sendViaPost to url

I would like to share one of my experience which I have had with Web services API used with portal environment (using portlets). In this issue, what I found is, the issue is not related to Web services, XML and portal. This error occurs due to invalid certificate which is used in portal environment. The main cause of this issue is, you are preparing request for HTTPS URL and your portal is not using valid certificate. So what you need to do is? update your certificate and restart your App server and portal server (depending on your environment). Your issue will get resolved. Alternatively, if you do not want to update your certificate you would need to change the configuration of server for which you have prepared URL. In my case, I am preparing URL for Exchange server (from portal) and the URL is,

https://<Exchange server host>/EWS/exchange.asmx 

So you need to change your Exchange server configuration for HTTP (URL would be start from HTTP not with HTTPs). 

For your information, the error details are,


[4/21/11 20:04:30:081 IST] 00000055 HTTPSender    I org.apache.axis2.transport.
http.HTTPSender sendViaPost Unable to sendViaPost to url[https://<Exchange server host>/EWS/exchange.asmx]
                                 org.apache.axis2.AxisFault
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
    at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:83)
    at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84)
    at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:495)
    at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)
    at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:557)
    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
    at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:438)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at com.microsoft.schemas.exchange.services._2006.messages.ExchangeServicesStub.findFolder(ExchangeServicesStub.java:8788)
    at com.yash.ews.FindFolders.findFolders(FindFolders.java:81)





Friday, April 1, 2011

Creating Web services

As we all know, it's time to move on Web services. It provides a way of communication over network using two electronic devices.
Well, I had a chance in my project where I was consuming .NET Web services. At that time I was not aware of, how can I prepare my own Web services? Now I come to know the required steps for preparing .NET Web services and I am sharing the same to this post.

Steps to create Web services
As I am going to create .NET Web services for which I need to use a .NET tool which is Microsoft Visual Studio 2005.

In order to create a new web service in VS 2005, please follow the steps below,
  • The figure below shows you the starting page of VS 2005.














  • Go to File >> New >> Web Site as,














  • Select ASP.NET Web Services and click OK.













  •  You will get Services.cs file which you can see in VS 2005. Here you can add your web methods which is similar as public method of your Java classes. Here I have created one 'HelloWorld' web method which you can see in Web service.














  • You need to debug this code. Click the green arrow button in upper middle portion of VS screen. You will get the below pop up message .










  •  You can see your service in browser with supported operations. As I have prepared this service for HelloWorld operation, you can see the same in figure below.














  •  You can now check your operation by clicking the same and check the used soap messages which is interacting with Web service.














  • As you can see in above figure, there is an invoke button. Once you click on this button, the web method will execute and give the result which you have passed in 'HelloWorld' web method in Services.cs file.














  • These are the steps for checking your operations which you have applied on Web services. Now you need to check your Web service which you can find in browser when you append '?WSDL' at the end of service URL which is,  http://localhost:TestWebSite/Service.asmx?WSDL.














  • This is what I am trying to explain you. Now you need to save this file in form .wsdl.















In this way, you can prepare your own services. Also you can go through one of my post Exchange Web services Java Stub to know about Java stub (Client) creation using Axis tool and Eclipse IDE.