[ 
https://issues.apache.org/jira/browse/ARIES-1772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16370244#comment-16370244
 ] 

Daniel Estermann commented on ARIES-1772:
-----------------------------------------

Hi Dominik, thank you for your work so far. I found out that the problem occurs 
also with the transitive dependencies of the provided dependencies. The 
situation I have is following:
{code:xml}
<project>
  <artifactId>A</artifactId>
  <build><dependencies><dependency>
    <artifactId>B</artifactId>
    <scope>provided</scope>
  </dependency></dependencies></build>
</project>{code}
{code:xml}
<project>
  <artifactId>B</artifactId>
  <build><dependencies><dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>${version.jersey}</version>
  </dependency></dependencies></build>
</project>
{code}
 
 Trying to build project A results in: 
{code:java}
[ERROR] Failed to execute goal 
org.apache.aries.blueprint:blueprint-maven-plugin:1.9.0:blueprint-generate 
(default) on project portal-backend: Execution default of goal 
org.apache.aries.blueprint:blueprint-maven-plugin:1.9.0:blueprint-generate 
failed: A required class was missing while executing 
org.apache.aries.blueprint:blueprint-maven-plugin:1.9.0:blueprint-generate: 
com/fasterxml/jackson/jaxrs/json/JacksonJaxbJsonProvider
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.aries.blueprint:blueprint-maven-plugin:1.9.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = 
file:/d:/.m2/repository/org/apache/aries/blueprint/blueprint-maven-plugin/1.9.0/blueprint-maven-plugin-1.9.0.jar
                                            ...skipped...
                                                         
...jersey-media-json-jackson is missing here...
[ERROR] urls[44] ...
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm 
ClassRealm[project>com.seeburger.portal:portal-backend:2.50.0-SNAPSHOT, parent: 
ClassRealm[maven.api, parent: null]]]
[ERROR] 
[ERROR] -----------------------------------------------------: 
com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
{code}
 

I looked at the code of the plugin and noticed two things, which are related to 
the error.
 # The filtering of the scanned classes using the scanPath parameter happens 
+after+ the scanning. FilteredClassFinder.findClasses(...) find the annotated 
classes first and then applies the filter by calling filterByBasePackages(..). 
That's why I cannot really constraint the scanning via that parameter.
{code:java}
org.apache.aries.blueprint.plugin.FilteredClassFinder:36

private static Set<Class<?>> findClasses(ClassFinder finder, Collection<String> 
packageNames, Class<? extends Annotation>[] annotations) {
  Set<Class<?>> rawClasses = new HashSet<Class<?>>();
  for (Class<? extends Annotation> annotation : annotations) {
    rawClasses.addAll(finder.findAnnotatedClasses(annotation));
  }
  return filterByBasePackages(rawClasses, packageNames);
}{code}
 # The ClassFinder gets initialized using a URLClassLoader, which contains a 
set of JARs including the transitive dependencies of the provided dependencies. 
{code:java}
org.apache.aries.blueprint.plugin.GenerateMojo:175

private ClassFinder createProjectScopeFinder() {
  for (Object artifactO : project.getArtifacts()) {
  //...
    urls.add(file.toURI().toURL());
  }
  ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), 
getClass().getClassLoader());
  return new ClassFinder(loader, urls);
}{code}
Project.getArtifacts() returns 120 objects while the amount of jar on the build 
classpath is 45. Especially jersey-media-json-jackson.jar containing 
JacksonJaxbJsonProvider is one of the JARs returned by getArtifacts(). No idea 
why that happens, maybe bug in maven? I use Maven 3.2.1 for CI and 3.5.2 
locally, if that matters.


 !test.png!

 

> Add an option to blueprint-maven-plugin to exclude dependencies.
> ----------------------------------------------------------------
>
>                 Key: ARIES-1772
>                 URL: https://issues.apache.org/jira/browse/ARIES-1772
>             Project: Aries
>          Issue Type: New Feature
>          Components: Blueprint
>    Affects Versions: blueprint-maven-plugin-1.9.0
>            Reporter: Daniel Estermann
>            Assignee: Dominik Przybysz
>            Priority: Major
>         Attachments: test.png, test.png
>
>
> Currently the list of scanned classes by blueprint-maven-plugin can be 
> restricted using scanPath parameter, so the list can also contain the classes 
> of the project dependencies. With my projects I experience two kind of issues 
> with it:
>  * If the the scan path is chosen too widely it may lead to a build failure. 
> For example: Assume project A has a dependency to project B an both have the 
> same base package, which is chosen as the scan path. Project B has a 
> blueprint bean, which implements an interface from some +provided+ dependency 
> of it. The build of project A will fail then, because it will try to scan a 
> blueprint bean of project B but it will miss its provided dependency. An 
> example error message:
>  
> {code:java}
> Failed to execute goal 
> org.apache.aries.blueprint:blueprint-maven-plugin:1.9.0:blueprint-generate 
> (default) on project email-template-editor-core: Execution default of goal 
> org.apache.aries.blueprint:blueprint-maven-plugin:1.9.0:blueprint-generate 
> failed: A required class was missing while executing 
> org.apache.aries.blueprint:blueprint-maven-plugin:1.9.0:blueprint-generate: 
> com/mycorporation/scheduler/api/ScheduledService{code}
>  
>  * If a bean of project B appears in the autowire.xml of project A, but the 
> package of that bean is not imported in the manifest of project A, a 
> ClassNotFoundException will be thrown during runtime:
>  
> {code:java}
> java.lang.ClassNotFoundException: 
> com.mycorporation.project-a.commons.notification.IncomingNotificationService 
> from [Module 
> "deployment.com.mycorporation.project-b.commons.core:0.0.1.SNAPSHOT" from 
> Service Module Loader]
> {code}
>  
> I suggest to add an option, to exclude dependencies from the list of scanned 
> classes, like [maven-bundle-plugin's 
> excludeDependencies|http://felix.apache.org/components/bundle-plugin/bundle-mojo.html#excludeDependencies]
>  for example, and give this option per default such value as to exclude all 
> dependencies.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to