You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2020/09/23 15:57:18 UTC
[tomee] branch master updated: Add some logging when resource
provider fails to instanciate a bean
This is an automated email from the ASF dual-hosted git repository.
jlmonteiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/master by this push:
new 8b527b9 Add some logging when resource provider fails to instanciate a bean
8b527b9 is described below
commit 8b527b9f5f3c3ea52425f1dfd8d02237712a258f
Author: Jean-Louis Monteiro <je...@gmail.com>
AuthorDate: Wed Sep 23 17:56:48 2020 +0200
Add some logging when resource provider fails to instanciate a bean
---
.../apache/openejb/server/cxf/rs/CdiResourceProvider.java | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CdiResourceProvider.java b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CdiResourceProvider.java
index 2fcbf04..c87084a 100644
--- a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CdiResourceProvider.java
+++ b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CdiResourceProvider.java
@@ -53,6 +53,9 @@ import java.util.HashSet;
import java.util.Set;
public abstract class CdiResourceProvider implements ResourceProvider {
+
+ private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_RS, CdiResourceProvider.class);
+
public static final String INSTANCE_KEY = CdiResourceProvider.class.getName() + ".instance";
protected final Collection<Injection> injections;
@@ -87,6 +90,7 @@ public abstract class CdiResourceProvider implements ResourceProvider {
bean = bm.resolve(beans);
} catch (final InjectionException ie) {
final String msg = "Resource class " + clazz.getName() + " can not be instantiated";
+ LOGGER.warning(msg, ie);
throw new WebApplicationException(Response.serverError().entity(msg).build());
}
@@ -138,7 +142,9 @@ public abstract class CdiResourceProvider implements ResourceProvider {
// only validate it here otherwise we'll fail for CDI injections
constructor = ResourceUtils.findResourceConstructor(clazz, true);
if (constructor == null) {
- throw new RuntimeException("Resource class " + clazz + " has no valid constructor");
+ final String message = "Resource class " + clazz + " has no valid constructor";
+ LOGGER.warning(message);
+ throw new RuntimeException(message);
}
}
@@ -322,18 +328,22 @@ public abstract class CdiResourceProvider implements ResourceProvider {
return instance;
} catch (final InstantiationException ex) {
final String msg = "Resource class " + constructor.getDeclaringClass().getName() + " can not be instantiated";
+ LOGGER.warning(msg, ex);
throw new WebApplicationException(Response.serverError().entity(msg).build());
} catch (final IllegalAccessException ex) {
final String msg = "Resource class " + constructor.getDeclaringClass().getName() + " can not be instantiated"
+ " due to IllegalAccessException";
+ LOGGER.warning(msg, ex);
throw new WebApplicationException(Response.serverError().entity(msg).build());
} catch (final InvocationTargetException ex) {
final String msg = "Resource class "
+ constructor.getDeclaringClass().getName() + " can not be instantiated"
+ " due to InvocationTargetException";
+ LOGGER.warning(msg, ex);
throw new WebApplicationException(Response.serverError().entity(msg).build());
- } catch (final OpenEJBException e) {
+ } catch (final OpenEJBException ex) {
final String msg = "An error occured injecting in class " + constructor.getDeclaringClass().getName();
+ LOGGER.warning(msg, ex);
throw new WebApplicationException(Response.serverError().entity(msg).build());
}
}