eclipse ear project error "the deployment descriptor of the module cannot be loaded or found" - m2eclipse

When importing a fully working maven ear project to eclipse I get a validation error for each included module. The messages all say:
The deployment descriptor of the module XXX cannot be loaded or found.
The project can be built successfully from the command line and the packaged EAR deploys perfectly.

The issue seems to be related to the way the wtp-m2e plugin loads the maven-ear-plugin configuration. It does not take the default EAR version into account and sets the project EAR facet version to 1.3.
The solution is to include the version explicitely in the maven -ear-plugin configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<version>7</version>
</configuration>
</plugin>

Related

Spring Boot build-image with Npm installed

I want to achieve the following: Packaging my Spring-Boot app into a Dockerimage where i can call a npx command in order to call a 3rd Party Node Library which i need in my App.
My Pom looks like this:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-image</goal>
</goals>
</execution>
</executions>
<configuration>
<image>
<name>my-app</name>
<buildpacks>
<buildpack>gcr.io/paketo-buildpacks/nodejs</buildpack>
<buildpack>gcr.io/paketo-buildpacks/java</buildpack>
</buildpacks>
</image>
</configuration>
</plugin>
</plugins>
</build>
Now with mvn package the plugin will be executed, but first:
it will fail with an error:
Invalid response received when loading image
"pack.local/builder/ayvwrfbvbm:latest"
However if i start the whole thing via pack the Image gets created
pack build my-app --builder paketobuildpacks/builder:base --buildpack paketo-buildpacks/nodejs --buildpack paketo-buildpacks/java
But in the created image i can not call node, nor npm nor npx, since it seems these layers are not added there.
If i then add a package.json and a server.js to my App-Root it seems that the npm-install layer is added but still i can not call node nor npm nor npx from within my container.
Please someone can show me a way how to create an image that runs a spring-boot app which then can call a 3rd party npm cli via
Runtime.getRuntime().exec("npx my3rdParty-cli");
A few notes.
When you add two buildpacks like --buildpack paketo-buildpacks/nodejs --buildpack paketo-buildpacks/java, it doesn't mean they will both run. Both will examine your code and determine if they can run, what is called the detection process, but ultimately only one of the two buildpack groups you've set will get picked to build your application.
When you run the build at the top, it'll print a list of the buildpacks selected to execute, so you can see exactly what's executing.
===> DETECTING
6 of 24 buildpacks participating
paketo-buildpacks/ca-certificates 3.2.4
paketo-buildpacks/bellsoft-liberica 9.4.0
paketo-buildpacks/syft 1.13.0
paketo-buildpacks/executable-jar 6.2.4
paketo-buildpacks/dist-zip 5.2.4
paketo-buildpacks/spring-boot 5.13.0
...
Right now, the Node.js buildpack and Java buildpacks are separate, so you'll either get one or the other. This is why it runs Java by default, but if you add a package.json file it runs Node.js. They are independent of each other.
There is an open issue to add Node.js into the Java buildpack group so that use cases like this can be supported.
If you are trying to use Node.js/NPM at build time, you can do something like in the demo here where you use a Maven plugin to install Node.js. It'll then be available if you need to perhaps build a front-end and bundle it with your Java app.
If you actually need Node.js/NPM at runtime, that's a trickier problem. 3.) isn't going to do that. You need something that would install Node.js into the actual runtime container. Having the support from 2.) would do that, but in the meantime, there are some options available. In particular, option 4.) from that link. You can use the apt-buildpack to install Node.js and then call out to it from your Java app.

best practices for java fx application build tool for linux

I trying to write a JavaFX application. When I built it using Netbeans, the RPM package does not work on CentOS 6.
Is there any fool proof way to build a JavaFX application for Linux?
Disclaimer: I'm the maintainer of the javafx-maven-plugin and creator of the javafx-gradle-plugin
When using maven, you can use the javafx-maven-plugin, just set the <bundler> to "rpm":
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.4.0</version>
<configuration>
<mainClass>your.path.to.your.MainClass</mainClass>
<verbose>true</verbose>
<bundler>rpm</bundler>
<bundleArguments>
<licenseFile>license.rtf</licenseFile>
</bundleArguments>
<!-- place your license here -->
<additionalAppResources>src/main/additionalAppResources</additionalAppResources>
</configuration>
</plugin>
Then just call mvn jfx:native on the command-line to create your rpm-package having your application including the JRE inside. If you don't want the JRE sit inside the RPM-package, just add <runtime /> to the bundleArguments.
When using gradle, just look at the project-website on github ;) or ask me via mail if something is unclear.
EDIT
As a temporary workaround, please set appName to something without a dot
<configuration>
<!-- other configuration elements -->
<appName>SimpleApplicationNameWithoutDot</appName>
</configuration>

