Tuesday, April 29, 2014

Axis2 Installation in Websphere 8.0 to 8.0.0.8

The following tutorial is about Axis2 Installation in Websphere 8.0 to 8.0.0.8

Step 1: Download the Required Axis2 War file from the Apache Axis Website
http://axis.apache.org/axis2/java/core/
Click on the Releases


Step 2:  Download the Version you need to install

You can choose Axis2 1.6.1 or 1.6.2


Step 3: Extract the war file from the Zip file




Step 4: For convenience  i have renamed the war file with specific version names

axis2.war to axis2_1_6_1.war / axis2_1_6_2.war depends on the version of war file which you have downloaded

Then Open the Zip file in the WinZip / 7Zip / Any Other utility



Step 5: Update the axis2.xml with the following attribute from false to true



Step 6:  Update the file in the axis2_1_6_2\WEB-INF \conf  folder


Step 7: Navigate to Websphere 8.0 Admin Console 

Application --> Application Types --> Websphere enterprise applications --> Install 



Step 8:  Click choose in the install page



Step 9: Browse and Select the updated war file axis2_1_6_2.war (**Updated Axis2.xml must be in the war file)


Step 10:  Click Next after selecting the war file 



Step 11: Select Fast Path and Click Next

Step 12: Click Next with default parameters



Step 13: Click Next in Map Modules to Server


Step 14: Click Next in Map Virtual Host



Step 15: Provide the Context Root as /axis2 and Click Next


Step 16: Click Finish in the Summary Screen


Step 17:  Click save directly to master configuration




Step 18:  Click on the deployed war file

Step 19: Click on Class Loading and update detection


Step 20: Select Classes loaded with local class loader first (parent last) and click apply
 Step 21: Click Save directly to the master configuration


Step 22: Click on the deployed war file


Step 23: Click on Manage Modules



Step 24:  Click on the Module Name Hyperlink Apache-Axis2


Step 25: From the drop down Class Loader Order --> Select Classes loaded with local class loader first (parent first) and click apply

Step 26:  Save directly to master configuration


Step 27: Click Ok


Step 28: Save directly to master configuration

Step 29: Select the war file and Click Start


Step 30: Application started successfully message will be displayed


Step 31: Open the url http://localhost:9080/axis2/services/Version?getVersion



Apache Axis 1.6.1 --> Run's fine in Websphere 8.0 at different patch levels

Apache Axis 1.6.2 --> Needs special changes in Websphere 8.0 at different patch levels especially for UNIX or LINUX operating system. In windows it will work fine for the above instruction.

I would strongly recommend to go for the latest version as of now 1.6.2


If you using Apache Axis2 1.6.2 in UNIX or LINUX you need to follow the below steps too

Step 32(Only for LINUX & UNIX OS): Copy (Not Move) the mar file to a jar file and move it to single jar file aall_module_secure.jar
The final jar file should be placed to the WEB-INF\lib
Rationale: IBM Websphere 8.0.0.1 doesn’t class load automatically for modules 
Step 33 (Only for LINUX & UNIX OS): Don't use the default axis2.xml from Apache Axis2 1.6.2 you need to get the axis2.xml from the IBM Websphere server local /apps/WebSphere8/AppServer/plugins/org.apache.axis2.jar 

org.apache.axis2.jar contains the axis2.xml file and other modules

Troubleshooting: 

In case of any problem first thing to check is go the url http://localhost:9080/axis2/  and click validate


Make sure the jar files are loaded from WEB-INF/lib from the screen shot




If you have something like below then you have missed the Step 24, 25 and 26.

You can see that the axis jar file is loaded from Websphere instead of WEB-INF lib which is wrong
\WebSphere\AppServer\plugins\org.apache.axis2.jar 



Examining webapp configuration

Essential Components

Found Apache-Axis (org.apache.axis2.transport.http.AxisServlet)
  at C:\IBM\WebSphere\AppServer\plugins\org.apache.axis2.jar
Found Jakarta-Commons Logging (org.apache.commons.logging.Log)
  at C:\IBM\WebSphere\AppServer\plugins\com.ibm.ws.prereq.commons-logging.jar
Found Streaming API for XML (javax.xml.stream.XMLStreamReader)
  at an unknown location
