You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2016/04/26 22:52:47 UTC

[05/15] olingo-odata2 git commit: [OLINGO-763] New internal server error code for serializer exceptions

[OLINGO-763] New internal server error code for serializer exceptions

Also imporved the exception handling for producers. If the root cause is a
message exception we will now provide the root cause instead of the
wrapper. This should lead to more detailed exception texts for
ProducerExceptions


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/eb806b91
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/eb806b91
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/eb806b91

Branch: refs/heads/OLINGO-882_EnableContainerManagedPersistence
Commit: eb806b91042ae450cdec1b6934ecb9418b6008fa
Parents: 27fced0
Author: Christian Amend <ch...@sap.com>
Authored: Thu Mar 3 15:27:18 2016 +0100
Committer: Christian Amend <ch...@sap.com>
Committed: Thu Mar 3 15:29:30 2016 +0100

----------------------------------------------------------------------
 .../apache/olingo/odata2/core/edm/EdmImpl.java  |  14 ++
 .../odata2/core/ep/AtomEntityProvider.java      |  20 +--
 .../odata2/core/ep/BasicEntityProvider.java     |  17 +-
 .../ep/EntityProviderProducerException.java     |  44 +++++
 .../odata2/core/ep/JsonEntityProvider.java      |  25 ++-
 .../ep/producer/AtomEntryEntityProducer.java    |  43 ++---
 .../core/ep/producer/AtomFeedProducer.java      |  17 +-
 .../producer/AtomServiceDocumentProducer.java   |  10 +-
 .../producer/JsonCollectionEntityProducer.java  |   6 +-
 .../JsonDeletedEntryEntityProducer.java         |   3 +-
 .../ep/producer/JsonEntryEntityProducer.java    |  10 +-
 .../ep/producer/JsonFeedEntityProducer.java     |   5 +-
 .../ep/producer/JsonLinkEntityProducer.java     |   3 +-
 .../ep/producer/JsonLinksEntityProducer.java    |   3 +-
 .../ep/producer/JsonPropertyEntityProducer.java |  16 +-
 .../producer/JsonServiceDocumentProducer.java   |   8 +-
 .../core/ep/producer/TombstoneProducer.java     |   5 +-
 .../producer/XmlCollectionEntityProducer.java   |   3 +-
 .../core/ep/producer/XmlLinkEntityProducer.java |   3 +-
 .../ep/producer/XmlLinksEntityProducer.java     |   3 +-
 .../core/ep/producer/XmlMetadataProducer.java   |   5 +-
 .../ep/producer/XmlPropertyEntityProducer.java  |  15 +-
 .../odata2/core/rest/ODataExceptionWrapper.java |  11 +-
 .../core/servlet/ODataExceptionWrapper.java     |  11 +-
 .../core/ep/producer/AtomEntryProducerTest.java |   8 +-
 .../fit/ref/InvalidDataInScenarioTest.java      | 164 +++++++++++++++++++
 26 files changed, 367 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java
index 80f3776..141a00e 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmImpl.java
@@ -81,6 +81,8 @@ public abstract class EdmImpl implements Edm {
           edmEntityContainers.put(name, edmEntityContainer);
         }
       }
+    } catch (EdmException e) {
+      throw e;
     } catch (ODataException e) {
       throw new EdmException(EdmException.COMMON, e);
     }
@@ -104,6 +106,8 @@ public abstract class EdmImpl implements Edm {
       if (edmEntityType != null) {
         edmEntityTypes.put(fqName, edmEntityType);
       }
+    } catch (EdmException e) {
+      throw e;
     } catch (ODataException e) {
       throw new EdmException(EdmException.COMMON, e);
     }
@@ -118,6 +122,8 @@ public abstract class EdmImpl implements Edm {
         if (aliasToNamespaceInfo == null) {
           aliasToNamespaceInfo = new HashMap<String, String>();
         }
+      } catch (EdmException e) {
+        throw e;
       } catch (ODataException e) {
         throw new EdmException(EdmException.COMMON, e);
       }
@@ -145,6 +151,8 @@ public abstract class EdmImpl implements Edm {
       if (edmComplexType != null) {
         edmComplexTypes.put(fqName, edmComplexType);
       }
+    } catch (EdmException e) {
+      throw e;
     } catch (ODataException e) {
       throw new EdmException(EdmException.COMMON, e);
     }
@@ -167,6 +175,8 @@ public abstract class EdmImpl implements Edm {
       if (edmAssociation != null) {
         edmAssociations.put(fqName, edmAssociation);
       }
+    } catch (EdmException e) {
+      throw e;
     } catch (ODataException e) {
       throw new EdmException(EdmException.COMMON, e);
     }
