You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Michael Dürig (JIRA)" <ji...@apache.org> on 2010/07/29 11:18:17 UTC

[jira] Created: (FELIX-2492) cxr plugin: using src annotations causes NoClassDefFoundError and other errors

cxr plugin: using src annotations causes NoClassDefFoundError and other errors
------------------------------------------------------------------------------

                 Key: FELIX-2492
                 URL: https://issues.apache.org/jira/browse/FELIX-2492
             Project: Felix
          Issue Type: Bug
          Components: Maven SCR Plugin
    Affects Versions:  maven-scr-plugin-1.4.4
            Reporter: Michael Dürig


Using comment tags and having a dependency on slf4j-api causes the scr plugin to throw a NoClassDefFoundError:

java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
	at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
	at java.lang.reflect.Field.get(Field.java:358)
	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:239)

A workaround is to add a 'dummy' dependency to i.e. slf4j-simple. But then

[WARNING] Unused declared dependencies found:
[WARNING]    org.slf4j:slf4j-simple:jar:1.5.0:provided

Furthermore when the 'dummy' dependency has the wrong version, the scr plugin might throw other errors:

java.lang.NoSuchFieldError: name
	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
	at java.lang.reflect.Field.get(Field.java:358)
	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:238)

I think such errors should be handled more gracefully indicating the source of the problem. Also it should not be necessary to have a 'dummy' dependencies. This was not the case up to version 1.4.1. 
If it is absolutely necessary to include such dummy dependencies, the plugin should state so in its error message. Also the slf4j case is so common that it might be worth to considering a specific solution/workaround for this in the plugin. This is still much better than forcing all clients to analyze the problem from the stacktrace and then implement workarounds.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-2492) cxr plugin: using src annotations causes NoClassDefFoundError and other errors

Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2492?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12894023#action_12894023 ] 

Michael Dürig commented on FELIX-2492:
--------------------------------------

> as we are talking of "developers" 

That's the users I had in mind. It still takes them time to analyze the issue and research a workaround. Particularly since the issue is counter intuitive: the dependency plugin will report your dependencies as fine but the src plugin will fail because of a missing dependency which the dependency plugin would report as unreferenced. 

I still think printing an explanatory message pointing to this bug would cut the time used to analyze the problem and come up with a workaround. 


> cxr plugin: using src annotations causes NoClassDefFoundError and other errors
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-2492
>                 URL: https://issues.apache.org/jira/browse/FELIX-2492
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions:  maven-scr-plugin-1.4.4
>            Reporter: Michael Dürig
>
> Using comment tags and having a dependency on slf4j-api causes the scr plugin to throw a NoClassDefFoundError:
> java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
> 	at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:239)
> A workaround is to add a 'dummy' dependency to i.e. slf4j-simple. But then
> [WARNING] Unused declared dependencies found:
> [WARNING]    org.slf4j:slf4j-simple:jar:1.5.0:provided
> Furthermore when the 'dummy' dependency has the wrong version, the scr plugin might throw other errors:
> java.lang.NoSuchFieldError: name
> 	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
> 	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
> 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:238)
> I think such errors should be handled more gracefully indicating the source of the problem. Also it should not be necessary to have a 'dummy' dependencies. This was not the case up to version 1.4.1. 
> If it is absolutely necessary to include such dummy dependencies, the plugin should state so in its error message. Also the slf4j case is so common that it might be worth to considering a specific solution/workaround for this in the plugin. This is still much better than forcing all clients to analyze the problem from the stacktrace and then implement workarounds.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-2492) scr plugin: using src annotations causes NoClassDefFoundError and other errors

Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2492?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12894496#action_12894496 ] 

Michael Dürig commented on FELIX-2492:
--------------------------------------

I agree on everything here: should use annotations instead of comment tags, should use final instead of final static, should mark slf4j-simple as optional and so on. The best way to advertise all this is to put this info onto the Wiki page of the scr plugin improve the error reporting of the plugin in the case of the missing dependency directing the user to the relevant information (i.e. Wiki, this bug).



> scr plugin: using src annotations causes NoClassDefFoundError and other errors
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-2492
>                 URL: https://issues.apache.org/jira/browse/FELIX-2492
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions:  maven-scr-plugin-1.4.4
>            Reporter: Michael Dürig
>
> Using comment tags and having a dependency on slf4j-api causes the scr plugin to throw a NoClassDefFoundError:
> java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
> 	at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:239)
> A workaround is to add a 'dummy' dependency to i.e. slf4j-simple. But then
> [WARNING] Unused declared dependencies found:
> [WARNING]    org.slf4j:slf4j-simple:jar:1.5.0:provided
> Furthermore when the 'dummy' dependency has the wrong version, the scr plugin might throw other errors:
> java.lang.NoSuchFieldError: name
> 	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
> 	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
> 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:238)
> I think such errors should be handled more gracefully indicating the source of the problem. Also it should not be necessary to have a 'dummy' dependencies. This was not the case up to version 1.4.1. 
> If it is absolutely necessary to include such dummy dependencies, the plugin should state so in its error message. Also the slf4j case is so common that it might be worth to considering a specific solution/workaround for this in the plugin. This is still much better than forcing all clients to analyze the problem from the stacktrace and then implement workarounds.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-2492) cxr plugin: using src annotations causes NoClassDefFoundError and other errors

Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2492?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12894005#action_12894005 ] 