Found Streaming API for XML implementation (org.codehaus.stax2.XMLStreamWriter2)
  at C:\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\AARYAN-VAIONode01Cell\axis2_1_6_2_war.ear\axis2_1_6_2.war\WEB-INF\lib\wstx-asl-3.2.9.jar
The core axis2 libraries are present.
Note: Even if everything this page probes for is present, there is no guarantee your Axis Service will work, because there are many configuration options that we do not check for. These tests are necessary but not sufficient

Examining Version Service

There was a problem in Axis2 version service , may be the service not available or some thing has gone wrong. But this does not mean system is not working ! Try to upload some other service and check to see whether it is working. 


Troubleshooting based on Log file errors 

Problem#1 

If you get the error as below,

[29/04/14 21:42:56:607 EDT] 0000001c webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[AxisServlet]: org.apache.axis2.AxisFault: The system is attempting to engage a module that is not available: addressing
at org.apache.axis2.engine.AxisConfiguration.engageModule(AxisConfiguration.java:584)
at org.apache.axis2.engine.AxisConfiguration.engageGlobalModules(AxisConfiguration.java:705)
at org.apache.axis2.deployment.DeploymentEngine.engageModules(DeploymentEngine.java:831)
at org.apache.axis2.deployment.WarBasedAxisConfigurator.engageGlobalModules(WarBasedAxisConfigurator.java:300)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:94)
at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:584)
at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:454)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:329)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:577)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:449)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1020)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:883)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1659)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1648)

[29/04/14 21:42:56:612 EDT] 00000020 SystemOut     O [INFO] OMException in getSOAPBuilder
org.apache.axiom.om.OMException: SOAP message MUST NOT contain a Document Type Declaration(DTD)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createDTD(StAXSOAPModelBuilder.java:455)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:282)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:198)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:140)
at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:686)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:197)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:555)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:531)
at com.ibm._jsp._HappyAxis.invokeTheService(_HappyAxis.java:372)
at com.ibm._jsp._HappyAxis._jspService(_HappyAxis.java:512)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1147)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:722)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:449)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1020)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:883)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1659)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1648)


Solution#1 : (Fix for The system is attempting to engage a module that is not available: addressing) 
Axis2.xml file attribute is not updated 

    <parameter name="EnableChildFirstClassLoading">true</parameter>

And also Step 32 and 33 if you are in UNIX or LINUX

Problem#2 

If you get the error as below,

[29/04/14 22:54:55:547 EDT] 00000017 WarBasedAxisC E org.apache.axis2.deployment.WarBasedAxisConfigurator <init> org.apache.commons.fileupload.FileUploadException
                                 org.apache.axis2.deployment.DeploymentException: org.apache.commons.fileupload.FileUploadException
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:774)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:234)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:859)
at org.apache.axis2.deployment.WarBasedAxisConfigurator.<init>(WarBasedAxisConfigurator.java:156)
at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:569)
at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:457)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:329)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.load(ServletWrapper.java:1283)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:973)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3639)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:950)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1659)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1648)
Caused by: java.lang.NoClassDefFoundError: org.apache.commons.fileupload.FileUploadException
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:77)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:139)
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1345)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:771)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:612)
... 35 more

[29/04/14 22:54:55:548 EDT] 00000017 AxisServlet   I org.apache.axis2.util.OnDemandLogger info org.apache.axis2.deployment.DeploymentException: org.apache.commons.fileupload.FileUploadException
[29/04/14 22:54:55:549 EDT] 00000017 servlet       E com.ibm.ws.webcontainer.servlet.ServletWrapper init Uncaught.init.exception.thrown.by.servlet
[29/04/14 22:54:55:564 EDT] 00000017 ClusterBuilde I org.apache.axis2.deployment.ClusterBuilder buildCluster Clustering has been disabled
[29/04/14 22:54:55:566 EDT] 00000017 WarBasedAxisC E org.apache.axis2.deployment.WarBasedAxisConfigurator <init> org.apache.commons.fileupload.FileUploadException
                                 org.apache.axis2.deployment.DeploymentException: org.apache.commons.fileupload.FileUploadException
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:774)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:234)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:859)
at org.apache.axis2.deployment.WarBasedAxisConfigurator.<init>(WarBasedAxisConfigurator.java:156)
at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:569)
at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:457)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:329)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:577)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:449)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1020)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3639)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:950)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1659)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1648)
Caused by: java.lang.NoClassDefFoundError: org.apache.commons.fileupload.FileUploadException
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:77)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:139)
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1345)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:771)
... 30 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:612)
... 37 more

