- This topic has 8 replies, 2 voices, and was last updated 18 years, 10 months ago by Riyad Kalla.
-
AuthorPosts
-
Ken NelsonMemberI have ran into an odd problem. All of the sudden when I try to Create Hibernate Mapping from the DB Browser, no classes are generated and there is no error message. I am really not sure what the issue is. Has anyone run into a similar issue?
Ken NelsonMemberIt turns out that I had created a java project that relied on the commons and log4 jar files. I had to run them from the command line, which required me to place them in the lib\etc dir of the jre. Once I removed them, I was able to map again. I guess I had placed a different version of the files in the directory.
Riyad KallaMemberThis is a sneaky problem, whenever you put JARs in your JRE’s /etc dir beware. You never know what libraries the software you rely on uses, in this case, our Hibernate plugins likely were conflicting and silently failing against those versions of log4j.
Ken NelsonMemberThanks rkalla,
I have seen that this issue is not mine alone. Do you guys have a recommendation for how you package and run a default class from a jar. One that relies on other classes in other jars?
I see three options
1) Unjar the dependant jars and package them in your jar. This may violate some license agreement and is generally a bad practice.
2) Place the jar’s in the lib\etc of the JRE. We have seen the issue here. So another not so good idea.
3) I did find this http://www-128.ibm.com/developerworks/java/library/j-onejar/ which sounds interesting but I think you would have to include the class in every application. Not that I actually write a lot of applications – I work more on web apps.
Riyad KallaMemberDo you guys have a recommendation for how you package and run a default class from a jar. One that relies on other classes in other jars?
All sizable projects that I am aware of use a deployment technology like WebStart (this gets my personal vote) or a startup script (any IDE, App server etc,.) that sets up the classpath with the necessary JARs on it and calls the main class.
Is this not something you would want to do? I believe there is a way, as long as the JARs are all in the same dir, to make your class-path entries in your MANIFEST.MF file add all of them to the classpath when the main class executes. But this isn’t a great solution or one I have tried.
Ken NelsonMemberActually no. What I want to do is run this from cron. I have tried various methods of including the support jar’s with no success. I included the supporting jar’s in my jar – didn’t work. I ran with classpath set to point to the supporting jars – didn’t work. I spent WAY to much time on it trying various combinations of the above – never found anything that woeked.
Riyad KallaMemberActually no. What I want to do is run this from cron. I have tried various methods of including the support jar’s with no success.
java -cp lib\a.jar:lib\b.jar:lib\c.jar com.sanclem.Main
Why doesn’t that work from the cron job? We run quite a few Java-based services in our cron jobs all in this manner, seems to work fine. Is there a specific problem you are running into?
I ran with classpath set to point to the supporting jars – didn’t work.
Don’t mess around trying to get a CLASSPATH environment variable right, waste of time, lots of headaches.
I spent WAY to much time on it trying various combinations of the above – never found anything that woeked.
The more time you spend one something, is the simpler the solution… so hopefully that’s good news 🙂
Ken NelsonMember@support-rkalla wrote:
java -cp lib\a.jar:lib\b.jar:lib\c.jar com.sanclem.Main
That told me that a class (org.commons.net.FTPClient or something like that) I was using did not exist. The class was in a.jar (Actually it was in commons-net-???.jar) for example.
@support-rkalla wrote:
The more time you spend one something, is the simpler the solution… so hopefully that’s good news 🙂
Isn’t that always the case 😀
Riyad KallaMemberThat told me that a class (org.commons.net.FTPClient or something like that) I was using did not exist. The class was in a.jar (Actually it was in commons-net-???.jar) for example.
Send me a PM with all the dependent JARs, the name of the main JAR and the name of the main class.
Just to clarify, everything is in normal JARs right? If you are executing your code outside of a JAR, but have dependent JARs you need to add to the path let me know that too.
-
AuthorPosts