Thursday, February 2, 2017

Translate jardesc content into jar-command

Leave a Comment

I am making some WebFilters for our WebLogic server and I've got everything up and running.

The problem is how I package the filters into jar-files. If I use the following jardesc-file and create the jar-file from Eclipse, everything is working fine and WebLogic has no problems loading the webfilter class. But as soon as I try to manually create the jar-file using just jar.exe I am hitting ClassNotFoundExceptions when loading the webcontainer in WebLogic.

Working jardesc-file:

<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?> <jardesc>     <jar path="C:/Workspace/Java/Jars/jars/corsfilter.jar"/>     <options buildIfNeeded="true" compress="true" descriptionLocation="/CorsFilter/corsfilter.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>     <storedRefactorings deprecationInfo="true" structuralOnly="false"/>     <selectedProjects/>     <manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">         <sealing sealJar="false">             <packagesToSeal/>             <packagesToUnSeal/>         </sealing>     </manifest>     <selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">         <file path="/CorsFilter/.project"/>         <file path="/CorsFilter/.classpath"/>         <javaElement handleIdentifier="=CorsFilter/src"/>     </selectedElements> </jardesc> 

Current jar-command:

jar -cvf corsfilter.jar .project .classpath -C .\bin dk\akait\filters\cors\CorsFilter.class 

The jar-command creates a jar-file that seems to be equivalent to the one generated using the jardesc-file in Eclipse, except for what looks like some kind of symbolic link to the META-INF-folder in the root of the jar-file.

Content of working jar-file: Working jar-file

Content of non-working jar-file enter image description here

Can anyone explain what the right command for executing jar.exe is, given the jardesc-file?

Or

Can anyone explain what the META-INF file in the not working jar-file is?

Updated with output of jar-command run using jdk-1.8.0_111 Output of jar-command

1 Answers

Answers 1

I don't think your command line is even correct. As according to jar output

Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...

And also http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jar.html

It is expect to be [manifest-file] and [entry-point] after [jar-file] name.

Try jar -cvf corsfilter.jar -C . .project .classpath -C .\bin dk\akait\filters\cors\CorsFilter.class

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment