cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kaleb Walton <kdwal...@us.ibm.com>
Subject Re: Custom Exceptions using Simple Server
Date Fri, 02 Nov 2007 19:15:42 GMT

Well, I found that I can do something like this:

  <simple:server id="testServiceServer"
serviceClass="a.b.c.services.TestService" serviceBean="#testService"
address="/Test">
    <simple:properties>
      <entry key="jaxb.additionalContextClasses">
        <bean class="a.b.c.services.ClassArrayFactoryBean">
          <property name="classNames">
            <list>
              <value>a.b.c.services.ServiceException</value>
            </list>
          </property>
        </bean>
      </entry>
    </simple:properties>
    <simple:serviceBean>
      <bean class="a.b.c.services.TestServiceImpl"/>
    </simple:serviceBean>
  </simple:server>

Unfortunately now I get:

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1
counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default constructor.
        this problem is related to the following location:
                at java.lang.StackTraceElement
                at public java.lang.StackTraceElement[]
java.lang.Throwable.getStackTrace()
                at java.lang.Throwable
                at java.lang.Exception
                at a.b.c.services.ServiceException

Any way to get the simple server not to blow up if using custom exceptions
in the service interfaces?

Regards,
Kaleb


|------------>
| From:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Kaleb Walton/Southfield/IBM@IBMUS                                                     
                                                           |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |cxf-user@incubator.apache.org                                                         
                                                           |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |11/02/2007 02:32 PM                                                                   
                                                           |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Custom Exceptions using Simple Server                                                 
                                                           |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|







I've been digging around trying to find a way to enable custom exceptions
to be thrown using the Simple Server and am pretty stumped.

I'm trying to enable ServiceExceptions to be thrown from one of my service
interfaces but when I call it I get an exception such as:

Caused by: javax.xml.bind.MarshalException
 - with linked exception:
[javax.xml.bind.JAXBException: a.b.c.services.ServiceException is not known
to this context]
        at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:295)
        at
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221)
        at
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:91)

        at
org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:192)

        at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:167)

        ... 44 more

I tried adding a WebFaultOutInterceptor to my interceptor chain but this
error occurs further up in the chain:

INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Threw exception
        at
org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:101)

        at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:90)

        at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:63)

        at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56)

        at
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)

        at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92)

        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)

        at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:73)

        at
org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDestination.java:79)

        at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:235)

        at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:140)

        at
org.apache.cxf.transport.servlet.CXFServlet.invoke(CXFServlet.java:278)
        at
org.apache.cxf.transport.servlet.CXFServlet.doPost(CXFServlet.java:256)
        ...

I found http://issues.apache.org/jira/browse/CXF-340 which suggests that
this error can be resolved for the JAX-WS web services but is there a way
to do it with the simple server?

The simple server is so nice in terms of configuration that I'd hate to
have to switch over to JAX-WS - especially since we will have so many
services! In addition, the simple server can keep our stuff completely
annotation free. These services are not only going to be used for the web
and having to include the libraries that accompany those annotations would
be an annoyance to the rest of our development team.

Please let me know if this is not enough information to provide
suggestions.Thanks!

Regards,
Kaleb
Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message