Archive for January, 2012

Axis2: Deploying webservice onto Axis2


1. Download Apache Axis2 war distribution and Axis2 Binary distribution as well. Axis2 can be downloaded from

http://axis.apache.org/axis2/java/core/download.cgi In this case, i used Axis2 1.6.1.

2. Download latest tomcat from http://tomcat.apache.org/ and unzip onto c:\tomcatx. Lets assume it is c:\tomcat7

3. Unzip Axis2 war distribution, and copy axis2.war onto C:\tomcat7\webapps

4. open run command and navigate to C:\tomcat7\bin and start the tomcat by typing startup.bat

5. Upon starting the tomcat, you can notice that the axis2.war file that was copied earlier, gets exploded into directory structure. Later on, we want .aar file to be copied to C:\tomcat7\webapps\axis2\WEB-INF\services to deploy a webservice onto the tomcat server

6. Now lets start to build .aar file to be deployed onto the above directory. For this unzip the Axis2 binary distribution and extract it to a directory lets say, c:\axis2161 (i downloaded axis2-1.6.1-bin and named it accordingly)

7. Now, do not forget to set AXIS2_HOME environmental variable to point to C:\axis2161\ and also add %AXIS2_HOME%  to the path.

8. Our goal is to deploy the quickstart sample app that gets shipped with Axis2, onto application server.

9. If you do not have ant installed on your machine, download ant from http://ant.apache.org/bindownload.cgi, in our case it is ant apache-ant-1.8.2-bin.zip

10. Set the environmental variable for ant, NOTE: Ant 1.8.2 has an issue with environmental variable setup, setup the system path variable directly as ;C:\ant182\bin;

11. Open run command, cd to c:\axis2161\samples\quickstart

12. quickstart example comes with ant build.xml, run the command ant generate.service. You should see build successful

c:\axis2161\samples\quickstart>ant generate.service
Buildfile: c:\axis2161\samples\quickstart\build.xml

compile.service:
[mkdir] Created dir: c:\axis2161\samples\quickstart\build\classes
[javac] c:\axis2161\samples\quickstart\build.xml:42: warning: ‘includeantrun
time’ was not set, defaulting to build.sysclasspath=last; set to false for repea
table builds
[javac] Compiling 1 source file to c:\axis2161\samples\quickstart\build\clas
ses
[javac] Note: c:\axis2161\samples\quickstart\src\samples\quickstart\service\
pojo\StockQuoteService.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.

generate.service:
[copy] Copying 1 file to c:\axis2161\samples\quickstart\build\classes
[jar] Building jar: c:\axis2161\samples\quickstart\build\StockQuoteService
.aar
[copy] Copying 1 file to c:\axis2161\repository\services

BUILD SUCCESSFUL
Total time: 9 seconds

13. Navigate to URL http://127.0.0.1:8080/axis2/axis2-admin/ and login with admin as login and axis2 as password

14. Under upload services at http://127.0.0.1:8080/axis2/axis2-admin/upload, upload the aar file generated in above step.

15. upon successful deployment of service, you should see the service under available services. If you are seeing the service to be in FAULT status, check my other post regarding version mismatch to resolve the issue.

16. Click on the service name, to get the WSDL

17. If you have SOAP UI or any other client, you can now test the generated WSDL and the services using the URL

http://127.0.0.1:8080/axis2/services/StockQuoteService?wsdl

 

 

 

 

Leave a comment

Error: org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation


Problem: Upon trying to deploy an aar file onto Axis2, service will be in fault status and the error log shows

Error: org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: samples.quickstart.service.pojo.StockQuoteService at org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:150) at org.apache.axis2.deployment.ServiceDeployer.deploy(ServiceDeployer.java:82) at org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136) at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:813) at org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144) at org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:370) at org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254) at org.apache.axis2.deployment.RepositoryListener.startListener(RepositoryListener.java:364) at org.apache.axis2.deployment.scheduler.SchedulerTask.checkRepository(SchedulerTask.java:73) at org.apache.axis2.deployment.scheduler.SchedulerTask.run(SchedulerTask.java:94) at org.apache.axis2.deployment.scheduler.Scheduler$SchedulerTimerTask.run(Scheduler.java:93) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) Caused by: org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: samples.quickstart.service.pojo.StockQuoteService at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:433) at org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:101) at org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:143) … 12 more Caused by: org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: samples.quickstart.service.pojo.StockQuoteService at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:397) … 14 more Caused by: org.apache.axis2.AxisFault: samples.quickstart.service.pojo.StockQuoteService at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at org.apache.axis2.util.Utils.getServiceClass(Utils.java:804) at org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:430) at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:389) … 14 more Caused by: java.lang.ClassNotFoundException: samples.quickstart.service.pojo.StockQuoteService at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.apache.axis2.util.Loader.loadClass(Loader.java:261) at org.apache.axis2.util.Loader.loadClass(Loader.java:229) at org.apache.axis2.util.Utils.getServiceClass(Utils.java:801) … 16 more