[29/04/14 22:54:55:568 EDT] 00000017 AxisServlet   I org.apache.axis2.util.OnDemandLogger info org.apache.axis2.deployment.DeploymentException: org.apache.commons.fileupload.FileUploadException
[29/04/14 22:54:55:568 EDT] 00000017 servlet       E com.ibm.ws.webcontainer.servlet.ServletWrapper init Uncaught.init.exception.thrown.by.servlet
[29/04/14 22:54:55:568 EDT] 00000017 webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[AxisServlet]: org.apache.axis2.deployment.DeploymentException: org.apache.commons.fileupload.FileUploadException
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:774)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:234)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:859)
at org.apache.axis2.deployment.WarBasedAxisConfigurator.<init>(WarBasedAxisConfigurator.java:156)
at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:569)
at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:457)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:329)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:577)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:449)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1020)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3639)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:950)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1659)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1648)
Caused by: java.lang.NoClassDefFoundError: org.apache.commons.fileupload.FileUploadException
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:77)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:139)
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1345)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:771)
... 30 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:612)
... 37 more

[29/04/14 22:54:55:576 EDT] 00000017 servlet       I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [axis2_1_6_2_war] [/axis2] [/axis2-web/Error/error500.jsp]: Initialization successful.


Solution#2 : (Fix for WarBasedAxisC E org.apache.axis2.deployment.WarBasedAxisConfigurator <init> org.apache.commons.fileupload.FileUploadException
Step 24, 25, 26 not done properly

Problem#3: java.lang.VerifyError: class loading constraint violated (class: org/apache/xerces/dom/CoreDocumentImpl method: getDomConfig()Lorg/w3c/dom/DOMConfiguration;) at pc: 0 


Solution#3 : (FIX for "java.lang.VerifyError: JVMVRFY013 class loading constraint violated" )


In the xmlbeans-2.3.0.jar à remove org.dom package




Recommendations: 
If you have a chance to update the Fix Pack for Websphere please do it which will resolve lot of bugs and issues
To view list of fix packs for IBM Websphere server check the link below,
http://www-01.ibm.com/support/docview.wss?uid=swg27004980

Also if you are planning to enabling Third Party JAX-WS
Use this link

Using a third-party JAX-WS Web services engine

 http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Ftwbs_thirdparty.html

Also i found this article is very useful but not detailed

http://www.ibm.com/developerworks/websphere/library/techarticles/1001_thaker/1001_thaker.html

Tuesday, July 23, 2013

Hibernate SessionFactory buildSessionFactory deprecated fix


Fix for Hibernate SessionFactory buildSessionFactory deprecation as of Hibernate 4.0 

private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;

private static SessionFactory configureSessionFactory() throws HibernateException {
   Configuration configuration = new Configuration();
   configuration.configure();
   serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();        
   sessionFactory = configuration.buildSessionFactory(serviceRegistry);
   return sessionFactory;
}



Generic JDBC Program for Derby


This is a simple JDBC Program for Derby database. No standards followed, you can see that connection is not closed, statement is not cleared.

Can be used to check database connectivity.

SQL Queries
create table test (id integer, name varchar(10), age integer, address varchar(30));

insert into test values (1, 'test1', 20, '80 Absolute Avenue');
insert into test values (2, 'test2', 30, '90 Absolute Avenue');

select * from test



package com.hibernate.demo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class GenericJDBC {

public static void main(String[] args) {
// TODO Auto-generated method stub
String url ="jdbc:derby://localhost:1527/sample;create=true";

Connection conn;

try
{

Class.forName("org.apache.derby.jdbc.ClientDriver");

conn = DriverManager.getConnection(url, "user", "user");

Statement st = conn.createStatement();

ResultSet rs = st.executeQuery("select * from test");

while(rs.next())
{
System.out.println(rs.getInt(1)
+" " + rs.getString(2) +
" " + rs.getInt(3)+ " "+
rs.getString(4));
}

}catch(Exception e)
{
e.printStackTrace();
}
finally
{

}

}

}

