You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Alexander Klimetschek (JIRA)" <ji...@apache.org> on 2009/05/08 13:15:45 UTC

[jira] Commented: (FELIX-1129) SCR plugin fails if class import is implicit

    [ https://issues.apache.org/jira/browse/FELIX-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12707315#action_12707315 ] 

Alexander Klimetschek commented on FELIX-1129:
----------------------------------------------

Ah, stupid me. The classic result of cargo cult programming. On the other hand, with the new Java annotation way for the scr stuff this would have been noted by the compiler ;-)

> SCR plugin fails if class import is implicit
> --------------------------------------------
>
>                 Key: FELIX-1129
>                 URL: https://issues.apache.org/jira/browse/FELIX-1129
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions: maven-scr-plugin-1.0.10
>            Reporter: Alexander Klimetschek
>            Priority: Minor
>
> The scr plugin gives a build error (see below) in a certain case when an import is implicit, ie. is not defined explicitly in the import section of the java source file, but is referenced in the source of the superclass. The interface in question is the one that this class implements and under which it should be registered as service.
> In my specific case there is:
> - an interface Importer, defined in bundle A
> - an implementation of that interface, HttpImporter, also defined in bundle A
> - bundle B now has a provided dep to bundle A
> - bundle B has a class ICalHttpImporter that extends HttpImporter
> - this class has scr qdox annotations and shall be registered as service under the Importer interface
> - it uses the short form @scr.service without explicitly specifying the interface class name
> Because of the import of HttpImporter (and the ICalHttpImporter extends HttpImporter), it is not necessary for the Java compiler to have an "import com.day.cq.polling.importer.Importer" in the file (Eclipse removes it automatically upon organize imports if present). But if it is missing, the scr plugin fails. From the error message, it seems it is looking for the interface in the current package (com.day.cq.collab.calendar.impl.importer.Importer), where it cannot find it.
> If the import statement "import com.day.cq.polling.importer.Importer;" is added, the scr plugin runs correctly and produces the right scrinfo files. Setting priority to minor because of this workaround.
> [INFO] [scr:scr {execution: generate-scr-scrdescriptor}]
> [INFO] ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO] ------------------------------------------------------------------------
> [INFO] Unable to load class com.day.cq.collab.calendar.impl.importer.Importer
> [INFO] ------------------------------------------------------------------------
> [INFO] Trace
> org.apache.maven.lifecycle.LifecycleExecutionException: Unable to load
> class com.day.cq.collab.calendar.impl.importer.Importer
>        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
>        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
>        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
>        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
>        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
>        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
>        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
>        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
>        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:585)
>        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to
> load class com.day.cq.collab.calendar.impl.importer.Importer
>        at org.apache.felix.scrplugin.tags.JavaClassDescriptorManager.getJavaClassDescription(JavaClassDescriptorManager.java:383)
>        at org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription.getExternalFieldByName(QDoxJavaClassDescription.java:175)
>        at org.apache.felix.scrplugin.PropertyHandler.getReferencedField(PropertyHandler.java:258)
>        at org.apache.felix.scrplugin.PropertyHandler.getPropertyName(PropertyHandler.java:210)
>        at org.apache.felix.scrplugin.PropertyHandler.testProperty(PropertyHandler.java:308)
>        at org.apache.felix.scrplugin.SCRDescriptorMojo.createComponent(SCRDescriptorMojo.java:268)
>        at org.apache.felix.scrplugin.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:129)
>        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
>        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
>        ... 16 more

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