Tuesday, January 11, 2011

Develop Web Service With Axis2 #8 - Troubleshooting while working with Axis2

My Environment:
JDK  v1.6.x
Axis2  v1.5.4
Ant  v1.7.1
Hibernate  v3.3.1
Tomcat  v6.0.26
Weblogic v1.03

1) tomcat can not start up properly if deploy axis2 project to tomcat

I got the errors as follows

SEVERE: Error in dependencyCheck
java.util.zip.ZipException: invalid bit length repeat
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:147)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:146)

or

Jan 9, 2011 7:35:42 PM org.apache.catalina.core.StandardContext start
SEVERE: Error in dependencyCheck
java.util.zip.ZipException: too many length or distance symbols
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:147)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:146)

or

org.apache.axis2.deployment.DeploymentException: A ClassNotFoundException error occurred in loading the message receiver

Solution:
You must follow up the build.xml provided by axis2 strictly if you write your own build.xml

For example,

<copy todir="${build.dist.dir}/WEB-INF/lib" filtering="true" overwrite="yes">

if filtering="true", the jar file will be not unzipped properly if pack in war file.

2) can not load hibernate

My .aar structure is as follows

.aar
      /com       --- classes files
      /lib          --- hibernate jar files and other the 3rd jar files
      /META-INF
      hibernate.cfg.xml
      log4j.properties


in services.xml, add the following configuration

<parameter name="ServiceTCCL">composite</parameter>

if using this configuration, axis2 will load jar files under lib folder inside aar


3) log4j

Finally, I found if put log4j.properties in aar, it will not work, the correct location is %WAR%\WEB-INF\classes

4)  jar conflict if deploying to weblogic

These are well-known exceptions if deloying axis2 project into weblogic.

org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken


Solution:
*change the war file struecture

WAR
   |- axis2-web
   |- WEB-INF
          |- classes
                  |- com/xxx    Here is your DAO, business classes, utils,etc
                  log4j.properties
                  hibernate.cfg.xml
                  your own other properties 
          |- conf
                   axis2.xml
          |- lib
                   all axis2-related jar files
                   log4j-related jar files
                   hibernate-related jar files
                   other 3rd party jar files
           |- modules
           |- services
                    yourservice.aar     Only inlcude skeleton classes here, almost generated by axis2
                            com/...../xxxMessageReceiverInOut.class
                            com/...../xxxSkeleton.class
                            META-INF\services.xml
                            META-INF\wsdl.list
                            META-INF\xxxx.wsdl
           web.xml
           weblogic.xml


* in weblogic.xml, should configure

    <container-descriptor>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-descriptor>

* in hibernate.cfg.xml, it is not necessary to configure 'hibernate.query.factory_class'

there is a jar ANTLR conflict between hibernate v3.x and weblogic, so someone suggests to configure explicitly 'hibernate.query.factory_class'

for hibernate v3.x query translator,
hibernate.query.factory_class= org.hibernate.hql.ast.ASTQueryTranslatorFactory
for hibernate v2.x query translator
hibernate.query.factory_class= org.hibernate.hql.classic.ClassicQueryTranslatorFactory

It is NOT necessary to do so.

<prefer-web-inf-classes> will ensure weblogic load %WAR%\WEB-INF\lib , let hibernate auto-choose which query translator to use.


5) can not find aar/mar file if deploying to weblogic

need to add aar file name, or mar file name in \services\services.list and \mrodules\modules.list

6) cannot show custom WSDL file, always show auto-generated WSDL file

in your own .aar\META-INF folder to add a file named wsdl.list , and put your wsdl file name in it.

in services.xml ,  <parameter name="useOriginalwsdl">true</parameter>

7) xerces jar file conflict if deploying to weblogic

java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.xerces.dom.ElementImpl.getSchemaTypeInfo()Lorg/w3c/dom/TypeInfo;" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, org/apache/xerces/dom/ElementImpl, and the class loader (instance of <bootloader>) for interface org/w3c/dom
/Element have different Class objects for the type org/w3c/dom/TypeInfo used in the signature

Solution: remove xercesImpl-2.8.1.jar from axis2\WEB-INF\lib

No comments:

Post a Comment