FELIX-2492 : scr plugin: using src annotations causes NoClassDefFoundError and other errors

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1132934 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/ClassUtil.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/ClassUtil.java
index 76160d2..3860364 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/ClassUtil.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/ClassUtil.java
@@ -32,15 +32,20 @@
      * @param fieldName The name of the field.
      * @return The initial value or null.
      */
-    public static String[] getInitializationExpression(Class<?> clazz, String fieldName) {
-        try {
+    public static String[] getInitializationExpression(final Class<?> clazz, final String fieldName)
+    {
+        try
+        {
             final Field field = clazz.getDeclaredField(fieldName);
             field.setAccessible(true);
             final Object value = field.get(null);
-            if ( value != null ) {
-                if ( value.getClass().isArray() ) {
+            if ( value != null )
+            {
+                if ( value.getClass().isArray() )
+                {
                     final String[] values = new String[Array.getLength(value)];
-                    for(int i=0; i<values.length; i++) {
+                    for(int i=0; i<values.length; i++)
+                    {
                         values[i] = Array.get(value, i).toString();
                     }
                     return values;
@@ -48,7 +53,14 @@
                 return new String[] {value.toString()};
             }
             return null;
-        } catch (Exception e) {
+        }
+        catch (final NoClassDefFoundError ncdfe)
+        {
+            throw new IllegalArgumentException("A class could not be found while parsing class " + clazz.getName() +
+                        ". Please check this stracktrace and add a dependency with the missing class to your project.", ncdfe);
+        }
+        catch (final Exception e)
+        {
             // ignore and just return null
         }
         return null;