1

I know this question has been asked a lot, however no answer I found is relevant or applicable to my situation.

I have a lot of projects which are having the following folder structure:

main
+-- pom.xml
+-- shared
    +--- pom.xml
    +--- org.apache.felix
      +---- pom.xml
    +--- com.google.protobuf
      +---- pom.xml
    +--- project1 
      +---- pom.xml
    +--- project2
      +---- pom.xml
    +--- project3
      +---- pom.xml
    +--- ...

Basically some jar projects assisting the others with source files. And I am trying to compile everything. The process compiles the jar projects, but gives error at the project1 with the following:

package org.apache.felix.service.command does not exist

and

cannot find symbol [ERROR] symbol:   class activator

the latter is expected because of the first error. I believe there is some referencing error somewhere. I am sharing the following pom.xml files of mine:

pom.xml of org.apache.felix

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
      <groupId>shared</groupId>
      <artifactId>shared.master</artifactId>
      <relativePath>../pom.xml</relativePath>
      <version>1.0.0-SNAPSHOT</version>
   </parent>
   <groupId>shared</groupId>
   <artifactId>org.apache.felix</artifactId>
   <name>org.apache.felix</name>
   <version>1.0.0</version>
</project>

pom.xml of project1 which throws the error

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
      <groupId>shared</groupId>
      <artifactId>shared.master</artifactId>
      <relativePath>../pom.xml</relativePath>
      <version>1.0.0-SNAPSHOT</version>
   </parent>
   <groupId>shared</groupId>
   <artifactId>shared.cmd.felix</artifactId>
   <name>shared.cmd.felix</name>
   <version>1.0.0</version>
   <packaging>jar</packaging>
   <dependencies>
      <dependency>
         <groupId>shared</groupId>
         <artifactId>org.apache.felix</artifactId>
         <version>1.0.0</version>
         <scope>system</scope>
         <systemPath>${project.basedir}/../org.apache.felix/felix.jar</systemPath>
      </dependency>
      <dependency>
         <groupId>shared</groupId>
         <artifactId>org.apache.log4j</artifactId>
         <version>1.0.0</version>
         <scope>system</scope>
         <systemPath>${project.basedir}/../org.apache.log4j/log4j-1.2.17.jar</systemPath>
      </dependency>
   </dependencies>
   <build>
      <sourceDirectory>src/</sourceDirectory>
      <plugins>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <source>${jdk.version}</source>
               <target>${jdk.version}</target>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.1</version>
            <configuration>
               <archive>
                  <manifest>
                     <addClasspath>true</addClasspath>
                     <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                     <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                  </manifest>
                  <manifestEntries>
                     <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                     <Bundle-Version>${project.version}</Bundle-Version>
                     <Bundle-ClassPath>.</Bundle-ClassPath>
                     <Export-Package>shared.cmd.felix</Export-Package>
                  </manifestEntries>
               </archive>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

And this is the MANIFEST.MF file of the project1:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: project1
Bundle-SymbolicName: project1
Bundle-Version: 1.0.0
Fragment-Host: shared.mw;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: .,
 bundle/system/org.apache.felix.gogo.runtime-0.10.0.jar
Export-Package: shared.cmd.ext
Import-Package: shared,
 shared.cmd,
 shared.comp,
 shared.mw,
 shared.sched,
 shared.service,
 org.apache.felix.service.command,
 org.apache.log4j,
 org.osgi.framework
Require-Bundle: org.apache.felix;bundle-version="1.0.0",
 org.apache.activemq

By the way I am running the script from the /shared directory, not /main.

Anyone faced a similar situation?

  • I would launch Maven from main's `pom.xml`. It seems like it is the root POM. – Tunaki Jun 27 '16 at 08:09
  • It does not matter since it should compile standalone as well. I could remove everything and just keep `shared`, and it should work. –  Jun 27 '16 at 08:11
  • Are you trying to build Apache Felix? `${project.basedir}/../org.apache.felix/felix.jar` looks really weird. Check your dependencies in project1. – Tunaki Jun 27 '16 at 08:13
  • Yes, I have that jar in that project which is a part of the build process. I'd like to have it in my local repository. As for dependencies, I am putting my MANIFEST.MF now, you can check it. –  Jun 27 '16 at 08:15
  • Using the scope `system` is not your local repository, see http://stackoverflow.com/questions/2229757/maven-add-a-dependency-to-a-jar-by-relative-path to see how to correctly add a dependency. Wait, Maven doesn't read dependencies from MANIFEST, only from the POM. – Tunaki Jun 27 '16 at 08:17
  • Well, [the second answer](http://stackoverflow.com/a/2229775/4964330) in that question is exactly what I have here, are you sure that `system` is the problem here? Because it seems to be working for other people. –  Jun 27 '16 at 08:31
  • 1
    I thought so but you want to build an OSGi bundle here right? If so, look at http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html – Tunaki Jun 27 '16 at 08:33
  • Thank you for the link. I guess I have to start even from the scratch, since I didn't know the existence of such a plugin. Now that I looked at it, some other questions popped up in my mind. In this case, I'll remove this, and ask those. –  Jun 27 '16 at 10:55

0 Answers0