Wednesday, July 17, 2013

ANT Weblogic WebApp Sample File

This article contains the Weblogic Web Application Ant Sample deployment script.

Very useful for configuration and deployment.

<project name="AppBuilder" default="deploy" basedir="."> 
        <property file="build.properties"/> 
<!-- 
Tasks to be done 
1. clean 
2. init 
3. compile 
4. copy 
5. war 
 --> 
        <path id="classpath"> 
                <!--<fileset dir="${lib.dir}" includes="*.jar"/>--> 
                <fileset dir="common" includes="*.jar"/> 
        </path> 

        <target name="clean"> 
                <echo>Cleaning the ${build.dir} and ${dist.dir}</echo> 
                <delete dir="${build.dir}"/> 
                <delete dir="${dist.dir}"/> 
        </target> 
        <target name="init" depends="clean"> 
                <echo>Creating the required directories</echo> 
                <mkdir dir="${dist.dir}"/> 
                <mkdir dir="${build.dir}\WEB-INF\classes"/>                 
                <mkdir dir="${build.dir}\WEB-INF\lib"/> 
        </target> 

        <target name="compile" depends="init"> 
                <echo>Compile the source files</echo> 
                <javac srcdir="${src.dir}" destdir="${build.dir}\WEB-INF\classes"> 
                        <classpath refid="classpath"/> 
                </javac> 
        </target>         
        
        <target name="copy" depends="compile"> 
                <copy todir="${build.dir}"> 
                        <fileset dir="${web.content}"/> 
                </copy> 
                <copy todir="${build.dir}/WEB-INF/classes"> 
                        <fileset dir="${src.dir}" includes="**/*.properties, **/*.xml, **/*.wsdl"/> 
                </copy> 
        </target>                 

        <target name="war" depends="copy"> 
                <echo>Building the war file</echo> 
                <war destfile="${dist.dir}\${project.name}.war" webxml="${build.dir}\WEB-INF\web.xml"> 
                        <fileset dir="${build.dir}"/> 
                </war> 
        </target> 

        <taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy"> 
          <classpath> 
          <pathelement location="common/weblogic.jar"/> 
          </classpath> 
        </taskdef> 

        <target name="deploy"> 
           <wldeploy action="deploy" 
                  source="dist/SMDBWebservice.war" name="SMDBWebservice" 
                  user="weblogic" password="weblogic" verbose="true" adminurl="t3://localhost:7001" 
                  debug="true" targets="AdminServer"/> 
        </target> 

        <target name="undeploy"> 
           <wldeploy action="undeploy" name="SMDBWebservice" 
                  user="weblogic" password="weblogic" verbose="true" adminurl="t3://localhost:7001" 
                  debug="true" targets="AdminServer"/> 
        </target> 

        <target name="redeploy"> 
           <wldeploy action="redeploy" 
                  source="dist/SMDBWebservice.war" name="SMDBWebservice" 
                  user="weblogic" password="weblogic" verbose="true" 
                  adminurl="t3://localhost:7001" 
                  debug="true" targets="AdminServer"> 
                 <!--<files file="index.jsp"/>--> 
           </wldeploy> 
        </target> 

        <taskdef name="wlconfig" classname="weblogic.ant.taskdefs.management.WLConfig"> 
          <classpath> 
          <pathelement location="common/weblogic.jar"/> 
          </classpath> 
        </taskdef> 

        <taskdef name="wlserver" classname="weblogic.ant.taskdefs.management.WLServer"> 
          <classpath> 
          <pathelement location="common/weblogic.jar"/> 
          <pathelement location="common/ant-weblogic.jar"/> 
          </classpath> 
        </taskdef> 