Michael Dürig commented on FELIX-2492:
--------------------------------------

That's one part of the issue. But I think the scr plugin should say so. That is the plugin should at least print a message like "unresolved dependency.... See FELIX-2492". In the case of slf4j which seems very common to me the plugin could even suggest to add a dependency to slf4j-simple. 

Simply failing with a stack trace and relying on the each and every user digging into the problem seems not right to me. 



> cxr plugin: using src annotations causes NoClassDefFoundError and other errors
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-2492
>                 URL: https://issues.apache.org/jira/browse/FELIX-2492
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions:  maven-scr-plugin-1.4.4
>            Reporter: Michael Dürig
>
> Using comment tags and having a dependency on slf4j-api causes the scr plugin to throw a NoClassDefFoundError:
> java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
> 	at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:239)
> A workaround is to add a 'dummy' dependency to i.e. slf4j-simple. But then
> [WARNING] Unused declared dependencies found:
> [WARNING]    org.slf4j:slf4j-simple:jar:1.5.0:provided
> Furthermore when the 'dummy' dependency has the wrong version, the scr plugin might throw other errors:
> java.lang.NoSuchFieldError: name
> 	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
> 	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
> 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:238)
> I think such errors should be handled more gracefully indicating the source of the problem. Also it should not be necessary to have a 'dummy' dependencies. This was not the case up to version 1.4.1. 
> If it is absolutely necessary to include such dummy dependencies, the plugin should state so in its error message. Also the slf4j case is so common that it might be worth to considering a specific solution/workaround for this in the plugin. This is still much better than forcing all clients to analyze the problem from the stacktrace and then implement workarounds.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-2492) cxr plugin: using src annotations causes NoClassDefFoundError and other errors

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2492?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12894009#action_12894009 ] 

Felix Meschberger commented on FELIX-2492:
------------------------------------------

> Simply failing with a stack trace and relying on the each and every user digging into the problem seems not right to me.

YMMV certainly here, particularly as we are talking of "developers" not mere users in the sense of "my mother" ;-)

But yes, the message could be nicer indicating similarly to FELIX-1726, that a project dependency is missing.

Whether we should specially highlight SLF4J or not: I certainly don't think so. It may be your case, that SLF4J is a primary candidate. Other users have other candidates. So we may probably not generalize, event though SLF4J is certainly one of the few libraries having such an issue.

> cxr plugin: using src annotations causes NoClassDefFoundError and other errors
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-2492
>                 URL: https://issues.apache.org/jira/browse/FELIX-2492
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions:  maven-scr-plugin-1.4.4
>            Reporter: Michael Dürig
>
> Using comment tags and having a dependency on slf4j-api causes the scr plugin to throw a NoClassDefFoundError:
> java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
> 	at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:239)
> A workaround is to add a 'dummy' dependency to i.e. slf4j-simple. But then
> [WARNING] Unused declared dependencies found:
> [WARNING]    org.slf4j:slf4j-simple:jar:1.5.0:provided
> Furthermore when the 'dummy' dependency has the wrong version, the scr plugin might throw other errors:
> java.lang.NoSuchFieldError: name
> 	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
> 	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
> 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:238)
> I think such errors should be handled more gracefully indicating the source of the problem. Also it should not be necessary to have a 'dummy' dependencies. This was not the case up to version 1.4.1. 
> If it is absolutely necessary to include such dummy dependencies, the plugin should state so in its error message. Also the slf4j case is so common that it might be worth to considering a specific solution/workaround for this in the plugin. This is still much better than forcing all clients to analyze the problem from the stacktrace and then implement workarounds.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-2492) cxr plugin: using src annotations causes NoClassDefFoundError and other errors

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2492?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12894359#action_12894359 ] 

Carsten Ziegeler commented on FELIX-2492:
-----------------------------------------

I would suggest people to use the real annotations instead of the javadoc tags anyway :) I haven't encounted such problems with annotations yet and I would like to get more feedback about the annotations anyway.
So I tend to agree with Felix to "just" have a nicer error message