@@ -190,6 +200,8 @@ public abstract class EdmImpl implements Edm {
       if (edmEntitySets == null) {
         edmEntitySets = createEntitySets();
       }
+    } catch (EdmException e) {
+      throw e;
     } catch (ODataException e) {
       throw new EdmException(EdmException.COMMON, e);
     }
@@ -202,6 +214,8 @@ public abstract class EdmImpl implements Edm {
       if (edmFunctionImports == null) {
         edmFunctionImports = createFunctionImports();
       }
+    } catch (EdmException e) {
+      throw e;
     } catch (ODataException e) {
       throw new EdmException(EdmException.COMMON, e);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java
index 6dc6b7a..acdf998 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java
@@ -150,7 +150,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       csb.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -181,7 +181,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       csb.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -213,7 +213,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       csb.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -242,7 +242,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (XMLStreamException e) {
       csb.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -270,7 +270,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       csb.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
 
@@ -299,7 +299,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       csb.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -324,7 +324,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       csb.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -349,8 +349,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
         return writeSingleTypedElement(info, data);
       }
     } catch (EdmException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
-          .getSimpleName()), e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -419,8 +418,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
           new XmlEntityConsumer().readProperty(info, content, properties).get(info.getName());
       }
     } catch (final EdmException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED
-          .addContent(e.getClass().getSimpleName()), e);
+      throw new EntityProviderException(e.getMessageReference(), e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java
index c8b2520..7d9a59c 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java
@@ -122,8 +122,7 @@ public class BasicEntityProvider {
     try {
       type = (EdmSimpleType) edmProperty.getType();
     } catch (EdmException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
-          .getSimpleName()), e);
+      throw new EntityProviderException(e.getMessageReference(), e);
     }
 
     if (type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()) {
@@ -137,8 +136,7 @@ public class BasicEntityProvider {
           return type.valueOfString(readText(content), EdmLiteralKind.DEFAULT, edmProperty.getFacets(), typeMapping);
         }
       } catch (EdmException e) {
-        throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
-            .getSimpleName()), e);
+        throw new EntityProviderException(e.getMessageReference(), e);
       }
     }
   }
@@ -179,8 +177,7 @@ public class BasicEntityProvider {
       }
 
     } catch (EdmException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
-          .getSimpleName()), e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -197,7 +194,7 @@ public class BasicEntityProvider {
       try {
         stream = new ByteArrayInputStream(value.getBytes(DEFAULT_CHARSET));
       } catch (UnsupportedEncodingException e) {
-        throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+        throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
             .getSimpleName()), e);
       }
       builder.entity(stream);
@@ -248,13 +245,13 @@ public class BasicEntityProvider {
       XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
       XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, predefinedNamespaces);
     } catch (UnsupportedEncodingException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     } catch (FactoryConfigurationError e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
     builder.entity(csb.getInputStream());

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/EntityProviderProducerException.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/EntityProviderProducerException.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/EntityProviderProducerException.java
new file mode 100644
index 0000000..2c23846
--- /dev/null
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/EntityProviderProducerException.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.core.ep;
+
+import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.api.exception.MessageReference;
+
+public class EntityProviderProducerException extends EntityProviderException {
+
+  private static final long serialVersionUID = 1L;
+
+  public EntityProviderProducerException(final MessageReference messageReference) {
+    super(messageReference);
+  }
+
+  public EntityProviderProducerException(final MessageReference messageReference, final Throwable cause) {
+    super(messageReference, cause);
+  }
+
+  public EntityProviderProducerException(final MessageReference messageReference, final String errorCode) {
+    super(messageReference, errorCode);
+  }
+
+  public EntityProviderProducerException(final MessageReference messageReference, final Throwable cause,
+      final String errorCode) {
+    super(messageReference, cause, errorCode);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/JsonEntityProvider.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/JsonEntityProvider.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/JsonEntityProvider.java
index 092135b..c83b128 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/JsonEntityProvider.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/JsonEntityProvider.java
@@ -125,7 +125,8 @@ public class JsonEntityProvider implements ContentTypeBasedEntityProvider {
           .build();
     } catch (Exception e) {
       buffer.close();
-      throw new ODataRuntimeException(e);
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+          .getSimpleName()), e);
     }
   }
 