<target name="JDBCPool"> 
                <wlconfig url="t3://localhost:7001" username="weblogic" password="weblogic"> 
                        
                        <query domain="base_domain" type="Server" name="AdminServer"  property="server"/> 
                <create type="JDBCConnectionPool" 
                         name="CMSPool"       
                         property="cmspool">       
                         <set attribute="CapacityIncrement" value="1"/>       
                         <set attribute="DriverName"         
                                         value="com.ibm.db2.jcc.DB2Driver"/>       
                         <set attribute="InitialCapacity" value="1"/>       
                         <set attribute="MaxCapacity" value="10"/>       
                         <set attribute="Password" value="smdbuat"/>       
                         <set attribute="Properties" value="user=dsmdd1d;SecurityMechanism=EncryptedUIDPassword;databaseName=DPSMSSMD;serverName=160.254.49.155;batchPerformanceWorkaround=true;portNumber=3600;"/>       
                         <set attribute="RefreshMinutes" value="0"/>       
                         <set attribute="ShrinkPeriodMinutes" value="15"/>       
                         <set attribute="ShrinkingEnabled" value="true"/>       
                         <set attribute="TestConnectionsOnRelease" value="false"/>       
                         <set attribute="TestConnectionsOnReserve" value="false"/>       
                         <set attribute="URL" value="jdbc:db2://160.254.49.155:3600/DPSMSSMD"/>       
                         <set attribute="Targets" value="${server}"/>   
                 </create> 

                 <create type="JDBCTxDataSource" name="CMSDataSource"> 
                        <set attribute="JNDIName" value="JDBCIBM2"/> 
                        <set attribute="PoolName" value="CMSPool"/> 
                        <set attribute="Targets" value="${server}"/> 
                 </create> 
        </wlconfig> 
</target> 

</project> 

Hello World with Apache Ant

Apache Ant (Another Neat Tool) is a Java library and Command line utility useful for automating batch code build process.

For example, let say there is Java Class file HelloWorld.java   you need to compile, jar, move and run. In command you will perform the following activities

To Compile 

javac HelloWorld.java

To Create the jar file 

jar -cvf HelloWorld.jar HelloWorld.class

or

jar -cvf HelloWorld.jar HelloWorld.class jar -cvf HelloWorld.jar HelloWorld.java

To Move the program 

move HelloWorld.jar HelloWorld1.jar

To run the program

java -cp HelloWorld.jar HelloWorld


Executing all the above steps is ok for one time, lets say you have to do 100 times in a month. This is troublesome and can be automated.

Lets see how this can be automated

Step 1: Download the Apache Ant Latest Stable Version

http://ant.apache.org



Step 2:  Extract the Zip file

Step 3:  Go to Environment Variables


Step 4:  Create variable ANT_HOME 


Step 5: Add ANT_HOME\bin in the path 


Step 6:  Open Command prompt and execute the command ant -version



Step 7:  Create the build.xml  


1. target element with name attribute 

<target name="clean"> 

Create target for each of your activities example, clean, compile, move, jar, execute etc., 

2.  Echo Command 

    <echo>Cleaning the directories</echo> 

The echo command is useful while running the ant, it show which step it is currently in. Basically it is just print command.

3. Depends Attribute

        <target name="init" depends="clean"> 

Depends is a very useful command which will execute the depends target before executing the current target. It is like parent child relationship.

4. Console Commands

                <javac srcdir="${currentfolder}\src" destdir="${currentfolder}\classes"> 
                        <classpath refid="classpath"/> 
                </javac> 

For most of the generic commands you have Ant Task defined, tasks such as Javac, Jar, War etc., 

5.  Project Root Element and Attributes

<project name="HelloWorld" default="execute" basedir="."> 

The project element defines the project name the default target it should execute and the base directory from where it should run. 

Sample build.xml file as below,

<project name="HelloWorld" default="execute" basedir="."> 
        <!-- <property file="build.properties"/> -->
<!-- Tasks to be done 1. clean  2. init  3. compile  4. jar 5. move 6.execute --> 
 
<property name="currentfolder" location="C:\Temp"/>
 
        <path id="classpath"> 
                <!--<fileset dir="${lib.dir}" includes="*.jar"/>--> 
        </path> 
<target name="clean"> 
                <echo>Cleaning the ${build.dir} and ${dist.dir}</echo> 
                <delete dir="${currentfolder}\classes"/> 
                <delete dir="${currentfolder}\lib"/> 
        </target> 
        <target name="init" depends="clean"> 
                <echo>Creating the required directories</echo> 
                <mkdir dir="${currentfolder}\classes"/> 
                <mkdir dir="${currentfolder}\lib"/> 
        </target> 

        <target name="compile" depends="init"> 
                <echo>Compile the source files</echo> 
                <javac srcdir="${currentfolder}\src" destdir="${currentfolder}\classes"> 
                        <classpath refid="classpath"/> 
                </javac> 
        </target>

