[jboss-user] [JBossWS] - java-wsdl conversion for Custom Exception

rt_s do-not-reply at jboss.com
Thu Jul 13 05:11:11 EDT 2006


Below is the scaled down version of a service that i am trying to develop. My service throws a custom exception. However, i get an error when trying to generate a WSDL for this SEI.

SEI


  | package com.testservice;
  | 
  | import java.rmi.Remote;
  | import java.rmi.RemoteException;
  | 
  | import com.testservice.exception.MyCustomException;
  | 
  | public interface ExceptionService extends Remote 
  | {
  | 	public void throwCustomException() throws MyCustomException, RemoteException;
  | }
  | 


MyCustomException class 


  | package com.testservice.exception;
  | 
  | public class MyCustomException extends Exception 
  | {
  | 	private int errorCode;
  | 	
  | 	private String customMsg;
  | 	
  | 	private String[] arr;
  | 
  | 	public MyCustomException() 
  | 	{
  | 		super();
  | 	}
  | 
  | 	public MyCustomException(int errorCode, String customMsg, String[] arr) {
  | 		super();
  | 
  | 		this.errorCode = errorCode;
  | 		this.customMsg = customMsg;
  | 		this.arr = arr;
  | 	}
  | 
  | 	public String[] getArr() {
  | 		return arr;
  | 	}
  | 
  | 	public void setArr(String[] arr) {
  | 		this.arr = arr;
  | 	}
  | 
  | 	public String getCustomMsg() {
  | 		return customMsg;
  | 	}
  | 
  | 	public void setCustomMsg(String customMsg) {
  | 		this.customMsg = customMsg;
  | 	}
  | 
  | 	public int getErrorCode() {
  | 		return errorCode;
  | 	}
  | 
  | 	public void setErrorCode(int errorCode) {
  | 		this.errorCode = errorCode;
  | 	}
  | 	
  | }
  | 


ANT for generating stubs


  | 	<target name="generate_stubs" depends="prepare">
  | 		<taskdef name="wstools" classname="org.jboss.ws.tools.ant.wstools">
  | 			<classpath refid="client.path"/>
  | 		</taskdef>
  | 		<wstools dest="${configs.dir}" config="${basedir}/wstools-config.xml"/>
  | 	</target>
  | 


WSTools Config XML


  | <configuration xmlns="http://www.jboss.org/jbossws-tools">
  | 	<java-wsdl>
  | 		<service name="ExceptionService" style="rpc" endpoint="com.testservice.ExceptionService"/>
  | 		<namespaces target-namespace="http://com.testservice" type-namespace="http://com.testservice/types"/>
  | 		<mapping file="jaxrpc-mapping.xml"/>
  | 		<webservices servlet-link="ExceptionService"/>
  | 	</java-wsdl>
  | </configuration>
  | 


And the error i get on running the ANT is ...

  | generate_stubs:
  |   [wstools] log4j:WARN No appenders could be found for logger (org.jboss.ws.tools.WSTools).
  |   [wstools] log4j:WARN Please initialize the log4j system properly.
  |   [wstools] java.lang.IllegalArgumentException: Could not locate a constructor with the following types: class com.testservice.exception.MyCustomException [class [Ljava.lang.String;, class java.lang.String, int]
  |   [wstools]     at org.jboss.ws.tools.schema.SchemaTypeCreator.getComplexTypeForJavaException(SchemaTypeCreator.java:722)
  |   [wstools]     at org.jboss.ws.tools.schema.SchemaTypeCreator.getType(SchemaTypeCreator.java:268)
  |   [wstools]     at org.jboss.ws.tools.schema.SchemaTypeCreator.generateType(SchemaTypeCreator.java:133)
  |   [wstools]     at org.jboss.ws.tools.JavaToXSD.generateForSingleType(JavaToXSD.java:109)
  |   [wstools]     at org.jboss.ws.tools.helpers.JavaToWSDLHelper.generateType(JavaToWSDLHelper.java:555)
  |   [wstools]     at org.jboss.ws.tools.helpers.JavaToWSDLHelper.generateTypesForXSD(JavaToWSDLHelper.java:178)
  |   [wstools]     at org.jboss.ws.tools.JavaToWSDL11.handleJavaToWSDLGeneration(JavaToWSDL11.java:241)
  |   [wstools]     at org.jboss.ws.tools.JavaToWSDL11.generate(JavaToWSDL11.java:168)
  |   [wstools]     at org.jboss.ws.tools.JavaToWSDL.generate(JavaToWSDL.java:318)
  |   [wstools]     at org.jboss.ws.tools.helpers.ToolsHelper.handleJavaToWSDLGeneration(ToolsHelper.java:122)
  |   [wstools]     at org.jboss.ws.tools.WSTools.process(WSTools.java:129)
  |   [wstools]     at org.jboss.ws.tools.WSTools.generate(WSTools.java:119)
  |   [wstools]     at org.jboss.ws.tools.ant.wstools.execute(wstools.java:103)
  |   [wstools]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
  |   [wstools]     at org.apache.tools.ant.Task.perform(Task.java:364)
  |   [wstools]     at org.apache.tools.ant.Target.execute(Target.java:341)
  |   [wstools]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
  |   [wstools]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
  |   [wstools]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
  |   [wstools]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
  |   [wstools]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
  |   [wstools]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
  |   [wstools]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
  |   [wstools]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
  |   [wstools]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
  | 

(I have a JBoss-4.0.4 setup running on Java5)

I can solve this problem if i change the order of parameters to parameterized constructor of MyCustomException as follows:

  | 	public MyCustomException(String[] arr, String customMsg, int errorCode) {
  | 		super();
  | 
  | 		this.errorCode = errorCode;
  | 		this.customMsg = customMsg;
  | 		this.arr = arr;
  | 	}
  | 

I would like to know
1) Is this an expected behavior or bug?
2) If it is an expected behavior, are there any guidelines for the order in which parameters to a parameterized constructor are passed?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957660#3957660

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957660



More information about the jboss-user mailing list