@@ -151,7 +152,7 @@ public class JsonEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       buffer.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -180,7 +181,7 @@ public class JsonEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       buffer.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -203,7 +204,7 @@ public class JsonEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       buffer.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -228,7 +229,7 @@ public class JsonEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       buffer.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -255,7 +256,7 @@ public class JsonEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       buffer.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -276,7 +277,7 @@ public class JsonEntityProvider implements ContentTypeBasedEntityProvider {
       throw e;
     } catch (Exception e) {
       buffer.close();
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -298,8 +299,7 @@ public class JsonEntityProvider implements ContentTypeBasedEntityProvider {
         return writeSingleTypedElement(info, data);
       }
     } catch (final EdmException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
-          .getSimpleName()), e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -330,12 +330,11 @@ public class JsonEntityProvider implements ContentTypeBasedEntityProvider {
       } else {
         final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport);
         return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ?
-          new JsonEntityConsumer().readCollection(info, content, properties) :
-          new JsonEntityConsumer().readProperty(info, content, properties).get(info.getName());
+            new JsonEntityConsumer().readCollection(info, content, properties) :
+            new JsonEntityConsumer().readProperty(info, content, properties).get(info.getName());
       }
     } catch (final EdmException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED
-          .addContent(e.getClass().getSimpleName()), e);
+      throw new EntityProviderException(e.getMessageReference(), e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java
index 5e92500..6250739 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java
@@ -57,6 +57,7 @@ import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
 import org.apache.olingo.odata2.core.commons.ContentType;
 import org.apache.olingo.odata2.core.commons.Encoder;
 import org.apache.olingo.odata2.core.edm.EdmDateTimeOffset;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo;
 import org.apache.olingo.odata2.core.ep.util.FormatXml;
@@ -139,11 +140,11 @@ public class AtomEntryEntityProducer {
 
       writer.flush();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (EdmException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     } catch (URISyntaxException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 
@@ -208,7 +209,7 @@ public class AtomEntryEntityProducer {
 
       return etag;
     } catch (EdmSimpleTypeException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -245,7 +246,7 @@ public class AtomEntryEntityProducer {
       }
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 
@@ -269,13 +270,13 @@ public class AtomEntryEntityProducer {
 
         ODataCallback callback = properties.getCallbacks().get(navigationPropertyName);
         if (callback == null) {
-          throw new EntityProviderException(EntityProviderException.EXPANDNOTSUPPORTED);
+          throw new EntityProviderProducerException(EntityProviderException.EXPANDNOTSUPPORTED);
         }
         WriteFeedCallbackResult result;
         try {
           result = ((OnWriteFeedContent) callback).retrieveFeedResult(context);
         } catch (ODataApplicationException e) {
-          throw new EntityProviderException(EntityProviderException.COMMON, e);
+          throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
         }
         List<Map<String, Object>> inlineData = result.getFeedData();
         if (inlineData == null) {
@@ -313,13 +314,13 @@ public class AtomEntryEntityProducer {
 
         ODataCallback callback = properties.getCallbacks().get(navigationPropertyName);
         if (callback == null) {
-          throw new EntityProviderException(EntityProviderException.EXPANDNOTSUPPORTED);
+          throw new EntityProviderProducerException(EntityProviderException.EXPANDNOTSUPPORTED);
         }
         WriteEntryCallbackResult result;
         try {
           result = ((OnWriteEntryContent) callback).retrieveEntryResult(context);
         } catch (ODataApplicationException e) {
-          throw new EntityProviderException(EntityProviderException.COMMON, e);
+          throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
         }
         Map<String, Object> inlineData = result.getEntryData();
         if (inlineData != null && !inlineData.isEmpty()) {
@@ -346,9 +347,9 @@ public class AtomEntryEntityProducer {
       writer.writeAttribute(FormatXml.ATOM_TITLE, eia.getEntityType().getName());
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (EdmException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -373,7 +374,7 @@ public class AtomEntryEntityProducer {
       writer.writeAttribute(FormatXml.ATOM_TYPE, mediaResourceMimeType);
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 
@@ -410,7 +411,7 @@ public class AtomEntryEntityProducer {
       writer.writeAttribute(FormatXml.ATOM_SRC, self);
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 
@@ -443,9 +444,9 @@ public class AtomEntryEntityProducer {
 
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (EdmSimpleTypeException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -477,7 +478,7 @@ public class AtomEntryEntityProducer {
       }
       return null;
     } catch (EdmSimpleTypeException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -520,9 +521,9 @@ public class AtomEntryEntityProducer {
       writer.writeAttribute(FormatXml.ATOM_CATEGORY_SCHEME, Edm.NAMESPACE_SCHEME_2007_08);
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (EdmException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -538,7 +539,7 @@ public class AtomEntryEntityProducer {
         writer.writeEndElement();
       }
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 
@@ -574,7 +575,7 @@ public class AtomEntryEntityProducer {
         keys.append(Encoder.encode(type.valueToString(data.get(name), EdmLiteralKind.URI,
             keyPropertyInfo.getFacets())));
       } catch (final EdmSimpleTypeException e) {
-        throw new EntityProviderException(EntityProviderException.COMMON, e);
+        throw new EntityProviderProducerException(e.getMessageReference(), e);
       }
     }
 
@@ -601,7 +602,7 @@ public class AtomEntryEntityProducer {
         writer.writeEndElement();
       }
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java
index 5684814..0c43572 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java
@@ -37,6 +37,7 @@ import org.apache.olingo.odata2.api.ep.callback.TombstoneCallback;
 import org.apache.olingo.odata2.api.ep.callback.TombstoneCallbackResult;
 import org.apache.olingo.odata2.core.commons.Encoder;
 import org.apache.olingo.odata2.core.edm.EdmDateTimeOffset;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.util.FormatXml;
 
@@ -88,7 +89,7 @@ public class AtomFeedProducer {
 
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 
@@ -120,7 +121,7 @@ public class AtomFeedProducer {
         writer.writeAttribute(FormatXml.ATOM_HREF, deltaLink);
         writer.writeEndElement();
       } catch (XMLStreamException e) {
-        throw new EntityProviderException(EntityProviderException.COMMON, e);
+        throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
       }
     }
   }
@@ -132,7 +133,7 @@ public class AtomFeedProducer {
       writer.writeAttribute(FormatXml.ATOM_REL, FormatXml.ATOM_NEXT_LINK);
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 
@@ -147,14 +148,14 @@ public class AtomFeedProducer {
   private void appendInlineCount(final XMLStreamWriter writer, final Integer inlineCount)
       throws EntityProviderException {
     if (inlineCount == null || inlineCount < 0) {
-      throw new EntityProviderException(EntityProviderException.INLINECOUNT_INVALID);
+      throw new EntityProviderProducerException(EntityProviderException.INLINECOUNT_INVALID);
     }
     try {
       writer.writeStartElement(Edm.NAMESPACE_M_2007_08, FormatXml.M_COUNT);
       writer.writeCharacters(String.valueOf(inlineCount));
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 
@@ -175,7 +176,7 @@ public class AtomFeedProducer {
       writer.writeAttribute(FormatXml.ATOM_TITLE, eia.getEntitySetName());
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 
@@ -217,9 +218,9 @@ public class AtomFeedProducer {
       writer.writeEndElement();
 
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (EdmSimpleTypeException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducer.java
index a5299f1..d5827e2 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducer.java
@@ -28,10 +28,12 @@ import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.edm.EdmEntitySetInfo;
+import org.apache.olingo.odata2.api.edm.EdmException;
 import org.apache.olingo.odata2.api.edm.EdmServiceMetadata;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.core.commons.ContentType;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.util.FormatXml;
 
 /**
@@ -88,11 +90,13 @@ public class AtomServiceDocumentProducer {
 
       xmlStreamWriter.flush();
     } catch (FactoryConfigurationError e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
+    } catch (EdmException e) {
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     } catch (ODataException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonCollectionEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonCollectionEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonCollectionEntityProducer.java
index 4ba8577..0c25410 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonCollectionEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonCollectionEntityProducer.java
@@ -25,6 +25,7 @@ import java.util.List;
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.edm.EdmException;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo;
 import org.apache.olingo.odata2.core.ep.util.FormatJson;
 import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter;
@@ -69,11 +70,10 @@ public class JsonCollectionEntityProducer {
       jsonStreamWriter.endObject()
           .endObject();
     } catch (final IOException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     } catch (final EdmException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
-          .getSimpleName()), e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonDeletedEntryEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonDeletedEntryEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonDeletedEntryEntityProducer.java
index 2452228..0ce7f80 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonDeletedEntryEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonDeletedEntryEntityProducer.java
@@ -25,6 +25,7 @@ import java.util.Map;
 
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.util.FormatJson;
 import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter;
@@ -68,7 +69,7 @@ public class JsonDeletedEntryEntityProducer {
         }
       }
     } catch (final IOException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java
index fe02cc7..6615935 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java
@@ -45,6 +45,7 @@ import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackResult;
 import org.apache.olingo.odata2.api.exception.ODataApplicationException;
 import org.apache.olingo.odata2.core.commons.ContentType;
 import org.apache.olingo.odata2.core.commons.Encoder;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.util.FormatJson;
 import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter;
@@ -100,11 +101,10 @@ public class JsonEntryEntityProducer {
       writer.flush();
 
     } catch (final IOException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     } catch (final EdmException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
-          .getSimpleName()), e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -147,7 +147,7 @@ public class JsonEntryEntityProducer {
 
     ODataCallback callback = properties.getCallbacks().get(navigationPropertyName);
     if (callback == null) {
-      throw new EntityProviderException(EntityProviderException.EXPANDNOTSUPPORTED);
+      throw new EntityProviderProducerException(EntityProviderException.EXPANDNOTSUPPORTED);
     }
     try {
       if (isFeed) {
@@ -182,7 +182,7 @@ public class JsonEntryEntityProducer {
         }
       }
     } catch (final ODataApplicationException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonFeedEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonFeedEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonFeedEntityProducer.java
index 4dc4dae..db71b63 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonFeedEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonFeedEntityProducer.java
@@ -28,6 +28,7 @@ import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
 import org.apache.olingo.odata2.api.ep.callback.TombstoneCallback;
 import org.apache.olingo.odata2.api.ep.callback.TombstoneCallbackResult;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.util.FormatJson;
 import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter;
@@ -84,7 +85,7 @@ public class JsonFeedEntityProducer {
 
       jsonStreamWriter.endObject();
     } catch (final IOException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }
@@ -97,7 +98,7 @@ public class JsonFeedEntityProducer {
       appendEntries(writer, entityInfo, data, jsonStreamWriter);
       jsonStreamWriter.endArray();
     } catch (final IOException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinkEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinkEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinkEntityProducer.java
index 9ddfddd..7c3efd8 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinkEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinkEntityProducer.java
@@ -24,6 +24,7 @@ import java.util.Map;
 
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.util.FormatJson;
 import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter;
@@ -56,7 +57,7 @@ public class JsonLinkEntityProducer {
         jsonStreamWriter.endObject();
       }
     } catch (final IOException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinksEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinksEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinksEntityProducer.java
index 858456c..7a19ed6 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinksEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonLinksEntityProducer.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import org.apache.olingo.odata2.api.commons.InlineCount;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.util.FormatJson;
 import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter;
@@ -81,7 +82,7 @@ public class JsonLinksEntityProducer {
         jsonStreamWriter.endObject();
       }
     } catch (final IOException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonPropertyEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonPropertyEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonPropertyEntityProducer.java
index 6947910..00ab712 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonPropertyEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonPropertyEntityProducer.java
@@ -22,8 +22,15 @@ import java.io.IOException;
 import java.io.Writer;
 import java.util.Map;
 
-import org.apache.olingo.odata2.api.edm.*;
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFacets;
+import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmType;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityComplexPropertyInfo;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo;
 import org.apache.olingo.odata2.core.ep.util.FormatJson;
@@ -52,11 +59,10 @@ public class JsonPropertyEntityProducer {
       jsonStreamWriter.endObject()
           .endObject();
     } catch (final IOException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     } catch (final EdmException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
-          .getSimpleName()), e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -78,7 +84,7 @@ public class JsonPropertyEntityProducer {
         }
         jsonStreamWriter.endObject();
       } else {
-        throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
+        throw new EntityProviderProducerException(EntityProviderException.ILLEGAL_ARGUMENT
             .addContent("A complex property must have a Map as data"));
       }
     } else {

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonServiceDocumentProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonServiceDocumentProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonServiceDocumentProducer.java
index bca6b65..bb4d351 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonServiceDocumentProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonServiceDocumentProducer.java
@@ -23,9 +23,11 @@ import java.io.Writer;
 
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.edm.EdmEntitySetInfo;
+import org.apache.olingo.odata2.api.edm.EdmException;
 import org.apache.olingo.odata2.api.edm.EdmServiceMetadata;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.util.FormatJson;
 import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter;
 
@@ -60,10 +62,12 @@ public class JsonServiceDocumentProducer {
           .endObject()
           .endObject();
     } catch (final IOException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
+    } catch (final EdmException e) {
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     } catch (final ODataException e) {
-      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+      throw new EntityProviderProducerException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
           .getSimpleName()), e);
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java
index 7f1babb..142db4d 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java
@@ -33,6 +33,7 @@ import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
 import org.apache.olingo.odata2.api.ep.callback.TombstoneCallback;
 import org.apache.olingo.odata2.core.edm.EdmDateTimeOffset;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo;
 import org.apache.olingo.odata2.core.ep.util.FormatXml;
@@ -66,9 +67,9 @@ public class TombstoneProducer {
         writer.writeEndElement();
       }
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (EdmSimpleTypeException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java
index bf0bc8c..96eae72 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java
@@ -25,6 +25,7 @@ import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo;
 import org.apache.olingo.odata2.core.ep.util.FormatXml;
 
@@ -49,7 +50,7 @@ public class XmlCollectionEntityProducer {
       writer.writeEndElement();
       writer.flush();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java
index fe59c4a..1e20f1c 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java
@@ -26,6 +26,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.util.FormatXml;
 
@@ -55,7 +56,7 @@ public class XmlLinkEntityProducer {
       writer.writeEndElement();
       writer.flush();
     } catch (final XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java
index 84eff3b..a8a240e 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java
@@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
 import org.apache.olingo.odata2.core.ep.util.FormatXml;
 
@@ -60,7 +61,7 @@ public class XmlLinksEntityProducer {
       writer.writeEndElement();
       writer.flush();
     } catch (final XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlMetadataProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlMetadataProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlMetadataProducer.java
index f917de7..f301482 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlMetadataProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlMetadataProducer.java
@@ -57,6 +57,7 @@ import org.apache.olingo.odata2.api.edm.provider.Schema;
 import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
 import org.apache.olingo.odata2.api.edm.provider.Using;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.util.XmlMetadataConstants;
 import org.apache.olingo.odata2.core.exception.ODataRuntimeException;
 
@@ -420,9 +421,9 @@ public class XmlMetadataProducer {
 
       xmlStreamWriter.flush();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (FactoryConfigurationError e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java
index 433e79e..587748d 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java
@@ -32,6 +32,7 @@ import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
 import org.apache.olingo.odata2.api.edm.EdmSimpleType;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityComplexPropertyInfo;
 import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo;
 import org.apache.olingo.odata2.core.ep.util.FormatXml;
@@ -77,9 +78,9 @@ public class XmlPropertyEntityProducer {
 
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (EdmException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -92,9 +93,9 @@ public class XmlPropertyEntityProducer {
         writer.writeEndElement();
       }
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (EdmException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -123,9 +124,9 @@ public class XmlPropertyEntityProducer {
 
       writer.writeEndElement();
     } catch (XMLStreamException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
     } catch (EdmException e) {
-      throw new EntityProviderException(EntityProviderException.COMMON, e);
+      throw new EntityProviderProducerException(e.getMessageReference(), e);
     }
   }
 
@@ -229,7 +230,7 @@ public class XmlPropertyEntityProducer {
     String nsPrefix = mapping.getFcNsPrefix();
     String nsUri = mapping.getFcNsUri();
     if (nsUri == null || nsPrefix == null) {
-      throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE.addContent(name));
+      throw new EntityProviderProducerException(EntityProviderException.INVALID_NAMESPACE.addContent(name));
     }
     writer.writeStartElement(nsPrefix, name, nsUri);
     writer.writeNamespace(nsPrefix, nsUri);

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionWrapper.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionWrapper.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionWrapper.java
index 30efb9c..4300ab1 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionWrapper.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataExceptionWrapper.java
@@ -48,6 +48,7 @@ import org.apache.olingo.odata2.api.processor.ODataErrorCallback;
 import org.apache.olingo.odata2.api.processor.ODataErrorContext;
 import org.apache.olingo.odata2.api.processor.ODataResponse;
 import org.apache.olingo.odata2.core.commons.ContentType;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.ProviderFacadeImpl;
 import org.apache.olingo.odata2.core.exception.MessageService;
 import org.apache.olingo.odata2.core.exception.MessageService.Message;
@@ -160,7 +161,15 @@ public class ODataExceptionWrapper {
     if (toHandleException instanceof ODataHttpException) {
       errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus());
     } else if (toHandleException instanceof EntityProviderException) {
-      errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
+      if(toHandleException instanceof EntityProviderProducerException){
+        /*
+         * As per OLINGO-763 serializer exceptions are produced by the server and must therefore result 
+         * in a 500 internal server error
+         */
+        errorContext.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR);
+      }else{
+        errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
+      }
     } else if (toHandleException instanceof BatchException) {
       errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataExceptionWrapper.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataExceptionWrapper.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataExceptionWrapper.java
index 9a87505..e012ec4 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataExceptionWrapper.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataExceptionWrapper.java
@@ -43,6 +43,7 @@ import org.apache.olingo.odata2.api.processor.ODataErrorCallback;
 import org.apache.olingo.odata2.api.processor.ODataErrorContext;
 import org.apache.olingo.odata2.api.processor.ODataResponse;
 import org.apache.olingo.odata2.core.commons.ContentType;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.core.ep.ProviderFacadeImpl;
 import org.apache.olingo.odata2.core.exception.MessageService;
 import org.apache.olingo.odata2.core.exception.MessageService.Message;
@@ -152,7 +153,15 @@ public class ODataExceptionWrapper {
     if (toHandleException instanceof ODataHttpException) {
       errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus());
     } else if (toHandleException instanceof EntityProviderException) {
-      errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
+      if(toHandleException instanceof EntityProviderProducerException){
+        /*
+         * As per OLINGO-763 serializer exceptions are produced by the server and must therefore result 
+         * in a 500 internal server error
+         */
+        errorContext.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR);
+      }else{
+        errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
+      }
     } else if (toHandleException instanceof BatchException) {
       errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java
index ff429af..c6b712d 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryProducerTest.java
@@ -41,6 +41,7 @@ import javax.xml.stream.FactoryConfigurationError;
 import javax.xml.stream.XMLStreamException;
 
 import junit.framework.Assert;
+
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.edm.EdmConcurrencyMode;
 import org.apache.olingo.odata2.api.edm.EdmCustomizableFeedMappings;
@@ -60,6 +61,7 @@ import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
 import org.apache.olingo.odata2.core.commons.ContentType;
 import org.apache.olingo.odata2.core.ep.AbstractProviderTest;
 import org.apache.olingo.odata2.core.ep.AtomEntityProvider;
+import org.apache.olingo.odata2.core.ep.EntityProviderProducerException;
 import org.apache.olingo.odata2.testutil.helper.StringHelper;
 import org.apache.olingo.odata2.testutil.helper.XMLUnitHelper;
 import org.apache.olingo.odata2.testutil.mock.MockFacade;
@@ -465,7 +467,7 @@ public class AtomEntryProducerTest extends AbstractProviderTest {
     try {
       ser.writeEntry(employeesSet, employeeData, DEFAULT_PROPERTIES);
     } catch (EntityProviderException e) {
-      verifyRootCause(EntityProviderException.class, EntityProviderException.INVALID_NAMESPACE.getKey(), e);
+      verifyRootCause(EntityProviderProducerException.class, EntityProviderException.INVALID_NAMESPACE.getKey(), e);
       thrown = true;
     }
     if (!thrown) {
@@ -497,7 +499,7 @@ public class AtomEntryProducerTest extends AbstractProviderTest {
     try {
       ser.writeEntry(employeesSet, employeeData, DEFAULT_PROPERTIES);
     } catch (EntityProviderException e) {
-      verifyRootCause(EntityProviderException.class, EntityProviderException.INVALID_NAMESPACE.getKey(), e);
+      verifyRootCause(EntityProviderProducerException.class, EntityProviderException.INVALID_NAMESPACE.getKey(), e);
       thrown = true;
     }
     if (!thrown) {
@@ -528,7 +530,7 @@ public class AtomEntryProducerTest extends AbstractProviderTest {
     try {
       ser.writeEntry(employeesSet, employeeData, DEFAULT_PROPERTIES);
     } catch (EntityProviderException e) {
-      verifyRootCause(EntityProviderException.class, EntityProviderException.INVALID_NAMESPACE.getKey(), e);
+      verifyRootCause(EntityProviderProducerException.class, EntityProviderException.INVALID_NAMESPACE.getKey(), e);
       thrown = true;
     }
     if (!thrown) {

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/eb806b91/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/InvalidDataInScenarioTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/InvalidDataInScenarioTest.java b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/InvalidDataInScenarioTest.java
new file mode 100644
index 0000000..10be915
--- /dev/null
+++ b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/InvalidDataInScenarioTest.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.fit.ref;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.http.HttpResponse;
+import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.ep.EntityProvider;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.api.exception.ODataApplicationException;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
+import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetSimplePropertyUriInfo;
+import org.apache.olingo.odata2.core.processor.ODataSingleProcessorService;
+import org.apache.olingo.odata2.ref.edm.ScenarioEdmProvider;
+import org.apache.olingo.odata2.testutil.server.ServletType;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Based on OLINGO-763 we changed the behaviour of serializer exceptions. Now they must result in 500 internal server
+ * errors if an application provides false data. This test is to ensure that the serializer throws the correct exception
+ * which then results in the correct status code.
+ */
+public class InvalidDataInScenarioTest extends AbstractRefTest {
+
+  public InvalidDataInScenarioTest(ServletType servletType) {
+    super(servletType);
+  }
+
+  @Override
+  protected ODataSingleProcessorService createService() {
+    ODataSingleProcessor processor = new LocalProcessor();
+    EdmProvider provider = new ScenarioEdmProvider();
+
+    return new ODataSingleProcessorService(provider, processor) {};
+  }
+
+  @Before
+  public void showStacktrace() {
+    disableLogging();
+  }
+
+  @Test
+  public void nullKeyInEntryData() throws Exception {
+    HttpResponse response = callUri("Employees('1')", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    System.out.println(getBody(response));
+    response = callUri("Employees('1')?$format=json", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    assertTrue(getBody(response).contains("null value"));
+  }
+
+  @Test
+  public void violatedFacetsInEntry() throws Exception {
+    HttpResponse response = callUri("Employees('2')", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    assertTrue(getBody(response).contains("metadata constraints"));
+    response = callUri("Employees('2')?$format=json", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    assertTrue(getBody(response).contains("metadata constraints"));
+  }
+
+  @Test
+  public void nullKeyInFeedData() throws Exception {
+    HttpResponse response = callUri("Employees", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    assertTrue(getBody(response).contains("null value"));
+    response = callUri("Employees?$format=json", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    assertTrue(getBody(response).contains("null value"));
+  }
+
+  @Test
+  public void wrongPropertyValueIsNull() throws Exception {
+    HttpResponse response = callUri("Employees('1')/EmployeeId", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    assertTrue(getBody(response).contains("null value"));
+    response = callUri("Employees('1')/EmployeeId?$format=json", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    assertTrue(getBody(response).contains("null value"));
+  }
+
+  @Test
+  public void wrongPropertyValueWithFacets() throws Exception {
+    HttpResponse response = callUri("Employees('2')/TeamId", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    assertTrue(getBody(response).contains("metadata constraints"));
+    response = callUri("Employees('2')/TeamId?$format=json", HttpStatusCodes.INTERNAL_SERVER_ERROR);
+    assertTrue(getBody(response).contains("metadata constraints"));
+  }
+
+  public class LocalProcessor extends ODataSingleProcessor {
+
+    @Override
+    public ODataResponse readEntity(GetEntityUriInfo uriInfo, String contentType) throws ODataException {
+      HashMap<String, Object> data = new HashMap<String, Object>();
+
+      if ("Employees".equals(uriInfo.getTargetEntitySet().getName())) {
+        if ("2".equals(uriInfo.getKeyPredicates().get(0).getLiteral())) {
+          data.put("EmployeeId", "1");
+          data.put("TeamId", "420");
+        }
+
+        ODataContext context = getContext();
+        EntityProviderWriteProperties writeProperties =
+            EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).build();
+
+        return EntityProvider.writeEntry(contentType, uriInfo.getTargetEntitySet(), data, writeProperties);
+      } else {
+        throw new ODataApplicationException("Wrong testcall", Locale.getDefault(), HttpStatusCodes.NOT_IMPLEMENTED);
+      }
+    }
+
+    @Override
+    public ODataResponse readEntitySet(GetEntitySetUriInfo uriInfo, String contentType) throws ODataException {
+      if ("Employees".equals(uriInfo.getTargetEntitySet().getName())) {
+        ODataContext context = getContext();
+        EntityProviderWriteProperties writeProperties =
+            EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).build();
+        List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
+        data.add(new HashMap<String, Object>());
+        return EntityProvider.writeFeed(contentType, uriInfo.getTargetEntitySet(), data, writeProperties);
+      } else {
+        throw new ODataApplicationException("Wrong testcall", Locale.getDefault(), HttpStatusCodes.NOT_IMPLEMENTED);
+      }
+    }
+
+    @Override
+    public ODataResponse readEntitySimpleProperty(GetSimplePropertyUriInfo uriInfo, String contentType)
+        throws ODataException {
+      EdmProperty edmProperty = uriInfo.getPropertyPath().get(0);
+      Object value = null;
+      if ("EmployeeId".equals(edmProperty.getName())) {
+        // must be null for a specific test
+        value = null;
+      } else if ("TeamId".equals(edmProperty.getName())) {
+        value = new Integer(520);
+      }
+
+      return EntityProvider.writeProperty(contentType, edmProperty, value);
+    }
+  }
+}