<target name="jar" depends="compile">
<echo>Creating the jar file</echo> 
<jar jarfile="${currentfolder}\lib\HelloWorld.jar" basedir="${currentfolder}\classes"/>
</target>
        <target name="move" depends="jar"> 
<echo>Moving the HelloWorld.jar file</echo> 
<move file="${currentfolder}\lib\HelloWorld.jar" tofile="${currentfolder}\lib\HelloWorld1.jar"/>
        </target>            
        <target name="execute" depends="move"> 
                <echo>Executing Hello World</echo> 
<java  fork="true"
  failonerror="true"
  maxmemory="128m"
  classname="HelloWorld">
<arg value="-h"/>
<classpath>
  <pathelement location="${currentfolder}\lib\HelloWorld1.jar"/>
  <pathelement path="${java.class.path}"/>
</classpath>
</java>
        </target> 
</project> 



Step 8:  Go to Command and run ant where you have the build.xml




This is just tip of an Ice Berg, you can perform lot of activities like deploying code to the server, creating war files, create ear files, creating stubs, skeletons, ftp etc., As long you can perform some operation in command line you can perform the same using ant but in a sequence. 


Tuesday, April 30, 2013

ADB is Not Recognized as an internal or external command Fix


ADB is Not Recognized as an internal or external command Fix


Some of you are facing problems with Path, because of that you will see the error as below. Even though it is basic lot of people asking this same question. Hence posting this tutorial to fix this error.

In Windows --> Click Start --> Run --> cmd

When you run adb in the command prompt you will see an error as below

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\MOHAMMED>adb
'adb' is not recognized as an internal or external command,
operable program or batch file.


To fix this error you need the Android SDK if you don't have it please follow the steps below,


Open the browser and navigate to http://developer.android.com/index.html


Click the Get the SDK as shown in the above image


Click Download the SDK as shown in the above image


Check the checkbox for the license agreement, Select 32 or 64 bit based on your operating systtem.
Click the download SDK link.

Wait patiently until the download is complete.

My machine is a 64 bit Windows, hence the file downloaded is adt-bundle-windows-x86_64-20130219.zip

The zip file contains the following folders eclipse & sdk.

I have extracted to the following location in my machine

Hence i have the following in the path 

C:\Users\MOHAMMED\Downloads\adt-bundle-windows-x86_64\sdk\platform-tools


C:\Users\MOHAMMED\Downloads\adt-bundle-windows-x86_64\sdk\tools


You can see that adb.exe is in the location C:\Users\MOHAMMED\Downloads\adt-bundle-windows-x86_64\sdk\platform-tools



Execute the following commands in the command prompt and run adb it will be recognized now.

set ANDROID_PLATFORM_TOOLS="C:\Users\MOHAMMED\Downloads\adt-bundle-windows-x86_64\sdk\platform-tools"

set ANDROID_TOOLS="C:\Users\MOHAMMED\Downloads\adt-bundle-windows-x86_64\sdk\tools"

set path=%path%;%ANDROID_PLATFORM_TOOLS%;%ANDROID_TOOLS%



To Fix it permanently set in the environment variable 


Right Click My Computer --> Click Properties 


Click Advanced System Settings 

Click Environment Variables


Click New  as below, 


Variable name: ANDROID_PLATFORM_TOOLS

Variable Value: C:\Users\MOHAMMED\Downloads\adt-bundle-windows-x86_64\sdk\platform-tools


Variable name: ANDROID_TOOLS

Variable Value: C:\Users\MOHAMMED\Downloads\adt-bundle-windows-x86_64\sdk\tools



Edit the Path variable if it exist, else create a new variable Path 

Variable name: Path

Variable Value: %Path%;%ANDROID_PLATFORM_TOOLS%;%ANDROID_TOOLS%



adb should be working on command prompt and 'adb' is not recognized as an internal or external command,
operable program or batch file is resolved now.