Solution:

This is a problem with the java version being used and initially i was setting my java home to jdk1.7, upon setting JAVA_HOME environmental variable to point to jdk1.6 version instead, recreate the aar file and deploy on AXIS2, service will be deployed without any issues and will not be in fault status

2 Comments

Attempted to lock an already-locked dir svn: Working copy


Subversion supports a command named “Cleanup”; it is used to release the locks on a project.

If you have faced with the above issue while no one has locked the project files, you can run this command and resolve the issue.
You do this in Eclipse by right clicking the project; then Team->Cleanup

Leave a comment

Firefox window.focus()


<body onload=”this.window.focus();” > is failing in Firefox 6.

1.  Go to  Firefox -> Options -> Content
2.  Make sure “Enable JavaScript” is turned on.
3.  Next to “Enable JavaScript”, click the “Advanced” button.
4.  Make sure that there is a check-mark in the box
[x]  Raise or lower windows

Leave a comment

How to display hibernate sql parameter values – P6Spy


1. Download P6Spy library

Get the “p6spy-install.jar“, you can download it from

  1. P6Spy official website.
  2. P6Spy at Sourceforge.net

2. Extract it

Extract the p6spy-install.jar file, look for p6spy.jar and spy.properties

3. Add library dependency

Add p6spy.jar into your project library dependency along with commons-dbcp-1.4.jar

4. Modify P6Spy properties file

Modify your database configuration file. You need to replace your existing JDBC driver with P6Spy JDBC driver – ” com.p6spy.engine.spy.P6SpyDriver<!– SPY SETUP–>
<bean id=”dataSource” destroy-method=”close”>
<constructor-arg>
<ref local=”myDataSourceTarget”/>
</constructor-arg>
</bean>

<bean id=”myDataSourceTarget” destroy-method=”close”>

<property name=”driverClassName”>
<value>com.p6spy.engine.spy.P6SpyDriver</value>
</property>

<property name=”url”>
<value>jdbc:oracle:thin:@hostname:port:servicename</value>
</property>

<property name=”username”>
<value>username</value>
</property>

<property name=”password”>
<value>pw</value>
</property>

</bean>”

5. Modify P6Spy properties file

Modify the P6Spy properties file – “spy.properties# useful for debugging sql

module.log=com.p6spy.engine.logging.P6LogFactory

executionthreshold=
outagedetection=false
outagedetectioninterval=
filter=false
include     =
exclude     =
sqlexpression =
autoflush   = true
dateformat=
includecategories=
excludecategories=info,debug,result,batch

stringmatcher=
stacktraceclass=

reloadproperties=false
reloadpropertiesinterval=60

useprefix=false

appender=com.p6spy.engine.logging.appender.FileLogger
logfile     = c:\\temp\\spy.log

append=false

log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=p6spy – %m%n

log4j.logger.p6spy=DEBUG,STDOUT

realdriver=oracle.jdbc.driver.OracleDriver”

Change the Log file location
Change the log file location in logfile property, all SQL statements will log into this file.

Windows

logfile     = c:/spy.log

*nix

logfile     = /srv/log/spy.log

6. Copy “spy.properties” to project classpath

Copy “spy.properties” to your project root folder, make sure your project can locate “spy.properties”, else it will prompt “spy.properties” file not found exception.

7. Done

Run your application and do some database transaction, you will notice all the SQL statements sent from application to database will be logged into a file you specified in “spy.properties”.

Sample log file as following.

insert into stock_transaction (CHANGE, CLOSE, DATE, OPEN, STOCK_ID, VOLUME)
values (?, ?, ?, ?, ?, ?)|
insert into stock_transaction (CHANGE, CLOSE, DATE, OPEN, STOCK_ID, VOLUME)
values (10.0, 1.1, '2009-12-30', 1.2, 11, 1000000)

Conclusion

P6Spy is really useful in reducing the developers’ debugging time. As long as your project is using JDBC driver for connection , P6Spy can fit into it and log all SQL statements and parameter values for you.

3 Comments