> cxr plugin: using src annotations causes NoClassDefFoundError and other errors
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-2492
>                 URL: https://issues.apache.org/jira/browse/FELIX-2492
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions:  maven-scr-plugin-1.4.4
>            Reporter: Michael Dürig
>
> Using comment tags and having a dependency on slf4j-api causes the scr plugin to throw a NoClassDefFoundError:
> java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
> 	at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:239)
> A workaround is to add a 'dummy' dependency to i.e. slf4j-simple. But then
> [WARNING] Unused declared dependencies found:
> [WARNING]    org.slf4j:slf4j-simple:jar:1.5.0:provided
> Furthermore when the 'dummy' dependency has the wrong version, the scr plugin might throw other errors:
> java.lang.NoSuchFieldError: name
> 	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
> 	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
> 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:238)
> I think such errors should be handled more gracefully indicating the source of the problem. Also it should not be necessary to have a 'dummy' dependencies. This was not the case up to version 1.4.1. 
> If it is absolutely necessary to include such dummy dependencies, the plugin should state so in its error message. Also the slf4j case is so common that it might be worth to considering a specific solution/workaround for this in the plugin. This is still much better than forcing all clients to analyze the problem from the stacktrace and then implement workarounds.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-2492) scr plugin: using src annotations causes NoClassDefFoundError and other errors

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2492?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler updated FELIX-2492:
------------------------------------

    Summary: scr plugin: using src annotations causes NoClassDefFoundError and other errors  (was: cxr plugin: using src annotations causes NoClassDefFoundError and other errors)

> scr plugin: using src annotations causes NoClassDefFoundError and other errors
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-2492
>                 URL: https://issues.apache.org/jira/browse/FELIX-2492
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions:  maven-scr-plugin-1.4.4
>            Reporter: Michael Dürig
>
> Using comment tags and having a dependency on slf4j-api causes the scr plugin to throw a NoClassDefFoundError:
> java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
> 	at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:239)
> A workaround is to add a 'dummy' dependency to i.e. slf4j-simple. But then
> [WARNING] Unused declared dependencies found:
> [WARNING]    org.slf4j:slf4j-simple:jar:1.5.0:provided
> Furthermore when the 'dummy' dependency has the wrong version, the scr plugin might throw other errors:
> java.lang.NoSuchFieldError: name
> 	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
> 	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
> 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:238)
> I think such errors should be handled more gracefully indicating the source of the problem. Also it should not be necessary to have a 'dummy' dependencies. This was not the case up to version 1.4.1. 
> If it is absolutely necessary to include such dummy dependencies, the plugin should state so in its error message. Also the slf4j case is so common that it might be worth to considering a specific solution/workaround for this in the plugin. This is still much better than forcing all clients to analyze the problem from the stacktrace and then implement workarounds.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-2492) cxr plugin: using src annotations causes NoClassDefFoundError and other errors

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2492?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12894353#action_12894353 ] 

Felix Meschberger commented on FELIX-2492:
------------------------------------------

Comes to mind: Another, even better option than adding a compile-scope dependency on slf4j-simple is to not use constant fields referring to SLF4J loggers. There are at least two good reasons for this:

  (1) Having a complie-scope dependency on slf4-simple is bad, because the goal of slf4j is to properly separate the compile time issues (cared for by the developer) from the run-time issues (cared for by the deployer and/or system administrator). So, at least, you should mark your slf4j-simple compile time dependency as optional so as to not transitively forward this dependency.

  (2) Having constant references to complex objects makes the work of the garbage collector unnecessarily hard: The referred-to object can only be collected once the class containing the static final reference is collected ....

So, your best fix would probably be to change your "static final" reference to just a "final" reference. And everything would be fine.

> cxr plugin: using src annotations causes NoClassDefFoundError and other errors
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-2492
>                 URL: https://issues.apache.org/jira/browse/FELIX-2492
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions:  maven-scr-plugin-1.4.4
>            Reporter: Michael Dürig
>
> Using comment tags and having a dependency on slf4j-api causes the scr plugin to throw a NoClassDefFoundError:
> java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
> 	at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:239)
> A workaround is to add a 'dummy' dependency to i.e. slf4j-simple. But then
> [WARNING] Unused declared dependencies found:
> [WARNING]    org.slf4j:slf4j-simple:jar:1.5.0:provided
> Furthermore when the 'dummy' dependency has the wrong version, the scr plugin might throw other errors:
> java.lang.NoSuchFieldError: name
> 	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
> 	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
> 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
> 	at com.day.crx.spi.sharepoint.resource.SharepointResourceProvider.<clinit>(SharepointResourceProvider.java:60)
> 	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> 	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> 	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> 	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> 	at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> 	at java.lang.reflect.Field.get(Field.java:358)
> 	at org.apache.felix.scrplugin.tags.ClassUtil.getInitializationExpression(ClassUtil.java:41)
> 	at org.apache.felix.scrplugin.tags.qdox.QDoxJavaField.getInitializationExpression(QDoxJavaField.java:44)
> 	at org.apache.felix.scrplugin.helper.PropertyHandler.getPropertyName(PropertyHandler.java:238)
> I think such errors should be handled more gracefully indicating the source of the problem. Also it should not be necessary to have a 'dummy' dependencies. This was not the case up to version 1.4.1. 
> If it is absolutely necessary to include such dummy dependencies, the plugin should state so in its error message. Also the slf4j case is so common that it might be worth to considering a specific solution/workaround for this in the plugin. This is still much better than forcing all clients to analyze the problem from the stacktrace and then implement workarounds.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.