glassfish
  1. glassfish
  2. GLASSFISH-18622

Container incorrectly logs WebApplicationException thrown by JAX-RS endpoint

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 3.1.1
    • Fix Version/s: None
    • Component/s: ejb_container
    • Labels:
      None

      Description

      Hi there,

      I have a REST Webservice running on GlassFish v3.1.1.
      The project contains an EJB which hosts the REST Service. When I let the container throw a new WebApplicationException(Status.NOT_FOUND), the webpage nicely shows that the page cannot be found. The EJB Container however, logs the stacktrace of the WebApplicationException which I do not want.

      Here is a URL I found containing the same issue:
      http://jersey.576304.n2.nabble.com/EJBException-throwed-when-using-WebApplicationException-td4755164.html

      My stack trace:

      [#|2012-04-11T15:57:54.295+0200|WARNING|oracle-glassfish3.1.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=79;_ThreadName=Thread-2;|A system exception occurred during an invocation on EJB RelatieResource method public nl.onvz._201012.xmlschema.cannoniek.relatie.RelatieBericht nl.onvz.relatie.services.glassfish.relatieservice.resources.RelatieResource.getRelatie(java.lang.String) throws javax.xml.datatype.DatatypeConfigurationException
      javax.ejb.EJBException
      at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5193)
      at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5091)
      at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
      at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
      at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
      at $Proxy124.getRelatie(Unknown Source)
      at nl.onvz.relatie.services.glassfish.relatieservice.resources._EJB31_GeneratedRelatieResourceIntf__Bean_.getRelatie(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
      at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
      at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
      at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
      at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
      at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
      at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
      at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
      at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
      at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
      at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:232)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:722)
      Caused by: javax.ws.rs.WebApplicationException
      at nl.onvz.relatie.services.glassfish.relatieservice.resources.RelatieResource.getRelatie(RelatieResource.java:69)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
      at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
      at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5366)
      at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
      at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
      at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
      at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5338)
      at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5326)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
      ... 48 more

      #]

      Kind regards,

      Rens Groenveld

        Activity

        Hide
        marina vatkina added a comment -

        Is WebApplicationException designated as an application exception according to the EJB spec rules?

        Show
        marina vatkina added a comment - Is WebApplicationException designated as an application exception according to the EJB spec rules?
        Hide
        marina vatkina added a comment -

        WebApplicationException is a subclass of the RuntimeException and as such follows the rules in the EJB spec (one of them, it should be logged)

        Show
        marina vatkina added a comment - WebApplicationException is a subclass of the RuntimeException and as such follows the rules in the EJB spec (one of them, it should be logged)
        Hide
        marina vatkina added a comment -

        To mark WebApplicationException as an application exception, add this ejb-jar.xml to your EJB module:

        <?xml version="1.0" encoding="UTF-8"?>
        <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
        <assembly-descriptor>
        <application-exception>
        <exception-class>javax.ws.rs.WebApplicationException</exception-class>
        <rollback>true</rollback>
        </application-exception>
        </assembly-descriptor>
        </ejb-jar>

        Show
        marina vatkina added a comment - To mark WebApplicationException as an application exception, add this ejb-jar.xml to your EJB module: <?xml version="1.0" encoding="UTF-8"?> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd "> <assembly-descriptor> <application-exception> <exception-class>javax.ws.rs.WebApplicationException</exception-class> <rollback>true</rollback> </application-exception> </assembly-descriptor> </ejb-jar>
        Hide
        RensGroenveld added a comment -

        Hi there,

        I just solved this about 30 minutes ago by creating an exception class that extends the WebApplicationException.

        Then, I annotate that class with the @ApplicationException tag.

        Works too

        Many thanks!

        Show
        RensGroenveld added a comment - Hi there, I just solved this about 30 minutes ago by creating an exception class that extends the WebApplicationException. Then, I annotate that class with the @ApplicationException tag. Works too Many thanks!

          People

          • Assignee:
            marina vatkina
            Reporter:
            RensGroenveld
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: