I am able to successfully build a bundle with the bnd gradle plugin that includes a dependency jar, using -includeresource. However, when I try to build the directory of jar(s) to include programmatically, and try to include this entire directory into the bundle, like this:
jar {
dependsOn copyJars
// Build OSGI bundle, including the incompatible version of the transitive dependency
bnd('-exportcontents': 'com.example.foo',
'-sources': 'false',
'-includeresource': 'build/tmp/include/=lib/; lib:=true')
}
the copyJars task works (I can see the jar file has been copied), but then I get this error:
error : Input file does not exist: lib/
error : Input file does not exist: lib/
which does not make sense - lib/ is not an input, it's an output.
That's because it was given as an input file - it's the wrong way round. It should be:
'-includeresource': 'lib/=build/tmp/include/; lib:=true')
I'm following this tutorial: https://learn.microsoft.com/en-us/azure/hdinsight/storm/apache-storm-develop-java-topology
What I've done so far is
maven setting
vi *.java files (in src/main/java/com/microsoft/example directory)
RandomSentenceSpout.java
SplitSentence.java
WordCount.java
WordCountTopology.java
mvn compile
jar cf storm.jar *.class (in target/classes/com/microsoft/example directory)
RandomSentenceSpout.class SplitSentence.class WordCount.class WordCountTopology.class
The above 4 files were used to make storm.jar file
Then, I tried
storm jar ./storm.jar com.microsoft.example.WordCountTopology WordCountTopology
and
storm jar ./storm.jar WordCountTopology
, but both of these failed, saying:
Error: Could not find or load main class com.microsoft.example.WordCountTopology
or
Error: Could not find or load main class WordCountTopology
According to a document, it says
Syntax: storm jar topology-jar-path class ...
Runs the main method of class with the specified arguments. The storm
jars and configs in ~/.storm are put on the classpath. The process is
configured so that StormSubmitter will upload the jar at
topology-jar-path when the topology is submitted.
I cannot find where to fix.
How can I resolve this?
I think your jar file does not contain class WordCountTopology. You can check it with jar tf storm.jar | grep WordCountTopology.
Looks like your jar does not contain a Manifest file which keeps information about the main class.
Try including the Manifest file or you can run the below java command to include the Manifest file
Hope this works!
jar cvfe storm.jar mainClassNameWithoutDotClassExtn *.class
I am upgrading a springboot app from 1.X to 2.1.3.RELEASE. My Springboot is a multi module project setup which is triggered using a java command something similar to this.
java -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5088 -Drun.jvmArguments="-Xdebug" -Dloader.path=C:\code\build\libs\dir\ -jar C:\code\build/libs/core.jar --spring.config.location=C:\config\application.properties
This is how the project structure looks like
App
Common
Core (has the main class)
Sub
Before the upgrade : Manifest.mf file of core.jar looks like this
Manifest-Version: 3.2.15.signature.LOCALDEV
Project-Name: core
Built-By: dkumar
Built-Date: 2020-11-10 16:09
Project-Version: 3.2.15.signature.LOCALDEV
Spring-Boot-Version: 1.5.1.RELEASE
Main-Class: org.springframework.boot.loader.PropertiesLauncher
Git-Branch: signature
Start-Class: com.demo.Main
Spring-Boot-Classes: BOOT-INF/classes/
Git-Commit-Hash: signature
Project-Group: com.demo.print
Spring-Boot-Lib: BOOT-INF/lib/
After the upgrade. This what the manifest.mf file looks like
Manifest-Version: 3.1.87.upgradespring.LOCALDEV
Git-Branch: upgradespring
Project-Name: core
Built-By: dkumar
Built-Date: 2020-11-18 18:15
Start-Class: com.demo.Main
Git-Commit-Hash: upgradespring
Project-Group: com.demo.print
Project-Version: 3.1.87.upgradespring.LOCALDEV
Main-Class: org.springframework.boot.loader.JarLauncher
Before the upgrade the following property in my Core build.gradle took care of using org.springframework.boot.loader.PropertiesLauncher which inturn used -Dloader.path to load all the Sub (subprojects) jars on to the classpath
springBoot{
mainClass = "com.demo.Main"
layout = "ZIP"
}
After the upgrade, the layout property is now deprecated in 2.1.3.RELEASE and the Main-Class is now changed to Main-Class: org.springframework.boot.loader.JarLauncherand this doesn't support the usage of -Dloader.path (I think). Because of this I always get No bean found error when i try to invoke a class of Sub (subproject). This happens because -Dloader.path fails to include the JARS from subproject onto the classpath. Before the upgrade I could see the relevant jars on the class path.
I tried several ways to change the Main-Class attribute within the manifest to use PropertiesLaucher but none seem to have worked. I have also looked at the plugin documentation and tried something similar but that to didn't work
https://docs.spring.io/spring-boot/docs/2.1.3.RELEASE/gradle-plugin/reference/html/#packaging-executable-configuring-properties-launcher
I think by changing the Main-class I can solve this problem but I am not sure how to do that.
Any suggestions or idea would be helpful. All comments are welcome. I will update the question if the need arises.
I apologize in advance as i am unable to place a larger code snippet due corporate policies.
I was able to resolve this by adding the following properties
bootJar {
manifest {
attributes(
'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher',
'Spring-Boot-Classes': 'BOOT-INF/classes/',
'Spring-Boot-Lib': 'BOOT-INF/lib/'
)
}
}
Only this should work as well within the manifest:
'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher'
I am developing a plugin for BitBucket Server. Today, the Maven instance started throwing the following error after I changed the scope of one dependency:
[ERROR] Manifest com.my-plugin:integrationPlugin:atlassian-plugin:0.1-DEV : The default package '.' is not permitted by the Import-Package syntax.
This can be caused by compile errors in Eclipse because Eclipse creates
valid class files regardless of compile errors.
The following package(s) import from the default package null
[ERROR] Error(s) found in manifest configuration
After I reverted the change, the error did not go away.
I have tried solutions described in other StackOverflow posts, but they did not help me, since:
I am not using Eclipse
I have all packages declared in all my class files
The Bundle tool has this error fixed already
The manifest I got from the Maven debugging output is:
[DEBUG] Final Manifest:
#-----------------------------------------------------------------------
Manifest-Version: 1.0
Atlassian-Build-Date: 2019-04-04T11:44:27+0000
Atlassian-Plugin-Key: com.my-plugin.integrationPlugin
Bnd-LastModified: 1554378274635
Build-Jdk: 1.8.0_191
Built-By: egta136
Bundle-ClassPath: .,META-INF/lib/commons-logging-1.2.jar,META-INF/lib/pd
fbox-2.0.14.jar,META-INF/lib/fontbox-2.0.14.jar,META-INF/lib/ij-1.52n.j
ar
Bundle-Description: This is the com.my-plugin:integrationPlugin plu
gin for Atlassian Bitbucket Server.
Bundle-DocURL: https://example.com
Bundle-ManifestVersion: 2
Bundle-Name: integrationPlugin
Bundle-SymbolicName: com.my-plugin.integrationPlugin
Bundle-Vendor: Example
Bundle-Version: 0.1.0.DEV
Created-By: Apache Maven Bundle Plugin
Export-Package: com.my-plugin.integrationPlugin.api;version="0.1.0"
Import-Package:
com.apple.eawt;version=0;resolution:=optional,
com.atlassian.bitbucket.auth;version=0;resolution:=optional,
com.atlassian.bitbucket.commit;version=0;resolution:=optional,
com.atlassian.bitbucket.project;version=0;resolution:=optional,
com.atlassian.bitbucket.user;version=0;resolution:=optional,
com.atlassian.plugin.spring.scanner.annotation.export;version=0;resolut
ion:=optional,
com.atlassian.plugin.spring.scanner.annotation.imports;version=0;resolu
tion:=optional,
com.atlassian.sal.api;version=0;resolution:=optional,
com.atlassian.sal.api.pluginsettings;version=0;resolution:=optional,
com.atlassian.soy.renderer;version=0;resolution:=optional,
com.dizainsync.ddm.integrationPlugin.api;version=0;resolution:=optional
,
com.fasterxml.jackson.databind;version=0;resolution:=optional,
com.google.common.collect;version=0;resolution:=optional,
javax.crypto;version=0;resolution:=optional,
javax.crypto.spec;version=0;resolution:=optional,
javax.imageio;version=0;resolution:=optional,
javax.imageio.metadata;version=0;resolution:=optional,
javax.imageio.plugins.jpeg;version=0;resolution:=optional,
javax.imageio.stream;version=0;resolution:=optional,
javax.inject;version=0;resolution:=optional,
javax.script;version=0;resolution:=optional,
javax.servlet;version=0;resolution:=optional,
javax.servlet.http;version=0;resolution:=optional,
javax.swing;version=0;resolution:=optional,
javax.swing.event;version=0;resolution:=optional,
javax.swing.table;version=0;resolution:=optional,
javax.swing.text;version=0;resolution:=optional,
javax.swing.text.html;version=0;resolution:=optional,
javax.swing.tree;version=0;resolution:=optional,
javax.tools;version=0;resolution:=optional,
javax.xml.namespace;version=0;resolution:=optional,
javax.xml.parsers;version=0;resolution:=optional,
javax.xml.xpath;version=0;resolution:=optional,
org.apache.avalon.framework.logger;version=0;resolution:=optional,
org.apache.commons.fileupload;version=0;resolution:=optional,
org.apache.commons.fileupload.disk;version=0;resolution:=optional,
org.apache.commons.fileupload.servlet;version=0;resolution:=optional,
org.apache.commons.io;version=0;resolution:=optional,
org.apache.commons.lang3;version=0;resolution:=optional,
org.apache.log;version=0;resolution:=optional,
org.apache.log4j;version=0;resolution:=optional,
org.bouncycastle.asn1;version=0;resolution:=optional,
org.bouncycastle.asn1.cms;version=0;resolution:=optional,
org.bouncycastle.asn1.pkcs;version=0;resolution:=optional,
org.bouncycastle.asn1.x500;version=0;resolution:=optional,
org.bouncycastle.asn1.x509;version=0;resolution:=optional,
org.bouncycastle.cert;version=0;resolution:=optional,
org.bouncycastle.cms;version=0;resolution:=optional,
org.bouncycastle.cms.jcajce;version=0;resolution:=optional,
org.slf4j;version=0;resolution:=optional,
org.w3c.dom;version=0;resolution:=optional,
org.xml.sax;version=0;resolution:=optional,
com.atlassian.plugin.osgi.bridge.external
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Spring-Context: *
Tool: Bnd-3.5.0.201709291849
#-----------------------------------------------------------------------
What could be causing this? It is especially weird since reverting the changes to pom.xml did not get rid of the error.
The error was caused by the ImageJ dependency that I had. Apparently some of their classes use the default package which does not play well with maven. Removing the dependency fixes the issue.
I had a similar issue. To find out which dependency may prevent OSGi packaging to work, review error message like Classes found in the wrong directory: {META-INF/versions/9/module-info.class=module-info}
Using jcfind to identify its origin, as an example:
./target/classes/META-INF/lib/classgraph-4.8.43.jar META-INF/versions/9/module-info.class
I am contacting parent POM provider to get this fixed.
I am developing 2 jar files (jar1 and jar2 - the packaging type in pom.xml of 2 jars is jar) and installed them into serviceMix. Jar1 will use some packakes from jar2.
In the manifest.mf files, i used import and export for jar1 and jar2. After installing into serviceMix 4.3.0. Everything going almost fine. From jar 1, i can use packages in jar2 (i know that by debugging the code). But the problem is here:
The structure of Jar2:
jar2:/
.
com
abc
.......(classes)
META-INF
MANIFEST.MF
FactoryContext.xml
The short version of jar2's MANIFEST.MF is
Bundle-ClassPath: .
Bundle-Name: jar2
Bundle-SymbolicName: jar2
Bundle-Version: 1.0.0
Export-Package: com.abc
Import-Package: xyz
Tool: Bnd-1.50.0
Jar1 call a method of Jar2, that method is using bellow statement
context = new ClassPathXmlApplicationContext("FactoryContext.xml");
whenever it goes to this statement, it always throws exception say that FactoryContext.xml doesn not exist. (i guest this file is not in classpath)
Do you know how to make it work?
i also posted my question on ServiceMix forum and i have got the answer from Freeman-2.
Here is the answer
You can try to put FactoryContext.xml in a unique folder like META-
INF/MyFactoryContext/FactoryContext.xml, then jar2 also export package
META-INF.MyFactoryContext, and jar1 import package META-
INF.MyFactoryContext, and then should be able to use code like
context = new ClassPathXmlApplicationContext("META-INF/
MyFactoryContext/FactoryContext.xml");
in jar1.
Here is the link
http://servicemix.396122.n5.nabble.com/question-about-jar-bundle-and-classpath-td5602052.html