Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are we heading for jar hell in java platform similar to dll hell?

Last night I was trying to put a simple tutorial to build an application using the stack - Spring (2.5) + JPA (1.0) + Hibernate (downloading for first time, so didn't know which version to use). Unfortunately I didnt want to use Maven as the target participants were on ANT build. As usual hit the search engine and got somehow the steps in the appcontext, persistence.xml and in the java classes. The moment I started getting required libraries, I lost in the JAR hell. Luckily, not much of a problem on the Spring side as all the dependent JARs are packaged together for my Spring 2.5.6.

When it came to hibernate, I had no clue which all Jars to be included on the first place. On the next challenge, didn't know which version for each to add.

Finally I got the whole thing working, but it looks so scary to enter this JAR hell again unless I am taken through Maven heaven.

With lots of interceptors and weaving, it is becoming more complicated for the conventional Java programmer who once liked Java primarily for lots of transparency on what my code is doing.

Am I right in the thought process?

like image 765
arunram Avatar asked May 24 '11 15:05

arunram


People also ask

Which of the following corresponds to the problem JAR hell?

version conflicts are the single most problematic aspect of jar hell.

What is JAR hell?

Noun. JAR hell (uncountable) (computing, informal) (of the Java language) Problems caused by incompatible versions of a JAR (Java archive).

What is DLL Hell program?

DLL Hell is a situation in which two separate applications share a common assembly, and if one of the applications makes modifications to the common assembly that isn't backward compatible, the other application crashes.

What do you mean by DLL Hell problem how it can be solved?

A simple solution to DLL Hell in an application is to statically link all the libraries, i.e. to include the library version required in the program, instead of picking up a system library with a specified name. This is common in C/C++ applications, where, instead of having to worry about which version of MFC42.


2 Answers

You can still have dependency management while using Ant, use Ivy. See a detailed tutorial here for more or less exactly the stack you want to use. (Doesn't include Hibernate but I guess you can find how to add that pretty quickly)

And one more thing, if you are referring to the spring.jar which has the full Spring 2.5.6 bundle, I strongly suggest not to use it, you probably need not more than 20% of the libraries included in it. (Take the time to discover exactly which libraries you do need and only pick those.)

Also, consider using Spring 3 if you can, as well as Hibernate, if you are free to pick a version, I'd go for the latest.

like image 134
abalogh Avatar answered Sep 21 '22 06:09

abalogh


I had used other JPA implementations before, but I used Hibernate for the first time this year. Certainly it is more complicated than others in terms of jar dependencies, but in the Getting Started Guide, in Chapter 1, under Obtaining Hibernate I found details on which jars I needed and why.

I did suffer of jar hell problems later on, not because of not knowing which jars to use, but because we are in a really big probject, and other subprojects were already using older versions of Hibernate classes, and this caused me a lot of trouble at runtime and it took me several days to diagnose and fix.

I think this is a reality for the time being, and tools like Maven or frameworks like OSGi attempt to alleviate the problem.

Perhaps the biggest hope we have is Project Jigsaw intended to be part of JDK 8 in the future and which attempts to solve the Java modularity problems we currently have. It will be like a OSGi with steroids, and built in the JDK itself.

But before that happens, all I can tell you is a famous quote by Wiston Churchill

If you are going through hell, keep going

like image 40
Edwin Dalorzo Avatar answered Sep 21 '22 06:09

Edwin Dalorzo