views:

258

answers:

5

I have a rather complex J2EE app I don't have any documentation for and I am trying to get it to run.

I have gotten the ant build script to compile a EAR file that contains a WAR file, but this application even though I get "successfully deployed" on weblogic console is still not working.

There are many required jars missing from the EAR file, hence I get errors about missing classes on the console log when I deploy the app. Sometimes even after I check a particular class is there I still get the error.

What is a best way to debug and get this application running?

Is there any shortcuts in J2EE/Java to "find all dependencies", apps anybody knows to analyze code and find dependencies or anything like that?

A: 

I'd assume you managed to get this application put together and compiled in an IDE, maybe Eclipse. Why not simply put all the Jars that you had available at build time, into the EAR?

If you're having to debug this by trial and error, you can look at the list of missing classes and figure out which jars they belong to by Googling for the class names, or maybe you can find them in your IDE too.

If you have a lot of trouble identifying some classes, post the class names (or the error messages) here and someone should be able to tell you where to find the Jar it belongs in.

Carl Smotricz
Actually I only managed to compile from command line using ant, the default target built the WAR and placed it inside the EAR. So thanks for the suggestion of putting inside eclipse, sounds like that will help in identifying some problems, I will do that next. But do I understand you correctly that you are suggesting if I can build something, I should also be able to run it with the same jars? I had not understood that to be the case, I thought there is most likely some purely runtime dependencies that I am missing?
Ville M
It's possible to have dependencies that are configured dynamically and don't get resolved until runtime, alas, so it's not hard and fast. But I'd say it's the less likely case. Also, there's nothing wrong with working with an editor and ant, if that's working for you.
Carl Smotricz
I do think I am now seeing some runtime dependency problems. I been working alot with Perl and Ruby lately and those languages seem to lend themselves to command line lot better. I should probably revert to working with an IDE since these J2EE apps seem to be always made of many more and longer files and than I am used to from the more concise dynamic languages.
Ville M
A: 

If you are able to successfully build and deploy the app, but still getting the errors about missing classes, probably some of the jar classes are called through reflection. You may want to search for reflection API calls in the Project through your IDE. These calls may be something like, "Class cls = Class.forName(..); cls.newInstance()."

Sometimes even after I check a particular class is there I still get the error.

This may be a deployment issue. check the classpath. Some of the jars may be missing from the Classpath.

mrajeshc
+1  A: 

Is there any shortcuts in J2EE/Java to "find all dependencies", apps anybody knows to analyze code and find dependencies or anything like that?

Do you mean a compiler? I'm actually semi serious here (even if the compiler won't give you the name of a missing JAR). Indeed, if you are compiling that application successfully with Ant, then you likely have all dependencies required at compile time (you may need more of them at runtime but, well, you'll need to execute the code to identify them). Maybe you just need to add more of them in the EAR during the packaging. Or maybe you need to add more dependencies at the app server classpath level.

In both case, search engines like jarFinder.com or Docjar.com or Jarhoo.com might help you to identify missing JARs and to solve your ClassNotFoundException or NoClassDefFoundError.

You should actually give readers more details about the missing classes, I'm sure people will be able to give you some hints and point you in the right direction.

Pascal Thivent
Thanks for the search tools. From the names I can now tell some of the dependencies are in-house jars that did not get built nor included in the EAR as part of the build.xml.
Ville M
A: 

Is there any shortcuts in J2EE/Java to "find all dependencies", apps anybody knows to analyze code and find dependencies or anything like that?

I'd start by having another go at getting documentation ... or help ... from the original developers, if you can find them. [IMO, people who develop / provide software without any documentation deserve to be bugged incessantly by people asking silly questions.] But I guess you've already tried that.

Then there are the jarfinder.com and other services as mentioned in another answer. (New to me!)

If that fails, I'd try doing a Google search on the FQNs. The chances are that if the missing classes are part of a commonly used library you will hit the Javadocs ... or a posting from someone else with a similar problem to yours.

If the "Google it" approach fails, use the clues in the package naming for the missing classes to try and find where they come from. If they follow the Sun recommendations, the names should map to a company or (real or pseudo-) organization that you can locate by a web search.

Stephen C
+1  A: 

I know of no easy way to deal with this. If the application provides an ant task build the EAR then the result should be a self-contained deployable application EAR. It is possible that the EAR requires extra libraries to be added to some class path, without documentation it's really hard to know what.

This phrase is, I guess, at the heart of the problem: "Sometimes even after I check a particular class is there I still get the error." Exactly what do you mean?

You are getting a class not found error but you can see the class in the EAR file? If that's the case then things are really difficult, and may well be some kind of classloader issue. I don't know WebLogic at all, but in WebSphere when deploying an application you have a choice of whether to give precedence to JARs in the EAR or to the same JAR in WebSphere itself. Some Applications demand one or the other setting. If there's anything like that in WebLogic then this may be your problem.

Another possible problem is that the app may depend on infrastructure libraries (Eg. XML parsers) that are supplied by WebLogic, but expects a different version that is supplied with the WebLogic version you are using.

Without documentation that the app is supported on the version of WebLogic you are using, I fear you're fighting a long, hard (or even a losing) battle.

djna
+1, thanks, it is indeed somewhat possible that there is a version incompatibility. It appears to me now that when this app was last deployed, EAR was probably first decompressed, then some jars added inside it in order to fulfill runtime dependencies and make the app run. Thanks for the ideas, Long battle I can live with, losing not so much....
Ville M