Deploying a War File to Tomcat Root With Maven pom.xml - eclipse

Assuming the following pom.xml maven would build a client.war file which when deployed to Tomcat will have the URL www.server.com:8080/client/
What would one have to change so the application can be reached at the server root www.server.com:8080/?
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>...</groupId>
<artifactId>client</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>...</name>
<url>http://maven.apache.org</url>
<build>
<resources>
<resource>
<directory>target/generated-resources</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
...
</plugins>
<finalName>client</finalName>
</build>
...
</project>

I believe you can leave the war named client.war if you'd like. Then configure the tomcat6 plugin, setting the path like this:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0-beta-1</version>
<!-- put the configuration in an execution if you want to... -->
<configuration>
<path>/</path>
<warFile>${project.build.directory}/client.war</warFile>
<!-- other config options here -->
</configuration>
</plugin>
I haven't used tomcat7 version of the plugin, but I'm guessing it's similar.

Since you're using the combination of eclipse, tomcat, and maven, I'm going to make the guess that the m2e-wtp plugin is in use here. There's a FAQ that addresses this. This also shows though how to change your context root in a maven specific way (using the war plugin for specifying a finalName for the war) which results in a correctly named war file (such as ROOT.war as mentioned in other answers.

Maven war plugin (which is defined on super-pom by default) will only generate a war file. It's up to you to set up your app on Tomcat. If you want to add the "deploy to a container" to your maven build, go with Tomcat Maven Plugin or Cargo Maven Plugin.
What you want has nothing to do with Maven, actually. Setting your war name to ROOT.war should do it (<finalName>ROOT</finalName> on your build section), but if you want to add your context.xml to the war file, you could do something like (assuming src/main/webapp is your webapp folder defined by maven):
`<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<webResource>
<directory>${basedir}/src/main/webapp/META-INF</directory>
<includes>
<include>context.xml</include>
</includes>
<targetPath>META-INF</targetPath>
<filtering>true</filtering>
</webResource>
</webResources>
</configuration>
</plugin>
`

Related

.jar missing in deployed JBoss .war

