A summary of what I discussed with Romain on IRC:

According to the JavaEE spec only checked Exceptions and RuntimeExceptions 
which are marked as @ApplicationException must get transfered over @Remote 
(regardless if this is a real client or even inside the same JVM). For others 
the Exception gets re-packaged into a javax.ejb.EJBException.

TomEE takes some internal Exceptions and additionally transfers them along to 
the client. This is mainly as some TCKs are strictly speaking broken as they 
test for DefinitionException, DeploymentException, OptimisticLockException and 
other internal exceptions (which are RuntimeExceptions). But this only works as 
long as there is a cdi and jpa spec API jars are available on the client. 


Since the TomEE server doesn't know what is on the client it usually wraps 
Exceptions into a ThrowableArtifact which contains the original Exception 
(basically manually serialized as byte[]) plus also the String representation. 
If it is not possible to deserialize the original Exception (because 
javax.persistence.OptimisticLockException.class is not available on the client) 
then it falls back to unwrapping to an EJBException plus adding the String 
information of the original Exception.

TomEE did this wrapping only for custom Exceptions so far. But it also needs to 
provide the same for DefinitionException and DeploymentException as this might 
contain custom MyVersyOwnOnlyOnServerExtensionException which got thrown by an 
Extension on the server. And this will get added as Cause to the 
DeploymentException. So even if we don't serialize a 
WebBeansDeplyomentException but a spec DeploymentException instead then we 
still have the problem with all the containing causes which are not available 
on the client side (and thus will make the app fail with a 
ClassNotFoundException).

LieGrue,
strub





