Jars in the class path of a custom component
I am using the dom4j-1.6.1.jar library in a custom component, but my JBoss server has dom4j.jar in jboss\server\all\lib. My custom component is throwing the following error:
DefFoundError message:org/dom4j/xpath/DefaultXPath while invoking service XmlToCsvService and operation convert and no fault routes were found to be configured.
This makes me suspect that the version of Dom4J in the lib directory of the server is taking precedence over the one in my component. Any suggestions for how to deal with this? Thanks.
Jared Langdon
Even Marcel's suggestion may not always work, but it certainly is worth a quick try. I seem to remember trying that and finding that one of the LiveCycle EAR files has a version of dom4j buried inside it (I don't remember which version of LC it was).
Of course altering an Adobe supplied EAR is not recommended and may violate your support ageement. There is an alternative, however; if changing the JBoss lib folder doesn't work. To avoid the conflict you can use JarJar to rename the packages within the DOM4J class and deploy the renamed jar with your component to avoid the conflict.
http://code.google.com/p/jarjar/
You would then use the renamed classes in your component:
import org.mypackage.dom4j.Document;
import org.mypackage.dom4j.DocumentException;
import org.mypackage.dom4j.DocumentHelper;
import org.mypackage.dom4j.Element;
import org.mypackage.dom4j.Node;
import org.mypackage.dom4j.io.DOMReader;
import org.mypackage.dom4j.io.DOMWriter;
Similar Messages
-
Jar's manifest Class-Path option
Hey, hopefully this is my last question for a while.
I downloaded a custom look and feel that's packaged in a jar file.
Here's the directory structure.
Main-Program\*.class
Main-Program\MyProgram.jar (the created jar)
Main-Program\Data\kunststoff.jar (downloaded look&feel jar)
I can compile the class files like this:
javac -classpath .;Data\kunststoff.jar MainClass.java
and run it like this:
java.exe -classpath .;Data\kunststoff.jar MainClass
This works fine. But I want my program to be an executable jar.
So I create the exec. jar like usual
jar cf0 MyProgram.jar *.class
jar umf mainclass.txt MyProgram.jar
When I package the jar using the manifest file I include the Class-Path var:
Manifest-Version: 1.0
Main-Class: Database
Class-Path: .;Data\kunststoff
Now when I try to execute the jar it gives me the error:
"Could not find the main class. Program will exit!"
Any ideas? thanks.Manifest-Version: 1.0
Main-Class: Database
Class-Path: .;Data\kunststoff>
Better change that to "Class-Path: Data/kunststoff.jar"
(http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html)
And remember to have a line break after it..
Now when I try to execute the jar it gives me the
error:
"Could not find the main class. Program will exit!">
But the main class should still be found even if the class-path entry was not totally correct, does Database.class show in jar tf MyProgram.jar? -
Jar: Manifest-Attribute "Class-Path"
I've got a problem with the Class-Path-attribute of the JARs manifest-file. So I've written a real simple application to test where the problems occure... but even this trivial app does not work!
The execution starts at "Starter.java":
public class Starter{
public static void main(String args[]){
packageOne.Caller.callWriter();
}The class "Caller" is in a JAR ("Caller.jar") in the same directory as Starter.java.
Caller.java:
package packageOne;
public class Caller{
public static void callWriter(){
packageTwo.Writer.write("Write this");
}The class "Writer" is in a JAR ("Writer.jar") in the same directory as Starter.java and Caller.jar.
Writer.java:
package packageTwo;
public class Writer{
public static void write(String message){
System.out.println(message);
}The file Caller.jar consists of Caller.class and the Manifest.mf. The package-structur/the path seams to be all right.
The file Writer.jar consists of Writer.class and the Manifest.mf. The package-structur/the path seams to be all right.
If I invoke the Starter with:
java Starter -classpath Caller.jar;Writer.jareverything's fine.
Now, I added the following line to the Manifest.mf of Caller.jar:
Class-Path: Writer.jar(with one empty line between Manifest-Version: 1.0 and the new line.
So... shouldn't it be possible now, to invoke the application with:
java Starter -classpath Caller.jar ???
It doesn't work. So: what have I misunderstood?
(The error message is:
Exception in thread "main" java.lang.NoClassDefFoundError: packageTwo/Writer
at packageOne.Caller.callWriter(packageOne/Caller.java:5)
at Starter.main(Starter.java:3)Hmmm, I tested it and here are the command I ran and their results. Try doing the same on your computer:aleph% mkdir packageOne
aleph% mkdir packageTwoThat created the directories.aleph% cat > Starter.java
public class Starter{
public static void main(String args[]){
packageOne.Caller.callWriter();
aleph% cat > packageOne/Caller.java
package packageOne;
public class Caller{
public static void callWriter(){
packageTwo.Writer.write("Write this");
aleph% cat > packageTwo/Writer.java
package packageTwo;
public class Writer{
public static void write(String message){
System.out.println(message);
}That created the source files: Starter.java in the current directory, Caller.java under packageOne and Writer.java under packageTwo. Next the compiling and creating the manifest file:aleph% javac Starter.java
aleph% cat > MF
Class-Path: Writer.jarThat created additional info to be included in manifest file and put it in a file called MF.
Then I package "caller.jar" with the manifest and "Writer.jar" without it:aleph% jar -cmf MF caller.jar packageOne
aleph% jar -cf Writer.jar packageTwoDelete the package* directories so java wont get confused...aleph% rm -r package*And finally run the thing. Remember that the path separator is : in unix but ; in DOS, if that is what you are using.aleph% java -cp .:caller.jar Starter
Write thisNo problems anywhere. What are the steps you did? -
Problem: Multiple jar files in Class-Path [ IOException: line too long]
Hello Folks,
I am trying to create a jar file using the following command:
jar -cvfm mygrid.jar MANIFEST.MF -C grid-jar/ .
My MANIFEST.MF file is as following:
Manifest-Version: 1.0
Main-Class: com.gridftp.INSPgridFTP
Class-Path: lib/activation.jar lib/ant.jar lib/antlr.jar lib/axis.jar lib/castor-0.9.3.jar lib/cog-abstraction-common-2.0.jar lib/cog-abstraction-examples-2.1.jar lib/cog-certmanagement-1.0.jar lib/cog-certrequest-1.0.jar lib/cog-grapheditor-0.46.jar lib/cog-gridfaces-1.0.jar lib/cog-gridshell-1.0.jar lib/cog-jglobus-1.2-050621.jar lib/cog-karajan-0.31.jar lib/cog-provider-clref-gt3_0_2.jar lib/cog-provider-clref-gt3_2_0.jar lib/cog-provider-clref-gt3_2_1.jar lib/cog-provider-clref-gt4_0_0.jar lib/cog-provider-condor-2.0.jar lib/cog-provider-gt2-2.0.jar lib/cog-provider-gt2ft-1.0.jar lib/cog-provider-gt3_0_2-2.0.jar lib/cog-provider-gt3_2_0-2.0.jar lib/cog-provider-gt3_2_1-2.0.jar lib/cog-provider-gt4_0_0-2.2.jar lib/cog-provider-local-2.0.jar lib/cog-provider-ssh-2.0.jar lib/cog-provider-webdav-1.0.jar lib/cog-resources-1.0.jar lib/cog-setup-0.91.jar lib/cog-util-0.91.jar lib/commons-discovery.jar lib/commons-httpclient.jar lib/commons-logging.jar lib/concurrent.jar lib/cryptix32.jar lib/cryptix-asn1.jar lib/cryptix.jar lib/j2ssh-common-0.2.2.jar lib/j2ssh-core-0.2.2.jar lib/jaas.jar lib/jakarta-regexp-1.2.jar lib/jakarta-slide-webdavlib-2.0.jar lib/jaxrpc.jar lib/jce-jdk13-125.jar lib/jgss.jar lib/jug-1.0.1.jar lib/junit.jar lib/log4j-1.2.8.jar lib/mail.jar lib/puretls.jar lib/saaj.jar lib/wsdl4j.jar lib/xercesImpl.jar lib/xml4j.jar lib/xml-apis-1.1.jar lib/xmlsec.jar lib/xpp3-1.1.3.4d_b4_min.jar lib/xstream-1.1.1-patched.jar .
The grid-jar directory structure is:
| - com -- all classes are under this dir.
| - lib -- all the required jar files are in this dir.
There are 59 jar files in the lib directory. When I try to create the jar file, I get the following exception:
jar -cvfm mygrid.jar MANIFEST.MF -C grid-jar/ .
java.io.IOException: line too long
at java.util.jar.Attributes.read(Attributes.java:356)
at java.util.jar.Manifest.read(Manifest.java:167)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:124)
at sun.tools.jar.Main.main(Main.java:904)
Any idea, why do I get this exception? Is there any restriction as to how many jar files (or characters) can be there in the Class-Path value in the MANIFEST.MF file?
Please help.
Thanks,
Anause as the following way to resolve the problem:
(1) use separate lines, to avoid too long a line for java package name lists
(2) type a preceding space before each folloing lines, for example:
Class-Path: ...jar ...jar ...jar
...jar ..jar
...jar ...jar
...jar ...jar
Hello Folks,
I am trying to create a jar file using the following
command:
jar -cvfm mygrid.jar MANIFEST.MF -C grid-jar/ .
My MANIFEST.MF file is as following:
Manifest-Version: 1.0
Main-Class: com.gridftp.INSPgridFTP
Class-Path: lib/activation.jar lib/ant.jar
lib/antlr.jar lib/axis.jar lib/castor-0.9.3.jar
lib/cog-abstraction-common-2.0.jar
lib/cog-abstraction-examples-2.1.jar
lib/cog-certmanagement-1.0.jar
lib/cog-certrequest-1.0.jar
lib/cog-grapheditor-0.46.jar
lib/cog-gridfaces-1.0.jar lib/cog-gridshell-1.0.jar
lib/cog-jglobus-1.2-050621.jar
lib/cog-karajan-0.31.jar
lib/cog-provider-clref-gt3_0_2.jar
lib/cog-provider-clref-gt3_2_0.jar
lib/cog-provider-clref-gt3_2_1.jar
lib/cog-provider-clref-gt4_0_0.jar
lib/cog-provider-condor-2.0.jar
lib/cog-provider-gt2-2.0.jar
lib/cog-provider-gt2ft-1.0.jar
lib/cog-provider-gt3_0_2-2.0.jar
lib/cog-provider-gt3_2_0-2.0.jar
lib/cog-provider-gt3_2_1-2.0.jar
lib/cog-provider-gt4_0_0-2.2.jar
lib/cog-provider-local-2.0.jar
lib/cog-provider-ssh-2.0.jar
lib/cog-provider-webdav-1.0.jar
lib/cog-resources-1.0.jar lib/cog-setup-0.91.jar
lib/cog-util-0.91.jar lib/commons-discovery.jar
lib/commons-httpclient.jar lib/commons-logging.jar
lib/concurrent.jar lib/cryptix32.jar
lib/cryptix-asn1.jar lib/cryptix.jar
lib/j2ssh-common-0.2.2.jar lib/j2ssh-core-0.2.2.jar
lib/jaas.jar lib/jakarta-regexp-1.2.jar
lib/jakarta-slide-webdavlib-2.0.jar lib/jaxrpc.jar
lib/jce-jdk13-125.jar lib/jgss.jar lib/jug-1.0.1.jar
lib/junit.jar lib/log4j-1.2.8.jar lib/mail.jar
lib/puretls.jar lib/saaj.jar lib/wsdl4j.jar
lib/xercesImpl.jar lib/xml4j.jar lib/xml-apis-1.1.jar
lib/xmlsec.jar lib/xpp3-1.1.3.4d_b4_min.jar
lib/xstream-1.1.1-patched.jar .
The grid-jar directory structure is:
| - com -- all classes are under this dir.
| - lib -- all the required jar files are in
e in this dir.
There are 59 jar files in the lib directory. When I
try to create the jar file, I get the following
exception:
jar -cvfm mygrid.jar MANIFEST.MF -C grid-jar/ .
java.io.IOException: line too long
at
at
at
at
java.util.jar.Attributes.read(Attributes.java:356)
at
at
at java.util.jar.Manifest.read(Manifest.java:167)
at
at
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:124)
at sun.tools.jar.Main.main(Main.java:904)
Any idea, why do I get this exception? Is there any
restriction as to how many jar files (or characters)
can be there in the Class-Path value in the
MANIFEST.MF file?
Please help.
Thanks,
Anajust -
How to add jar file in class path ?
Hello,
how can I add jar file in system class path.
I am using Linux and installed java.
Now I am creating one java package and working programs.
I want to add commons-net-2.0.jar jar file into class path.
how can I add in linux systems.
Thank you.the same way you add anything else to the classpath.
-
Simple question about environment variables and setting the class path???
ok I have been trying for a few months now ontrying to set the class path..
I work with windows vista..
on the environment variables user variables,
I have the name of the variable as class
and the value as C:\Program Files\Java\jdk1.6.0_04\bin;.
where javac is...
on the system variables I have
its name as class
and the value as C:\Program Files\Java\jdk1.6.0_04\bin;.
why is this not reading javacThe PATH environment variable should have as an entry the directory containing your javac executable. The CLASSPATH should have have entries which define your library directories and entries which are your jar file libraries. In the early days, probably the only CLATHPATH entry you will need will be a '.' to indicate the current directory.
The Java tutorial covers ALL of this. -
I'm having some serious trouble with class package path issues ... ugh!
I've downloaded a fairly complex and well programmed FLA file and other source files in AS 3.0, and just started to adapt it for a custom application. When I published the FLA and packages in FLash CS3, everything worked perfectly. Then I just got Flash CS4 a few days ago, and so opened the same application in CS4, and also published it fine. Yet, once I started to make some very simple customizations, such as create a new MovieClip, and then added "linkage" to the MovieClip in the library, the trouble started. Getting the new external class to associate to the new MovieClip was not working (although it was in the same location as the other package file, with the same class package designation), so of course I went to take a look at the preferences and set the general class path. Interestingly, the class path was completely blank (I just installed CS4 that day). Yet then, why was the application still working initially with no class path set? All of your original classes were loading fine, and the application was working. So, then when I went into actually set a class path (my new class is in the same folder: .../com/parkerandkent/components/classic/photogallery ), I start getting all kinds of errors ... and now, even if I revert back to having no class path at all, the application does not work at all (when it originally did with no class path at all). Strange! I am very confused about what is going on.
There are 5 primary .as package files, all of which are linked to MovieClips in the Library:
ClassicPhotoGallery.as
Photo.as
Thumb.as
Thumbs.as
CallTag.as (the new class)
I've checked the properties linkage for each of these, and they all appear correct also.
Currently, I have all of these class paths set:
- "/Users/mac/_EXTRA/ArtMuse/GALLERY"
- " "/Users/mac/_EXTRA/ArtMuse/GALLERY/com/parkerandkent/components/classic/photogallery"
Currently, I get these these error messages, which are referring to only 3 of 5 total .as files (which are all in the same location, and all have the same class path designation - and none of these files is the new class I made, which now appears to be referenced okay).
Photo.as Line 1:
5001: The name of package 'com.parkerandkent.components.classic.photogallery' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. /Users/mac/_EXTRA/ArtMuse/GALLERY/com/parkerandkent/components/classic/photogallery/Photo .as
Thumb.as Line 1:
5001: The name of package 'com.parkerandkent.components.classic.photogallery' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. /Users/mac/_EXTRA/ArtMuse/GALLERY/com/parkerandkent/components/classic/photogallery/Thumb .asAgain, the class path package designation is the same for all 5 .as files:
package com.parkerandkent.components.classic.photogallery {
yet the application is not working, and I get only those errors posted above.
If I remove all source path designations, then I get NO error messages, and yet the application does not work (although, I swear it was working this way originally). -
Class xyz is not in the class path
When I used:
<jsp:useBean id="blast" scope="session"class="hr.pbf.pnf.castorblast2.BlastOutput"/>
(or other class) , I get an warning: "The class hr.pbf.pnf.castorblast2.BlastOutput" is not in the class path ???Hi,
The possible reason could be that class is not present in project class path.
Check the following location to make sure the project is configured with source and required libraries
- Project > Properties > Java Build Path > Source Tab / Libraries Tab
M7 Support -
Retrieve the class path!! need help
Hi all
I tried to retrieve the class path using the below method:
URL srcUrl = ClassLoader.getSystemResource(fileName)
Since the class path has some space in it, this srcUrl seems to be wrong
the returned value would look like this, "%20" represnts the spaces in the path. So is there a way to avoid this, and to return the path correctly?
D:\PROJECT\ReportDesigner\Run%20report%20designer%20from%20a%20share\
thanks in advance
madummFile srcDir = new File(srcUrl.getFile());Well you just can't do that, can you? URL.getFile() returns the filename part of the URL, but it's still URL-encoded. You have to convert each %20 to a space, and do a few other possible transformations as well. See java.net.URLDecoder.
-
How to run a jar file which needs another jar to be in the class path
Hi,
I need to execute a jar, which needs another jar to be in the classpath.
If I run like
java -classpath <jar1 name> -jar <main jar>
It is giving classnotfoundexception, where as the class is available in the <jar1 name>.
so, currently I am doing like this
In the manifest file i have given like
Main-Class: <class name>
Class-Path: <jar name> <jar name2>
then it is running fine. But, if I want to change the jar location again I need to changed the manifest file.
Is there any way to do this? Pls help me.How about
java -cp jar1.jar;jar2.jar com.acme.MainClass
You won't need to worry about the manifest file after that and you can make a bat files (or .sh file in *nix) for it. -
How to load a Jar file in the class path?
How to load a Jar file which contains class files, images, etc.. in the classpath without using URLClassLoader.
You don't "load" jars. If it's on the classpath, you can obtain individual resources from it using various methods on either Class or ClassLoader. Do you mean "how to add a jar to the classpath at runtime"? Can't be done without using a classloader, typically URLClassLoader or a subclass thereof. Why you want to not use the proven method is beyond me. Presumably because you don't understand classloading. In which case, forget it.
-
Stand alone class and the class path
Hi,
I have a simple Java project in Eclipse environment. The project has it's class path,
that contains a jar file that I need to use.
The project runs perfect in the Eclipse.
Now, I need to take the main class out of my project, to function alone in another environment.
My problem is that out of the environment, I don't know how the class should know that classpath.
I moved that jar to the same folder that the class located in, but I don't know how to tell it that the jar is there.
My goal is to run my standalone class from another java class.
I'm afraid that examples in command environment wouldn't help me.
Thanks a lot for any help !moshi wrote:
I have a simple Java project in Eclipse environment. The project has it's class path,
that contains a jar file that I need to use.Ok, so you have a class that you have written that depends on an external library. Fair enough.
The project runs perfect in the Eclipse.
Now, I need to take the main class out of my project, to function alone in another environment.Maybe (just maybe!) defining what exactly that "other environment" is could help us help you.
My problem is that out of the environment, I don't know how the class should know that classpath.Well, obviously that depends on what that other environment is.
You must have some way to influence that other environments classpath, or you couldn't even get it to call/use your class.
I moved that jar to the same folder that the class located in, but I don't know how to tell it that the jar is there.Now you're just guessing.
My goal is to run my standalone class from another java class. That's simple enough, you probably do it all the time.
I'm afraid that examples in command environment wouldn't help me.And why exactly is that?
Do you realize that you tell us far too little about your problem for us to be able to actually help you? -
I have a small swing application which connects to an external database and queries something and creates a small report on the local machine. Running from the command line calling the == java MyClass works good. I would like to deploy this to two other machines. I dont want the use to run from the command line solution. I want to run it from a batch file using the jar file. But I am getting a a classpath issue ( ClassNotFoundException for the jdbc drivers ) . I signed my jar file using jarsigner too. I am not interesed in using the Web Start because there are no other security attached to this app. Only couple of people intends to use it. Running from the command line calling the app file explicitly works. In the batch file I added the setclass path too. Still it gives an exception. I added the jdbc driver jar file to the appication jar file too. Still the problem exists.
Any ideas ?instead of including the JDBC driver inside your application's jar, have the two jars sit in a directory separatly and include both of them on your classpath. Or, you can even specify a manifest.mf Class-Path parameter for your application's jar file so that it automatically includes the driver's jar.
-
Verify a jar's manifest class-path
I want to verify a jar file's manifest class-path. By that I mean I want to verify that every import of every class in the jar file is reachable on the classpath specified in the jar file's manifest. I tried using a ClassLoader to load every class in the jar file and that does indeed catch a few errors (imported classes that are not on the classpath), but it does not catch them all -- I have situations where loading the class works fine, but when the code is executed, I get NoClassDefFoundError because an imported class is missing from the classpath. I have tried things like calling getDeclaredMethod() on the loaded class to sortof force all the imports to be resolved, but that apparently does not work.
So, can someone tell me how to sortof "force" a loaded class to reference/validate all its imports?
Thanks,
LeeWell yes, I know that executing the code would do it. But I'm not in a position to execute the code -- I'm doing this during a build and want to verify that I've built all the jars properly and have all the right classpaths. It's actually quite easy to use ANT to compile and create jar files that produce NoClassDefFoundError at runtime, due to leaving needed classes from the jar, or from bogus classpaths in the jar's manifest.
So, I was hoping there was some other way to do this. Perhaps I need to do something ugly like examining the bytecodes of each method...
Thanks,
Lee -
How to set the class path?-
my forlder is :C:\Documents and Settings\india
jdk is in:C:\Program Files\Java\jdk1.5.0_11\bin
can any body can help me to create a classpath for my folder?An alternative - as stated in reply 2 in your other thread on this topic: http://forum.java.sun.com/thread.jspa?threadID=5170470 - is not to set the CLASSPATH environment variable at all. Use the -classpath switch instead.
As the documentation linked to in that reply points out: "The class search path (more commonly known by the shorter name, "class path") can be set using either the -classpath option when calling a JDK tool (the preferred method) or by setting the CLASSPATH environment variable. The -classpath option is preferred because you can set it individually for each application without affecting other applications and without other applications modifying its value."
As always, the documentation is worth reading; the available command line options worth using.
Maybe you are looking for
-
About a day ago i dropped my iphone 4. ever since then my screen has been black. i have been able to hear voice control and music but i dont know how to fix it. it was not far off the ground but to be fair it had been through a lot. i have an appoint
-
When portal server's mobile access pack is accessed through nokia7110 handset simulator then while checking mails I am able to send mails through reply link in inbox but I am not able to compose mails. It gives 'server error'.Please help me out.
-
I created a form for internal maintenance jobs. We need to have the forms emailed to individuals and department heads. I have no problem with the individual emails but the department head emails are in a table in the database. Who gets the email will
-
How to load the original manifest file
Hi I wrote an application. Is lanunched by webstart. In the original jar file is set an property like a Program-version:1.5 after launching the application I can fread resources from "/resources/images/myimage", but I Cant read the from the manifest
-
Within my work i use a pdf based Availablity system. we send out pdf forms to our staff which they can fill in and automatically send back to us via our server by simply clicking a submit button within the form. All tests with windows based Adobe rea