I'm developing web application with OSGI. I have a maven configuration error which I cannot find. This is the complete source code:
http://uploading.com/files/8e5c9888/SH_27_test.zip/
This is the POM file:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.DX_57.osgi.SH_27</groupId>
<artifactId>SH_27</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>SH_27-impl</artifactId>
<packaging>bundle</packaging>
<name>SH_27-impl</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>SH_27-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>SH_27-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Import-Package>${pom.groupId}.api, org.osgi.framework</Import-Package>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Activator>${pom.groupId}.impl.SessionHandleApp</Bundle-Activator>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<groupId>org.DX_57.osgi.SH_27</groupId>
</project>
When I try to compile it with Netbeans I get this error:
http://pastebin.com/whxuSb7V
The problem occurs when I add #Datasource. It seems that I'm missing something in the POM file but I don't have idea what it is?
Any help will be highly appreciated.
Best Wishes
Peter
Check out Maven: Unresolved references to [org.osgi.service.http]. I think he had the same problem that he managed to resolve by including specific packages that need to be imported.
This is the solution:
<Import-Package>${pom.groupId}.api, org.osgi.framework</Import-Package>
Should be:
<Import-Package>*</Import-Package>
I hope that this will be helpful for someone.
Related
I have a web-application(TestWeb) and multiple java dependency projects(TestCommon,TestModule).
I was able to build all 3 projects using maven.It has created war file and jar file out of it.
I need to create .ear file using maven. How can I create ear and build them?
TestWeb/pom.xml
<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>
<groupId>TestWeb</groupId>
<artifactId>TestWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>TestCommon</groupId>
<artifactId>TestCommon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>TestModule</groupId>
<artifactId>TestModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Use <packaging>ear</packaging> instead of <packaging>war</packaging>.
I am having a situation where two jars of different versions of apache-commons-lang3 are being packaged in my application WAR even when a single version v3.4 is mentioned in my dependencyManagement.
link.
I explored a little and figured out the wrong jar i.e., v3.1 is coming from maven surefire plugin.
Now, I want to exclude apache-commons-lang3 jar that is coming from maven surefire plugin. However, I tried many ways to force surefire to take the latest jar and bring in v3.4 but I am not able to do so.
Does there exist a way to do the above? That is, exclude a transient jar coming from a maven plugin?
I am trying to build this pom but still it is downloading v3.1.
<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>
<groupId>bhatinik</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<apache.commons.lang3.version>3.4</apache.commons.lang3.version>
<maven.surefire.plugin.version>2.19.1</maven.surefire.plugin.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commons.lang3.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commons.lang3.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>unit-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude>${module.test.excludes}</exclude>
<excludeArtifactIds>commons-lang3</excludeArtifactIds>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency> </dependencies>
</project>
I get this error during generation of JAR with Maven:
Failed to execute goal on project TaskManagerTrue: Could not resolve dependencies for project groupId:TaskManagerTrue:jar:1.0: Could not find artifact groupId:TaskManagerTrue:jar:1.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
My pom.xml:
<?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>
<groupId>groupId</groupId>
<artifactId>TaskManagerTrue</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>TaskManagerTrue</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<build>
<finalName>test</finalName>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<goal>jar:inplace</goal>
<archive>
<manifestFile>META-INF/MANIFEST.MF</manifestFile>
</archive>
<outputDirectory>artifacts</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
How can I fix this problem?
Removing this declaration fixed the problem:
<dependency>
<groupId>groupId</groupId>
<artifactId>TaskManagerTrue</artifactId>
<version>1.0</version>
</dependency>
I am trying to configure the Maven Checkstyle Plugin for reporting and would like to change the dependency of Checkstyle to 7.5 instead of the default 6.11.2.
To achieve this I, have pluginManagement declared in parent pom with the dependency.
In the child project, I am just referencing the plugin in the reporting tag.
However I see that default Checkstyle (6.11.2) is being downloaded into the repository. Please see below parent and child pom.
<?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>
<groupId>com.mycompany.app</groupId>
<artifactId>parent_app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent_app</name>
<modules>
<module>my-app2</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>7.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Child pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>parent_app</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app2</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app2</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>src/main/resources/checkstyle.xml</configLocation>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>
Can you please help if this is the right way to override dependency for reporting plugin? If so why is it not working?
Maven version: 3.2.5
It looks like there is a bug here with the Maven Site Plugin (a regression introduced after MSITE-507). The dependencies explicitly added to the managed plugins configured in the build are indeed not taken into account, unless the plugin is also declared itself. That is to say, the following in the parent POM will give you the wanted behaviour (tested with Maven 3.3.9):
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>7.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
</build>
When that new parent is installed in the local repository, and the build on the child is launched (with mvn clean site for example), it is the expected Checkstyle 7.5 that will be used.
I have the tree
pom.xml
.presentation(ear)
..business(war)
..integration(jar)
when i try to build the ear (presentation) i get this error i don't understand why the artifact presentation should be a dependency and a dependency of what exactly ? :
Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.6:generate-application-xml (default-generate-application-xml) on project presentation: Artifact[war:presentaion:presentation] is not a dependency of the project. ->Help
ear: pom.xml:
<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>
<groupId>presentation</groupId>
<artifactId>presentation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<parent>
<groupId>MyProject</groupId>
<artifactId>MyProject</artifactId>
<version>0.0.1</version>
</parent>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<modules>
<webModule>
<groupId>presentaion</groupId>
<artifactId>presentation</artifactId>
<bundleFileName>presentation.war</bundleFileName>
<contextRoot>/presentation</contextRoot>
</webModule>
<jarModule>
<groupId>integration</groupId>
<artifactId>integration</artifactId>
<bundleFileName>integration.jar</bundleFileName>
</jarModule>
</modules>
<displayName>My Project</displayName>
</configuration>
</plugin>
</plugins>
<finalName>presentation</finalName>
</build>
<dependencies>
<dependency>
<groupId>business</groupId>
<artifactId>business</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>integration</groupId>
<artifactId>integration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
In the current .pom you are building an ear and you are giving the same ear as a warModule.
You should give a .war artefact for webmodule in the ear-plugin