MANIFEST.MF issue with jhall.jar - eclipse

i have created a jar-file (DicoDB.jar) with Eclipse in the folder called 'program-jar'. Inside a subdirectory 'javahelp' are the following jar-files: jhall.jar, hsviewer.jar, jh.jar and dicoDBHelp.jar (this is my jar-file which contents my help-application).
In the top directory 'program-jar' are also the following jars: jgraph.jar, gnujpdf.jar.
This is my MANIFEST.MF: (The file is manually created)
Manifest-Version: 1.0
Main-Class: gui.DicoDB
Class-Path: jgraph.jar
gnujpdf.jar
javahelp/jhall.jar
javahelp/hsviewer.jar
javahelp/jh.jar
javahelp/dicoDBHelp.jar
At the end of the file is an empty line.
Now I execute the DicoDB.jar in my terminal. Everything works fine until I want to open my help-file (dicoDBHelp.jar).
I get the following exception:
java.lang.NoClassDefFoundError: javax/help/JHelp
The JHelp class is contained by jhall.jar.
Now I don't undertand why the program does not find the class.
So i hope somebody can help me.

Just a thought: try to put all jars in the same line as Class-Path: .... separated by spaces.

Related

How to determine resources for fatjar?

I build my scala project with https://github.com/sbt/sbt-assembly to get a fatjar.
The structure of the project looks as following(You can see the resources folder, that contains a file SapConfig.json):
Then, I tried to execute the fatjar as following:
java -jar SapEvents-assembly-0.1.0.jar
java.nio.file.FileSystemNotFoundException
at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171)
at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157)
at java.nio.file.Paths.get(Paths.java:143)
at ch.micarna.SapEventServer$.stream(SapEventServer.scala:22)
at ch.micarna.SapEventServer$.stream(SapEventServer.scala:16)
at fs2.StreamApp.$anonfun$runStream$1(StreamApp.scala:66)
at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:128)
at cats.effect.internals.IORunLoop$.start(IORunLoop.scala:35)
at cats.effect.IO.unsafeRunAsync(IO.scala:257)
at cats.effect.IO.$anonfun$runAsync$1(IO.scala:175)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at cats.effect.internals.IORunLoop$.step(IORunLoop.scala:167)
at cats.effect.IO.unsafeRunTimed(IO.scala:304)
at cats.effect.IO.unsafeRunSync(IO.scala:239)
at fs2.StreamApp.main(StreamApp.scala:83)
at ch.micarna.SapEventServer.main(SapEventServer.scala)
As you can recognize, I assume that the resource file could not be found.
The code, that read the resource file looks as following:
Paths.get(getClass.getClassLoader.getResource("SapConfig.json")
Where should I put my resource file?
I think your solution is in this post.
Change only
src/main/webapp to src/main/resources

Debugging OfBiz in Eclipse gives MissingResourceException

I downloaded the OfBiz Java application and the following line throws an MissingResourceException:
ResourceBundle res = ResourceBundle.getBundle(settingsResourceName);
The value of settingsResourceName is "cache", but I cannot find any file called cache.properties or cache_en.properties.
Where should I be looking? I'm new to Java. All my research on SO says there should be such a file.
I imported OfBiz in Eclipse using the Import menu option and selecting Existing Project from File System (I'm not in front of my dev machine so I don't remember the exact wording). But I chose the root folder of the downloaded OfBiz.
I then added the appropriate VM Arguments in the Run Configuration to get it to run properly at least. And that's it, on the first Run I got the above error. I think it has to do with a missing class path but I don't know what to add to class path.
Here is the stack trace:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.ofbiz.base.util.Debug.<clinit>(Debug.java:68)
at org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:61)
at org.apache.ofbiz.base.start.StartupControlPanel.loadStartupLoaders(StartupControlPanel.java:202)
at org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:69)
at org.apache.ofbiz.base.start.Start.main(Start.java:84)
Caused by: java.util.MissingResourceException: Can't find bundle for base name cache, locale en
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:773)
at org.apache.ofbiz.base.util.cache.UtilCache.setPropertiesParams(UtilCache.java:174)
at org.apache.ofbiz.base.util.cache.UtilCache.setPropertiesParams(UtilCache.java:170)
at org.apache.ofbiz.base.util.cache.UtilCache.setPropertiesParams(UtilCache.java:166)
at org.apache.ofbiz.base.util.cache.UtilCache.<init>(UtilCache.java:124)
at org.apache.ofbiz.base.util.cache.UtilCache.createUtilCache(UtilCache.java:769)
at org.apache.ofbiz.base.util.UtilProperties.<clinit>(UtilProperties.java:75)
... 5 more
UPDATE:
My mistake, I found two files both called cache.properties in the following folders:
ofbiz-trunk/build/resources/main
ofbiz-trunk/framework/base/config
But these are folders, not packages. I tried putting them in the .classpath but that did not work, I still kept getting the same error.
As suspected, I knew it was because of a missing reference to a class path. After looking at a section on this page: http://www.opensourcestrategies.com/ofbiz/ofbiz_eclipse.php, I learned that I was supposed to go to the Java Build Path and in the Libraries tab, click on Add Class Folder, then point that to ofbiz-trunk/framework/base/config. Which is where I have one of the cache.properties files.

netbeans manifest.mf is read-only because it is inside