javafx self-contained package

I created the javafx standalone application using netbeans by copying the following snippet into build.xml file
<target name ="-post-jfx-deploy">
<fx:deploy width="${javafx.run.width}" height="${javafx.run.height}"
nativeBundles="all"
outdir="${basedir}/${dist.dir}" outfile="${application.title}">
<fx:application name="${application.title}" mainClass="${javafx.main.class}"/>
<fx:resources>
<fx:fileset dir="${basedir}/${dist.dir}" includes="*.jar"/>
</fx:resources>
<fx:info title="${application.title}" vendor="${application.vendor}"/>
</fx:deploy>
</target>
I had jdk environment for x64 bit version so it created application that runs in only x64 bit version of windows or operating systems. Can anyone tell how should I change the deploy method to make application runnable on x86 bit systems. By default netbeans took up 64bit version of jdk environment
You could combine Maven with Ant on the following way:
Defining a Maven artifact for JDK
Using maven-dependency-plugin
Using unzip Ant task
Using <fx:platform>
Defining Maven artifact for JDK
Defining Maven artifacts for JDK x86 and JDK x64. It may sounds weird at first time, but thinking in a continuous integration environment, it makes sense at all.
You just zip an ordinary JDK folder and deploy it as a Maven artifact.
Then your Maven project will depend on:
<properties>
<jdk.version>1.8.112</jdk.version>
<!-- can be '64' or '32' -->
<cpu.arch>64</cpu.arch>
</properties>
</dependencies>
<!-- other dependencies goes here -->
<dependency>
<groupId>com.my.company</groupId>
<artifactId>jre-linux-${cpu.arch}</artifactId>
<version>${jre.version}</version>
<type>zip</type>
<scope>runtime</scope>
</dependency>
</dependencies>
Note: I'm running on Debian, but it's totally applicable to Windows environment too.
Using maven-dependency-plugin
Add the maven-dependency-plugin. It will copy all your dependencies (includind your JDK zip file defined on dependencies section) to the /target/dist/lib folder.
We'll use it soon.
The plugin configuration looks like:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${application.dist}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
Using unzip Ant task
Now before your JavaFX Ant tasks, you must tell Ant to extract your JDK dependency into a folder.
It must be set BEFORE the task who will bundle your JavaFX application.
<unzip src="${application.dist}/lib/jdk-linux-${cpu.arch}-${jdk.version}.zip"
dest="${extra.dir}/jdk"/>
Using <fx:platform>
And finally, at your <fx:deploy> tag you must add a <fx:platform> child tag, adding the basedir attribute as your previous jdk folder, like:
<fx:deploy ...>
<fx:platform javafx="8.0+" basedir="${extra.dir}/jdk" />
</fx:deploy>
The Maven logs will be similar to this:
[INFO] --- maven-antrun-plugin:1.7:run (default) # my-app ---
[INFO] Executing tasks
main:
[unzip] Expanding: /home/danilo/development/temp/my-app/target/dist/lib/jdk-linux-64-1.8.112.zip into /home/danilo/development/temp/my-app/target/extras/jdk
Using base JDK at: /home/danilo/development/temp/my-app/target/extras/jdk/jre
Using base JDK at: /home/danilo/development/temp/my-app/target/extras/jdk/jre
Creating app bundle: /home/danilo/development/temp/my-app/target/dist/bundles/my-app
Debian packages should specify a license. The absence of a license will cause some linux distributions to complain about the quality of the application.
Using default package resource [menu icon] (add package/linux/my-app.png to the class path to customize)
Using default package resource [Menu shortcut descriptor] (add package/linux/my-app.desktop to the class path to customize)
Using default package resource [DEB control file] (add package/linux/control to the class path to customize)
Using default package resource [DEB preinstall script] (add package/linux/preinst to the class path to customize)
Using default package resource [DEB prerm script] (add package/linux/prerm to the class path to customize)
Using default package resource [DEB postinstall script] (add package/linux/postinst to the class path to customize)
Using default package resource [DEB postrm script] (add package/linux/postrm to the class path to customize)
Using custom package resource [DEB copyright file] (loaded from package/linux/copyright)
dpkg-deb: construindo pacote 'my-app' em '/home/danilo/development/temp/my-app/target/dist/bundles/my-app-1.0.deb'.
Package (.deb) saved to: /home/danilo/development/temp/my-app/target/dist/bundles/my-app-1.0.deb
Config files are saved to /tmp/fxbundler8773603423891700338/linux. Use them to customize package.
Bundler RPM Bundle skipped because of a configuration problem: Can not find rpmbuild {0} or newer.
Advice to fix: Install packages needed to build RPM, version {0} or newer.
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8:34.875s
[INFO] Final Memory: 22M/253M
[INFO] ------------------------------------------------------------------------
Conclusion
When you need to deliver your application on a x86 environment, just override the cpu.arch Maven property at build time:
mvn -Dcpu.arch=32 clean install
Now it's easier to set up your continuous integration. If you would use Jenkins CI, for example, you can create 2 different jobs and run it as needed.
I pushed the whole project to a Github repository. You can check it here: https://github.com/daniloguimaraes/javafx-multiple-jre-versions

