Showing posts with label compilation. Show all posts
Showing posts with label compilation. Show all posts

Tuesday, July 16, 2013

WSConsume Task and Jaxb Issues

My experience with WSDL and JAXB is not much. So I face various issues while working on those WSDL once a while. Though most of the issues have wide support on internet but this issue took plenty of time to find the solution.

Following is my ant entry to run the wsconsume utility.

<wsconsume keep="true" binding="TEST_bindings.xml"   wsdlLocation="/META-INF/wsdl/TEST/TEST.wsdl"  destdir="${TEST.3.0.bin}" sourcedestdir="${TEST.3.0.src}"  wsdl="${TEST.3.0.wsdl}" additionalHeaders="true"   target="${wsdl.jaxws.targetver}"/>

Content of TEST_binding xml are as following
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
                xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
                xmlns:xs="http://www.w3.org/2001/XMLSchema">
                <jxb:bindings schemaLocation="TEST.wsdl#types?schema1">
                                <jxb:schemaBindings>
                                                <jxb:package name="com.test " />
                                </jxb:schemaBindings>
                                <jxb:bindings node=                "//xs:complexType[@name='test']/xs:simpleContent/xs:extension[@base='s:string']/xs:attribute[@name='value']">
                                                <jxb:property name="testValue" />
                                </jxb:bindings>
                </jxb:bindings>
</jxb:bindings>
My file TEST.wsdl is stored in /META-INF/wsdl/TEST folder. So it is kind of all messed up from the start. Developer has already built a monster and I had to deal with it without knowing much about functionality.

When I ran the build xml with the following set up, I encountered the following issue.
"<COMPLETE_PATH>/TEST.wsdl" is not a part of this compilation. Is this a mistake for "file: <COMPLETE_PATH>/TEST.wsdl #types?schema1"? 

I found few links which suggested me to copy the WSDL under wsdl folder.
So now I moved WSDL files to /META-INF/wsdl/TEST/wsdl folder.

On Rerunning the application, I got file not found exception. As my application was already messed up, so I messed up a little more, and backed up the files in /META-INF/wsdl/TEST/wsdl and /META-INF/wsdl/TEST/ folders.

I reran the application, but again I faced same issues. So with some help of google sir, I got one alternative of TEST.wsdl#types?schema1. So I attempted that.
I replaced TEST.wsdl#types?schema1 test to TEST.wsdl#types1, and run the application again.

This time I did not get the compilation error. Now error was different. Error was as mentioned below.
[wsconsume] org.apache.cxf.tools.common.ToolException: java.lang.reflect.UndeclaredThrowableException
[wsconsume]     at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:279)
[wsconsume]     at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
[wsconsume]     at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
 [wsconsume] Caused by: java.lang.NoSuchMethodException: javax.xml.bind.annotation.XmlElementRef.required()
[wsconsume]     at java.lang.Class.getDeclaredMethod(Unknown Source)

It means that required method did not exist in the library files of jaxb. Java 6 works older version of JAXB, and Java 7 works with latest version of jaxb. You can choose to either use Java 7 or provide endorsed libraries to java. For me endorsed library path did not work, so I ran the application on Java 7 and it compiled and created respective jar to me.


I know, I have not given reasons and facts, but still I tried to write down all the problems I faced. Hope helps.

Wednesday, May 22, 2013

Jboss Esb - Imported file can not be resolved


I was working on an application that was built in Jboss Esb. I changed my source code and uploaded the jar, which was built using ant files.

As soon as I uploaded the file, Jboss bombed while starting it. It threw the exception mentioned below
The import com.XYZ.adapter.abc cannot be resolved.

I am new to JBOSS Esb. It was an urgent requirement and I needed to fix it ASAP. I did not have any idea to solve the issue in JBOSS ESB. I was cusring JBOSS and developer who thought to use the application. So I had to depend on Mr Reliable Google.

I search on google, and most of the people said that I have not build the jar in the correct manner. Whereas I was sure that I have build it correctly. I researched more. When Google stopped responding to my queries with satisfactory answers, then I started searching the answers at my own, and finally I found the solution for the problem.

I found that my class file did not have corresponding import statement(Which I lost while merging the file with version control tool). But my question was then how I got jar file. So I troubleshooted the ant scripts and found following.

-> My ant script was not deleting old class files. So instead compiling java source file, it was zipping already compiled files.
-> My Eclipse project did not show error, because auto building was disabled.
-> My Eclipse project and Ant Script was building class file at the same location. I.e. Both were building at ${basedir}/bin.

Keep it in mind, whatever technology you are using, it is based on one specific language. Irrespective of technology, the language concepts will always hold true.

The import com.XYZ.adapter.abc cannot be resolved.

Error listed above shows that there are compilation problems with the jar, so rebuild the jar with additional care.