I want to change contains of file Meta-inf/Manifest.mf . I try this:
org.openide.filesystems.FileObject projectDirectory = project.getProjectDirectory();
FileObject modulesFileObject = projectDirectory.getFileObject("build/cluster/modules/");
properties.store(propertiesFile.getOutputStream(), null);
but I got this Exeption:
manifest.mf is read-only because it is inside.
Jar file is not read-only. So can you help me, please?
PS: I use NetBeans Platform RCP 7.11 , java 1.7_07
Thank Jirka
The problem is, that the JarSystem is read-only.
Jirka

Error reading manifest file "...datanucleus-core-3.0.0-release.jar!/plugin.xml"

I got a very strange error. This what I've done:
I create a project (with Netbeans) which include datanucleuse-core-3.0.0-release.jar. The project can be built successfully. It also ran smoothly when I tried to run it with Netbeans or running 'java -jar <.jar bundle>' in dist folder via command prompt.
The problem is, when I copy that dist folder into another location and tried to run it again with command prompt, it gave these errors:
Exception in thread "main" Error reading manifest file
"jar:file:/E:/!new/BTJ/NCRServer/lib/datanucleus-core-3.0.0-release.jar!/plugin.xml"
org.datanucleus.exceptions.NucleusException: Error reading manifest
file "jar:fi
le:/E:/!new/BTJ/NCRServer/lib/datanucleus-core-3.0.0-release.jar!/plugin.xml"
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonMan
agedPluginRegistry.java:481)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(No
nManagedPluginRegistry.java:219)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensionPoin
ts(NonManagedPluginRegistry.java:160)
at org.datanucleus.plugin.PluginManager.(PluginManager.java:62)
at org.datanucleus.NucleusContext.(NucleusContext.java:211)
at org.datanucleus.NucleusContext.(NucleusContext.java:166)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.(JDOPersis
tenceManagerFactory.java:360)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.createPersistenc
eManagerFactory(JDOPersistenceManagerFactory.java:290)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceMa
nagerFactory(JDOPersistenceManagerFactory.java:191)
at com.ncr.server.Server.(Server.java:68)
at com.ncr.server.Server.main(Server.java:91) Caused by: java.io.FileNotFoundException: E:\ (The system cannot find the path s
pecified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:114)
at java.util.jar.JarFile.(JarFile.java:135)
at java.util.jar.JarFile.(JarFile.java:99)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonMan
agedPluginRegistry.java:390)
... 10 more Nested Throwables StackTrace: java.io.FileNotFoundException: E:\ (The system cannot find the path
specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:114)
at java.util.jar.JarFile.(JarFile.java:135)
at java.util.jar.JarFile.(JarFile.java:99)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonMan
agedPluginRegistry.java:390)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(No
nManagedPluginRegistry.java:219)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensionPoin
ts(NonManagedPluginRegistry.java:160)
at org.datanucleus.plugin.PluginManager.(PluginManager.java:62)
at org.datanucleus.NucleusContext.(NucleusContext.java:211)
at org.datanucleus.NucleusContext.(NucleusContext.java:166)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.(JDOPersis
tenceManagerFactory.java:360)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.createPersistenc
eManagerFactory(JDOPersistenceManagerFactory.java:290)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceMa
nagerFactory(JDOPersistenceManagerFactory.java:191)
at com.ncr.server.Server.(Server.java:68)
at com.ncr.server.Server.main(Server.java:91)
Anybody got clue ?
I am really sorry for everyone, especially for datanucleus members in StackOverflow.
Apparently the problem is me, not the netbeans, datanucleus API, nor anyone.
As you can see from "jar:file:/E:/!new/BTJ/NCRServer/lib/datanucleus-core-3.0.0-release.jar!/plugin.xml", I put the "dist" folder from Netbeans in "E:/!new" folder. I don't know why but the "!new" folder seems to cause the extra exclamation mark(!) in "release.jar!".
I move the dist folder into D:/ and it worked !!
So, if anyone ever experience this problem (precedence a folder's name with exclamation mark and accidentally put a project with datanucleus-core-3.0.0-release.jar inside it), that's the solution.
Thank you.

Intellij Idea 10.5 and Maven+GWT - Cannot resolve directory

I created maven project with command line:
mvn archetype:generate
-DarchetypeRepository=repo1.maven.org
-DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin
-DarchetypeVersion=2.3.0-1
Then I opened it in Intellij Idea 10.5, and received some errors from Maven Model Inspector:
Cannot resolve directory ''${webappDirectory}'' (at line 59)
Cannot resolve directory 'WEB-INF' (at line 59)
Cannot resolve file 'classes' (at line 59)
In spite of this the project compile and run normally. What is this?
Part of my pom.xml:
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
. . .
</build>
in the beginning of your pom.xml file in the properties section there should be this tag:
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
That's where the ${webappDirectory} "variable" is defined.
When you place the cursor over the text inside the brackets and press ctrl + q, you will see a small explanation for the variables (Intellj Idea specific)
${project.build.directory} = Model Property project.build.directory: ${project.basedir}/target
${project.build.finalName} = Model Property project.build.finalName: ${project.artifactId}-${project.version}
<outputDirectory>...</outputDirectory> configures where the compiled classes are put (As the comment above your snippet already says).
Have a look into your projectDir/target directory.
But I can't tell you what this means for development mode.
Btw. i've put <!--suppress MavenModelInspection --> above <outputDirectory> to get rid of the red mark in the editor.
Whoops, that seems to be a pretty old question :)
Guess you already know!
Regards