java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet

I am getting this error, when executing JSF and PrimeFaces.
I have included these jars,
jsf-api-2.0.3.jar,
jsf-impl-2.0.3.jar ,
jstl-1.0.2.jar jars and
primefaces-2.2.RC2.jar
in the WEB-INF/lib folder.
Is there any jar I am missing?
Right click on project properties and follow below steps
"Project Properties" --> "Deployment Assembly", adding
"Java Build Path Entries" -> "Maven Dependencies" solves the problem!
Apparently, you're not missing anything else. Just try to do the following:
Ensure that the necessary jars exist in the "lib" project folder;
Do clean & build;
In the end, you should find those included jars, available within the "build" project folder.
Right click on project properties and follow below steps
"Project Properties" --> "Deployment Assembly", adding "Java Build Path Entries" ->jsf 2.0 (mojarra 2.0.3-fcs) solved my problems
I added jsf 2.0 & mojarra 2.0.3-fcs in POM and it fixed my problem.
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.4.0</version>
</dependency>
You can also do this, which solved my problem.
Right click on your project->properties->project facets->java server faces.
Then if the disabled library configuration option has selected, then change it to user library and then add mojarra's latest version and press OK button and try run the project again...
It should help.
If you tried to convert your simple java project to web project using maven and changing specificications from project facets, you won't get a compile error but when you start deployment you can see this error message.
to solve this think of it. This is a web project and needs to deploy as a war file (or ear).
change packaging spec to war in your pom.xml then compile maven again.
Download JAR's from here: http://myfaces.apache.org/download.html
Copy them to TOMCAT lib directory.
Add to Tomcat web.xml these lines from screenshot:
listener
Adding below jars to path ..WebContent\WEB-INF\lib and a maven update solved the problem.
jsf-api
jsf-impl
I had a similar issue and solved after running Maven Update a couple of times when it finally solved the issue. Running only once was not enough because the jar file was still corrupt so you need to make sure it opens with any compression tool like winzip or gzip.

Build and include JSF taglib as jar in a Dynamic Web Project using Maven

I am working on a JSF taglib. To test it I compile it to a JAR as described here and add it manually to a Dynamic Web Project (In the WEB-INF/lib directory).
I know that this step can be automated, but I do not know how. Can anybody explain how to copy a generated jar to a second project in Eclipse?
Thanks in advance!
quite some steps to do :)
add a pom.xml into your project and follow the maven directory structure. use packaging "jar" for the taglib project. Lets assume you use groupId=com.company.taglib artifactId=company-taglib version=1.0.0-SNAPSHOT
if you do a mvn install on this project it will copy the jar into your local maven repository (usually found at ~/.m2/ - now maven can resolve the dependency on your local machine
add a pom.xml to your webproject, use packaging "war" and add the taglib project as a dependency (within <dependencies> in pom.xml).
<dependency>
<groupId>com.company.taglib</groupId>
<artifactId>company-taglib</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
Maven will resolve this dependency from your local repository. In Eclipse using the m2e Plugin it will resolve the project directly.
To "publish" the taglib.jar you need an infrastructure to share artifacts. Usually using a repository proxy (Sonatype Nexus or Artifactory). You can also use a network folder using the file:// protocol for quick startup.
In the pom.xml you need to add the <distributionManagement> section (in the taglib pom.xml) to specify the folder / proxy the artifacts are uploaded to. A mvn deploy will then build and copy the jar file for you.
Other developers need to add that location as repository in settings.xml (I dont recommend doing that in pom.xml) or if you setup a maven proxy configure a mirrorOf in settings.xml
There are archteypes available (project templates) that will help you creating initial project structures: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
see also: http://maven.apache.org/guides/getting-started/index.html

Resources