> On Saturday, 14 March 2015, 22:01, Romain Manni-Bucau <[email protected]> 
> wrote:
> > Please revert you just broke all arquillian tests relying on a remote
> container using OWB (tomee in my case)...and real use cases as well but not
> yet hit it.
> 
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github 
> <https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
> 
> 
> ---------- Forwarded message ----------
> From: <[email protected]>
> Date: 2015-03-14 21:58 GMT+01:00
> Subject: svn commit: r1666745 - in
> /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception:
> ./ helper/
> To: [email protected]
> 
> 
> Author: struberg
> Date: Sat Mar 14 20:58:32 2015
> New Revision: 1666745
> 
> URL: http://svn.apache.org/r1666745
> Log:
> OWB-1039 make revert writeReplace and make ExceptionMessageBuilder
> serializable
> 
> Modified:
> 
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/DuplicateDefinitionException.java
> 
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/InconsistentSpecializationException.java
> 
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansConfigurationException.java
> 
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansDeploymentException.java
> 
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ExceptionMessageBuilder.java
> 
> Modified:
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/DuplicateDefinitionException.java
> URL:
> http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/DuplicateDefinitionException.java?rev=1666745&r1=1666744&r2=1666745&view=diff
> ==============================================================================
> ---
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/DuplicateDefinitionException.java
> (original)
> +++
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/DuplicateDefinitionException.java
> Sat Mar 14 20:58:32 2015
> @@ -22,8 +22,6 @@ import javax.enterprise.inject.spi.Defin
> import org.apache.webbeans.exception.helper.DescriptiveException;
> import org.apache.webbeans.exception.helper.ExceptionMessageBuilder;
> 
> -import java.io.ObjectStreamException;
> -
> public class DuplicateDefinitionException extends DefinitionException
> implements DescriptiveException
> {
>      private static final long serialVersionUID = 2312285271502063304L;
> @@ -64,8 +62,4 @@ public class DuplicateDefinitionExceptio
>          return msg.getAdditionalInformation(super.getLocalizedMessage());
>      }
> 
> -    private Object writeReplace() throws ObjectStreamException
> -    {
> -        return new DefinitionException(getMessage(), getCause());
> -    }
> }
> 
> Modified:
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/InconsistentSpecializationException.java
> URL:
> http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/InconsistentSpecializationException.java?rev=1666745&r1=1666744&r2=1666745&view=diff
> ==============================================================================
> ---
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/InconsistentSpecializationException.java
> (original)
> +++
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/InconsistentSpecializationException.java
> Sat Mar 14 20:58:32 2015
> @@ -22,8 +22,6 @@ import javax.enterprise.inject.spi.Defin
> import org.apache.webbeans.exception.helper.DescriptiveException;
> import org.apache.webbeans.exception.helper.ExceptionMessageBuilder;
> 
> -import java.io.ObjectStreamException;
> -
> public class InconsistentSpecializationException extends
> DefinitionException implements DescriptiveException
> {
>      private static final long serialVersionUID = 5398575103682514128L;
> @@ -63,8 +61,4 @@ public class InconsistentSpecializationE
>          return msg.getAdditionalInformation(super.getLocalizedMessage());
>      }
> 
> -    private Object writeReplace() throws ObjectStreamException
> -    {
> -        return new DefinitionException(getMessage(), getCause());
> -    }
> }
> 
> Modified:
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansConfigurationException.java
> URL:
> http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansConfigurationException.java?rev=1666745&r1=1666744&r2=1666745&view=diff
> ==============================================================================
> ---
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansConfigurationException.java
> (original)
> +++
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansConfigurationException.java
> Sat Mar 14 20:58:32 2015
> @@ -22,8 +22,6 @@ import javax.enterprise.inject.spi.Defin
> import org.apache.webbeans.exception.helper.DescriptiveException;
> import org.apache.webbeans.exception.helper.ExceptionMessageBuilder;
> 
> -import java.io.ObjectStreamException;
> -
> /**
>   * Exception that is thrown by the web beans container at the intialization
>   * time. This is the OWB implementation of the DefinitionException.
> @@ -70,9 +68,4 @@ public class WebBeansConfigurationExcept
>      {
>          return msg.getAdditionalInformation(super.getLocalizedMessage());
>      }
> -
> -    private Object writeReplace() throws ObjectStreamException
> -    {
> -        return new DefinitionException(getMessage(), getCause());
> -    }
> }
> 
> Modified:
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansDeploymentException.java
> URL:
> http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansDeploymentException.java?rev=1666745&r1=1666744&r2=1666745&view=diff
> ==============================================================================
> ---
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansDeploymentException.java
> (original)
> +++
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansDeploymentException.java
> Sat Mar 14 20:58:32 2015
> @@ -22,8 +22,6 @@ import javax.enterprise.inject.spi.Deplo
> import org.apache.webbeans.exception.helper.DescriptiveException;
> import org.apache.webbeans.exception.helper.ExceptionMessageBuilder;
> 
> -import java.io.ObjectStreamException;
> -
> /**
>   * Exception that is thrown by the web beans container at the deployment
> time.
>   *
> @@ -68,9 +66,4 @@ public class WebBeansDeploymentException
>      {
>          return msg.getAdditionalInformation(super.getLocalizedMessage());
>      }
> -
> -    private Object writeReplace() throws ObjectStreamException
> -    {
> -        return new DeploymentException(getMessage(), getCause());
> -    }
> }
> 
> Modified:
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ExceptionMessageBuilder.java
> URL:
> http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ExceptionMessageBuilder.java?rev=1666745&r1=1666744&r2=1666745&view=diff
> ==============================================================================
> ---
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ExceptionMessageBuilder.java
> (original)
> +++
> openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ExceptionMessageBuilder.java
> Sat Mar 14 20:58:32 2015
> @@ -18,6 +18,7 @@
>   */
> package org.apache.webbeans.exception.helper;
> 
> +import java.io.Serializable;
> import java.util.ArrayList;
> import java.util.List;
> 
> @@ -25,8 +26,10 @@ import java.util.List;
> /**
>   * Helper for {@link DescriptiveException}.
>   */
> -public class ExceptionMessageBuilder
> +public class ExceptionMessageBuilder implements Serializable
> {
> +    private static final long serialVersionUID = 4391880458753108617L;
> +
>      private List<String> additionalInformations;
> 
>      public void addInformation(String additionalInformation)
> 

Reply via email to