I know this has been asked a few times in the past, but I'm unable to find a solution (except for the "add the .jar to your project manually in Eclipse"..)
What I have:
A Maven project
A .jar web-service we've created (let's call it kc.ourwebservice)
After a clean install (in Eclipse or via the command line) and Full Publish in Eclipse (and yes, I have done an Update Maven Project - Force Update of Snapshots/Releases before that), this .jar can be found in:
This kc.ourwebservice.jar is present in our Nexus Repository Manager OSS
This kc.ourwebservice.jar is present in our Eclipse project at the Maven dependencies
This kc.ourwebservice.jar is present when I run mvn dependency:tree -Dverbose
This kc.ourwebservice.jar is present in my .m2 folder
However, it's missing from the deployed JBoss .war's lib folder, which is what my question is about.
I know I could manually add the .jar in Eclipse' Deployment Assembly (or org.eclipse.wst.common.component file), but every time I switch git branches or do an "Update Maven Project", it's gone again. And I also don't want to manually add this .jar when the project is put on a server.
I need a permanent solution so the .jar is correctly added to the deployed JBoss .war, using the Maven plugins that were designed for it.
One thing to add. This webservice has both an .aar and .jar. Both of them are necessary. The .jar when we're starting the application, so I gave it a <scope>compile</scope>, and all the .aar we use are only needed at runtime, so I gave it that scope (<scope>runtime</scope>).
Here is the relevant pom.xml code (lots of more dependencies, plugins and code at the ...'s, but those are irrelevant for this problem):
<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>
...
</parent>
<artifactId>...</artifactId>
<packaging>war</packaging>
...
<properties>
...
<ourwebservice.version>1.0.0</ourwebservice.version>
...
</properties>
...
<plugins>
...
<!-- Takes care of copying the aar services to the WEB-INF/services -->
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-repo-maven-plugin</artifactId>
<version>1.7.3</version>
<configuration>
<outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
<stripServiceVersion>false</stripServiceVersion>
<services>...,ourwebservice</services>
</configuration>
<executions>
<execution>
<phase>generate-resources</phase>
<id>deploy webservices</id>
<goals>
<goal>create-repository</goal>
</goals>
</execution>
</executions>
</plugin>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${maven.war.plugin.version}</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<outputDirectory>${warOutputDir}</outputDirectory>
<webappDirectory>${webappDirectory}</webappDirectory>
<warName>${project.artifactId}</warName>
<!-- Tell the maven war plugin to use the merged web.xml -->
<webXml>${warOutputDir}/web.xml</webXml>
<warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
<webResources>
<resource>
<directory>${basedir}/src</directory>
<targetPath>WEB-INF/classes</targetPath>
<excludes>
<exclude>**/*.java</exclude>
<exclude>sample-properties.properties</exclude>
<exclude>sample-log4j.properties</exclude>
</excludes>
</resource>
<!-- Copy the generated services that were extracted from the dependencies to the WEB-INF/services folder of the war archive. -->
<resource>
<directory>${project.build.directory}/generated-resources/services</directory>
<targetPath>/WEB-INF/services</targetPath>
<includes>
<include>**/*.aar</include>
</includes>
</resource>
...
</webResources>
<!-- The axis2 services should not be stored in the WEB-INF/lib -->
<packagingExcludes>WEB-INF/lib/*.aar</packagingExcludes>
</configuration>
</plugin>
<!-- JBoss plugin used to deploy war file - http://mojo.codehaus.org/jboss-maven-plugin/ -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<hostName>${deploymentHostName}</hostName>
<port>${deploymentPort}</port>
<fileName>${deploymentFileName}</fileName>
<serverName>default</serverName>
<jbossHome>
//${deploymentHostName}/${jbossHome}
</jbossHome>
</configuration>
</plugin>
</plugins>
...
<dependencies>
...
<dependency>
<groupId>kc</groupId>
<artifactId>ourwebservice</artifactId>
<version>${ourwebservice.version}</version>
<type>aar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>kc</groupId>
<artifactId>ourwebservice</artifactId>
<version>${ourwebservice.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
...
</dependencies>
...
</project>
Does anyone has any idea why the .jar isn't deployed to the .war? Or better yet, does anyone know a solution so the .jar is always deployed to this .war when doing a clean install and publish?
All other .jar files are present in the .war, this webservice is the only one missing.

Eclipse deploying unfiltered .WAR-Archive on Tomcat

i have the following problem: I want to use maven profiles and the maven-war-plugin for filtering my webapplication, so that it's just one click to deploy it either on the live- or on the development server.
When i build the .WAR-archive via Eclipse (Maven-Plugin) and then manually deploy it on the tomcat-server via the tomcat-manager-interface, my application works as expected. (all variables are replaced correctly inside the generated .WAR-archive)
But when i want to run the application using Eclipse's "Run on Server", an exception occurs:
[..] nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.security.web.authentication.logout.LogoutFilter]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: ${security.casEntryPoint.logoutSuccessUrl} isn't a valid redirect URL
This is the configuration of the maven profiles in my pom.xml:
<profiles>
<profile>
<id>prod</id>
<build>
<filters>
<filter>src/main/filters/dfnaaiAgreement-prod.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>devLocal</id>
<build>
<filters>
<filter>src/main/filters/dfnaaiAgreement-devLocal.properties</filter>
</filters>
</build>
</profile>
This is an example entry for the *.properties file:
security.casEntryPoint.logoutSuccessUrl = https://example_entry/please_logmeout
This is one entry in the settings.xml that should be replaced by the value in the *.properties file:
<security:logout logout-url="/logout" logout-success-url="${security.casEntryPoint.logoutSuccessUrl}" />
and this is the configuration for the maven plugin (in the pom.xml), that is used for filtering the configuration files:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warName>dfnaaiAgreement</warName>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</webResources>
</configuration>
This is my maven build configuration:
Maven-Build configuration (Sorry, not enough reputation to post images directly)
It seems like eclipse's "run on server" deploys the unfiltered application on the tomcat-server.
What am i doing wrong?
Update:
I followed this Link Run Maven webapp on server from Eclipse with properties injection from profile, but i'am still receiving the same Exception.
Here's the adjustment of my project's configuration: Active Maven Profiles
Update: Eclipse (Luna) deploys the webapplication to workspace/.metadata/.plugins/.org.eclipse.wst.server.core/tmp0/wtpwebapps/applicationName. The settings.xml that's deployed there still contains the unfiltered variables, whereas the generated .WAR-Archive (that is located at workspace/applicationName/target) has the correctly filtered settings.xml. How is this possible?
Thanks for your help!
Although it's not an optimal solution i found a workaround to fix my problem. Therefor i adjusted the project's deployment assembly settings in the way that the WEB-INF-Folder of the target-Folder will be taken for deployment.
You can do this by rightclicking your project and choose "Properties". Here's a screenshot of how i adjusted the settings:
Web_Deployment_Assembly.PNG

Deploying Sources.jar Archive to Artifactory through UI

We are using a third party library that doesn't exist in Maven Central Repository and we wan't to deploy this archive as an artifact to Artifactory. We are trying to do that via Artifactory UI and we successfully deployed both archive.jar and archive-sources.jar. The problem occurs when we add this dependency through Gradle to our build.gradle script. Archive.jar is fetched from our repository but archive-sources.jar is not fetched. We are developing with Eclipse and you can see the problem through screenshot.
We tried several things including defining classifier in Artifactory UI, editing pom with Artifactory POM Editor, publishing pom file manually and nothing worked. Whatever we do we couldn't get the source of this archive. Any kind of help would save a lot of time and effort. Thanks!
Screenshot of Artifactory UI:
We have solved the issue but it was a little bit complicated. There are many steps to apply the solution:
In the case of jain-sdp archive, here are the steps:
1- Deploy jain-sdp sources artifact with classifier "sources" as it is shown in the screenshot.
2- Manually upload jain-sdp.pom file with including the "sourceDirectory" tag:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>javax.sip</groupId>
<version>1.2</version>
<artifactId>jain-sip</artifactId>
</parent>
<groupId>javax.sdp</groupId>
<artifactId>jain-sdp</artifactId>
<version>1.0.1111</version>
<packaging>jar</packaging>
<name>jain-sdp</name>
<url>http://jain-sip.dev.java.net</url>
<build>
<sourceDirectory>../../src/javax/</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<includes>
<include>**/sdp/**</include>
</includes>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>target/javax/</directory>
<includes>
<include>sdp/**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>
</project>
3- Manually create the below files.
pom.xml:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>javax.sip</groupId>
<version>1.2</version>
<artifactId>jain-sip</artifactId>
</parent>
<groupId>javax.sdp</groupId>
<artifactId>jain-sdp</artifactId>
<version>1.0.1111</version>
<packaging>jar</packaging>
<name>jain-sdp</name>
<url>http://jain-sip.dev.java.net</url>
<build>
<sourceDirectory>../../src/javax/</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<includes>
<include>**/sdp/**</include>
</includes>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>target/javax/</directory>
<includes>
<include>sdp/**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>
</project>
pom.properties:
#Generated by Maven
#Tue Feb 05 21:33:14 CET 2008
version=1.2
groupId=javax.sdp
artifactId=jain-sdp
4- Include the files that have been created in Step 3 to the below path in the archive:
META-INF/maven/javax.sdp/jain-sdp/pom.properties
META-INF/maven/javax.sdp/jain-sdp/pom.xml
Note that these files should be added to jain-sdp.jar, not jain-sdp-sources.jar
5- Upload jain-sdp.jar to the Artifactory through UI
I think that these steps should be done manually. There is no other way to solve this problem that I can think of. sourceDirectories should be included manually to pom files and archives manually.
Add your Source files into your jar, observing the same directory structure as for the class file contents.
This means you don't need to manage another artifact and don't need to update your pom.xml
Simplest steps to perform this addition is on the CLI: change into your source directory and "update" the jar. Doing it with this specific current working directory which will preserve the correct relative filenames.
For example, I have directory structure:
~/project/src/com/mycompany
~/project/target
and have built a jar into ~/project/target named existing.jar
$ cd ~/project/src; jar uvf ../target/existing.jar com
$ jar tvf ~/project/target/existing.jar
should show class files and source files in the same tree.
...
6923 Sun Sep 18 23:19:36 PDT 2016 org/spacehq/reddit/util/http/ResponseType.class
4676 Sun Sep 18 22:30:38 PDT 2016 org/spacehq/reddit/util/http/ResponseType.groovy
...
IntelliJ IDEA detects these source files in the jar and presents them when opening the related class file. I'd assume other full featured IDEs would also.
You should of course be able to automate this somehow with Maven, to take out the human step, but this is good for a one-off.

Web resources filtering with Maven war plugin does not work in Eclipse with m2e

I'm trying to filter a Spring configuration file using Maven filtering. My POM is configured like this:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<targetPath>WEB-INF/context</targetPath>
<directory>src/main/webapp/WEB-INF/context</directory>
<includes>
<include>applicationContext.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
...
and
<profiles>
<profile>
<id>desarrollo</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<filters>
<filter>src/main/properties/dev.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>pruebas</id>
<build>
<filters>
<filter>src/main/properties/test.properties</filter>
</filters>
</build>
</profile>
...
It works great when invoking Maven directly.
Unfortunately, when hot-deploying the webapp in Tomcat 6 with Eclipse WTP and m2e it always picks the unfiltered version of applicationContext.xml. (The file applicationContext.xml in the folder target/m2e-wtp/web-resources/WEB-INF/context is never filtered)
I can't find any useful documentation on the subject. I'm not even sure if it is implemented in m2e.
Is something wrong with my configuration or this is an unimplemented feature?
Well, finally I got it.
First of all, I did what khmarbaise pointed out. I moved applicationContext.xml to the resources folder. War plugin webResources are meant to work with external resources, and filtering a file in the destination folder itself was not the best practice.
I updated the POM to reflect the new configuration
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
and
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<targetPath>WEB-INF/context</targetPath>
<directory>src/main/resources/WEB-INF/context</directory>
<includes>
<include>applicationContext.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
So, half of the credit to him.
But that's was not enough, it still didn't work.
I realized that Maven/m2e was indeed filtering my file, but it didn't get my defined properties files. After some testing I found out that m2e is ignoring the activeByDefault option in the profiles activation section.
So, I added my default profile to the project Maven configuration and then it worked
I had a similar problem with filtering the web.xml. I solved the problem by reimporting the whole project in eclipse.
The reason was a corrupt /.settings/org.eclipse.wst.common.component file. In this file the order of the files copied to the local web servers deploy directory is defined. For example:
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="liquidvote-rest">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="myapp"/>
<property name="java-output-path" value="/myapp/target/classes"/>
</wb-module>
</project-modules>
If the web.xml or application.xml exists in several directories it will be taken from the first directory found. Therefore its important that
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
is the first entry.
You will find more informations at http://wiki.eclipse.org/M2E-WTP_FAQ in the section "What is this web resources folder?"
Have you tried to put the resources under src/main/resources/WEB-INF/... instead of and configured the resources area to filter the resources instead of putting configuration into a non default maven location.
I just had a similar problem. My solution is not elegant and I am not proud of it, but let's say it is acceptable. In my case I have a spring boot mvc application with swagger application (for testers to test our API). The thing is we are using this app in two environments, so I created two profiles - dev and test. In dev env we would like to fire application from eclipse with just "run as" so the context path is blank (I know it can be set in spring java config, but it is not the only placeholder we would like to switch) and in test env the application is run in our customized version of tomcat... so the context path is the same as war file name.
and here is the problem - swagger is calling rest docs on this context path and it depends on spring profile. So we have a web resource that needs to be filtered. At first I tried to use m2e-wtp filtering:
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**/scripts.js</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
...
it was working but only run in embedded in eclipse tomcat or from commandline java -jar it was not working with "run as" from eclipse.
The resource was filtered and I saw them in web-resource in target, but eclipse seems to be running on a source code directly or is making a copy I do not know... it cannot see filtered resources... so I thought that I will make something like this:
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<filtering>true</filtering>
<directory>src/main/resources/webapp/swagger</directory>
<targetPath>${basedir}/src/main/webapp/swagger</targetPath>
<includes>
<include>scripts.js</include>
</includes>
</resource>
</resources>
It is not most fortunate solution, because it is modifing code and not the target, but at least it is working. If anyone would have any suggestions how to make it work without code modifications I would be greateful.
Today I had similar problem when several jars were included into war. I set the filtering on,and compared the original jars with filtered. They seem to be same,but this is not true. I tried to rename jar to zip and I was not able to unpack the content due to corrupted structure inside jar(zip) whereas the original one were ok. It is also mentioned here adding filtering web resources where is said that filtering has to be set false to prevent corrupting your binary files.
I've tried everything described above without success. The files were filtered and generated correctly at the "m2e-wtp" folder, but for some reason Eclipse was copying files from "target/classes".
Thus, I've changed my pom.xml, changing the destination folder from "m2e-wtp" to "target/classes", like code ahead.
Important: everytime you need to run a maven build on project, you must change the pom in order to build de project.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<filters>
<filter>${project.basedir}/src/main/filters/${build.profile.id}/config.properties</filter>
</filters>
<webResources>
<resource>
<filtering>true</filtering>
<directory>${project.basedir}/src/main/resources</directory>
<targetPath>${project.basedir}/target/classes</targetPath>
<includes>
<include>*.properties</include>
<include>*.xml</include>
<include>META-INF/spring/*.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>

How to debug an OSGi Bundle inside eclipse using maven structured project

I have a maven project which library should also be an OSGi bundle with an
declarative service. I added the OSGI-INF folder with the service.xml inside
src/java/resources which will be added to the jar. But: When I start the project as equinox project, where I want to check if the service is loaded, I get the error that the OSGI-INF/service.xml can't be found. I guess eclipse won't add the resources folder to the classpath when starting.
BTW: The MANIFEST-MF is in the root folder and the pom.xml contains the following text:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
Has anbody a good idea how to tell eclipse where to find the metadata files? I'm using m2eclipse if this is relevant.
Thanks in advance
Hannes
I've the same issues but I've manually tweaked my POM.xml for copying the generate target/classes/META-INF/** stuff (MANIFEST.MF, property files, spring XMLs, ...) into the project ROOT folder (which Eclipse PDE expects):
<!--
We copy all stuff from target/classes/META-INF into META-INF/ in order
to keep Maven output with PDE.
-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>synch-pde-metadata-from-maven</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/META-INF</outputDirectory>
<resources>
<resource>
<directory>target/classes/META-INF</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!--
We delete all stuff from the root bundle's META-INF
-->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>META-INF</directory>
<includes>
<include>**/*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
(I also clean up things when mvn clean is called) It is not really efficient but it works.
Ps: you may have to right-click on the project and make it a plug-in project in order for this to work.
The Problem is that Eclipse needs that OSGI-INF (and also META-INF) Folder in root.
I have found a link on how to probably solve the problem.
https://www.nuxeo.com/blog/working-with-osgi-and-maven-in-eclipse/
Basically they put the OSGI-INF and META-INF Folders into src/main/resources
Then they set the src/main/resources Folder as root of the OSGI project. So that Eclipse has both Folders at root.
To have Soure Files also available they added a Linked Resources to src/main/java by adding an entry to the .project File
<linkedResources>
<link>
<name>src</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/java</locationURI>
</link>
</linkedResources>
Now you just need to copy the .prject and .classpath Files into src/main/resources (your new root) and everything should be working.
By the time of this writing i didn't test this on my own but will do so in the near future.