Doug Kohlert wrote:
> Can you include your custom exception class?
>
> Amit Soni wrote:
>
>> Hi all,
>>
>> Can any body guid me how to throw custom exception from my web
>> service interface api. i.e. i have one or method
>> wich throws custom exception in this case wscompile throws following
>> exception:
>>
>> [wscompile] class java.lang.StackTraceElement does not have a public
>> accessible empty constructor
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiStructure.initialize(RmiStructure.java:109)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiStructure.forClass(RmiStructure.java:32)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiStructure.modelTypeSOAP(RmiStructure.java:41)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiTypeModeler.collectMembers(RmiTypeModeler.java:204)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiTypeModeler.modelTypeSOAP(RmiTypeModeler.java:164)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiTypeModeler.modelTypeSOAP(RmiTypeModeler.java:107)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiTypeModeler.fillInStructure(RmiTypeModeler.java:668)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiTypeModeler.modelTypeSOAP(RmiTypeModeler.java:189)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.ExceptionModeler.createSOAPMember(ExceptionModeler.java:206)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.ExceptionModeler.addMessage(ExceptionModeler.java:239)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.ExceptionModeler.createFault(ExceptionModeler.java:126)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.ExceptionModelerBase.modelException(ExceptionModelerBase.java:91)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiModeler.processRpcEncodedMethod(RmiModeler.java:1079)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiModeler.processMethod(RmiModeler.java:838)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiModeler.processInterface(RmiModeler.java:748)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiModeler.modelPort(RmiModeler.java:683)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiModeler.buildEncodedModel(RmiModeler.java:523)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.modeler.rmi.RmiModeler.buildModel(RmiModeler.java:459)
>>
>> [wscompile] at
>> com.sun.xml.rpc.processor.config.ModelInfo.buildModel(ModelInfo.java:88)
>> [wscompile] at
>> com.sun.xml.rpc.processor.Processor.runModeler(Processor.java:63)
>> [wscompile] at
>> com.sun.xml.rpc.tools.wscompile.CompileTool.run(CompileTool.java:714)
>> [wscompile] at com.sun.xml.rpc.util.ToolBase.run(ToolBase.java:43)
>> [wscompile] at
>> com.sun.xml.rpc.tools.ant.Wscompile.execute(Wscompile.java:746)
>> [wscompile] at
>> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>> [wscompile] at org.apache.tools.ant.Task.perform(Task.java:364)
>> [wscompile] at org.apache.tools.ant.Target.execute(Target.java:341)
>> [wscompile] at
>> org.apache.tools.ant.Target.performTasks(Target.java:369)
>> [wscompile] at
>> org.apache.tools.ant.Project.executeTarget(Project.java:1214)
>> [wscompile] at
>> org.apache.tools.ant.Project.executeTargets(Project.java:1062)
>> [wscompile] at org.apache.tools.ant.Main.runBuild(Main.java:673)
>> [wscompile] at org.apache.tools.ant.Main.startAnt(Main.java:188)
>> [wscompile] at
>> org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
>> [wscompile] at
>> org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
>> [wscompile] error: class java.lang.StackTraceElement does not have a
>> public accessible empty constructor
>>
>> my wscompile task in ant is:
>>
>> <wscompile
>> server="true"
>> model="${build.ws.modelname}"
>> optimize="false"
>> debug="true"
>> verbose="true"
>> version="false"
>> xPrintStackTrace="true"
>> config="${config.ws.wsconfigfile}">
>> <classpath>
>> <path refid="project.classpath"/>
>> <path refid="ws.classpath"/>
>> </classpath>
>> </wscompile>
>>
>> Thanks,
>> Amit Soni
>>
>> ----------------------------------------------------------
>> Netcore Solutions Pvt. Ltd.
>> Website: http://www.netcore.co.in
>> Spamtraps: http://cleanmail.netcore.co.in/directory.html
>>
>> Support FAQ : http://support.netcore.co.in/
>> ----------------------------------------------------------
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
>> For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>>
>
My custom exception calss is,
/**
*
*/
package com.netcore.psmw.common;
import java.io.PrintStream;
import java.io.PrintWriter;
/**
* @author root
*
*/
public class PSMWException extends Exception {
private String errorCode; // Error code of the error
protected String errorDescription; // Error description
private String errorSource; // Source program of
exception
private Integer severity; // Severity of the Error
private Throwable cause; // The exception thrown.
/**
* The PSMWException constructor
*/
public PSMWException() {
super();
}
/**
* This is an Exception thrown with only the Error Code
* @param message
*/
public PSMWException(String errCode) {
super(errCode);
this.errorCode = errCode;
}
/**
* @param error Code
* @param error Description
*/
public PSMWException(String errCode,
String errMsg)
{
super(errCode);
this.errorCode = errCode;
this.errorDescription = errMsg;
}
/**
* @param cause
*/
public PSMWException(Throwable cause) {
super(cause);
}
/**
* @param error Code
* @param error Description
* @param error Source (method/class)
*/
public PSMWException(String errCode,
String errMsg,
String errSource)
{
super(errCode);
this.errorCode = errCode;
this.errorDescription = errMsg;
this.errorSource = errSource;
}
/**
* @param error Code
* @param error Severity
*/
public PSMWException(String errCode,
int iSevere)
{
super(errCode);
this.errorCode = errCode;
this.severity = iSevere;
}
/**
* @param error Code
* @param error Description
* @param error Severity
*/
public PSMWException(String errCode,
String errSource,
int iSevere)
{
super(errCode);
this.errorCode = errCode;
this.errorSource = errSource;
this.severity = iSevere;
}
/**
* @param error Code
* @param error Description
* @param error Source (method/class)
* @param error Severity
*/
public PSMWException(String errCode,
String errMsg,
String errSource,
int iSevere)
{
super(errCode);
this.errorCode = errCode;
this.errorDescription = errMsg;
this.errorSource = errSource;
this.severity = iSevere;
}
/**
* @param message
* @param cause
*/
public PSMWException(String errCode,
Throwable cause) {
super(errCode, cause);
this.errorCode = errCode;
this.cause = cause;
}
/**
* @param errorCode
* @param errorDescriptiom
* @param cause
*/
public PSMWException(String errCode,
String description,
Throwable cause) {
super(errCode, cause);
this.errorCode = errCode;
this.errorDescription = description;
this.cause = cause;
}
/**
* @param errorCode
* @param errorDescription
* @param errorSource
* @param cause
*/
public PSMWException(String errCode,
String description,
String errSource,
Throwable cause) {
super(errCode, cause);
this.errorCode = errCode;
this.errorDescription = description;
this.errorSource = errSource;
this.cause = cause;
}
/**
* @param errorCode
* @param errorSource
* @param Error Severity
* @param cause
*/
public PSMWException(String errCode,
String errSource,
int severity,
Throwable cause) {
super(errCode, cause);
this.errorCode = errCode;
this.errorSource = errSource;
this.severity = severity;
this.cause = cause;
}
/**
* @param errorDescription
* @param errorSource
* @param Error Severity
* @param cause
*/
public PSMWException(String errCode,
String description,
String errSource,
int severity,
Throwable cause) {
super(errCode, cause);
this.errorCode = errCode;
this.errorDescription = description;
this.errorSource = errSource;
this.severity = severity;
this.cause = cause;
}
/**
* Returns Exception Error Code
* @return String
*
*/
public String getErrorCode() {
return this.errorCode;
}
/**
* Returns Exception Error Description
* @return String
*
*/
public String getErrorDescription() {
return this.errorDescription;
}
/**
* Returns Exception Error Description
* @return String
*
*/
public String getErrorSource() {
return this.errorSource;
}
/**
* Returns Exception Error Severity
* @return int
*
*/
public Integer getErrorSeverity() {
return this.severity;
}
/**
* Returns the cause of this exception.
* @return cause of the exception, if available, else null
*
*/
public Throwable getCause() {
return this.cause;
}
*When i comment this method then it works fine.*
/**
* Prints the stack trace to PrintStream.
* @param ps PrintStream used for the output.
*/
public void printStackTrace(PrintStream ps) {
if (null != cause) {
cause.printStackTrace(ps);
}
super.printStackTrace(ps);
}
/**
* Prints the stack trace to PrintWriter.
* @param pw PrintWriter used for the output.
*/
public void printStackTrace(PrintWriter pw) {
if (null != cause) {
cause.printStackTrace(pw);
}
super.printStackTrace(pw);
}
/**
* Prints the stack trace to standard error stream
* @param
*/
public void printStackTrace() {
printStackTrace(System.err);
}
}
----------------------------------------------------------
Netcore Solutions Pvt. Ltd.
Website:
http://www.netcore.co.in
Spamtraps:
http://cleanmail.netcore.co.in/directory.html
Support FAQ :
http://support.netcore.co.in/
----------------------------------------------------------