• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1374
  • Last Modified:

Eclipse 3, Log4j JDK 1.3 compile problem.

Hi guys.
   Quick question, Appreciate it if someone has seen this before.

   I'm compiling an application which uses Log4J for logging.  JDK 1.3 is a must and not a choice.  On Eclipse 2, everything compiles 100% ok.

  On Eclipse 3, build 5, I get the following errors:
- The project was not built since build path is inclomplete.  Cannot find the class file java.util.logging.Logger.  Fix...(blah blah)
- The type java.util.logging.Logger cannot be resolved.  It is inderectly referenced from requested .class files.

Of course, I launch Eclipse 3 with JDK 1.4 (since it won't start properly with 1.3)
My project uses my eclipse defaults.  My eclipse defaults are set to compile for JDK 1.3.1_08 as default (checkmark).
In the code that is referenced by the second error, there is a completely qualified log4j import and no java.util.logging.XXX import statements (as it would not compile in eclipse 2 with jdk 1.3)

One last piece of info, the log4j is used in lots of places, so if I remove this compile unit from the build, I still get the same elsewhere.

So WHERE does eclipse find this java.util.logging.Logger reference... is there anyway for me to figure it out?
0
randis
Asked:
randis
  • 9
  • 7
  • 5
  • +2
2 Solutions
 
CEHJCommented:
If you put log4j.jar into all your jre/lib/ext directories, Eclipse should pick it up
0
 
sciuriwareCommented:
I get this error message every time I install a new ECLIPSE version and on any project.
Just don't worry.
;JOOP!
0
 
girionisCommented:
> is there anyway for me to figure it out?

  Try to look at the project's classpath.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CEHJCommented:
If you put the log4j jars where i mentioned, Eclipse should treat the log4j classes like the classes in the standard libraries, in that they will not need per-project settings
0
 
randisAuthor Commented:
CEJH: Ok, so I tried putting the Jar file in my jdk131_08\jre\lib\ext directory, closed eclipse 2 and 3. Opened Eclipse 3 and rebuilt. (the jar is now at two locations, as it is also loaded as an external jar file from it's previous directory).

Still no change.  Can't compile.

sciuriware: I'd love to not worry, but I'd also like my code to compile with as little impact to my project possible :D

Girionis:
This is what I thought at first, but out of all the jars included in the project (about 20), I don't seem to have any JDK1.4 classes included as jars in my project, I checked the "classpath variables" (Window/Preferences/Java/Classpath Variables) , and the only one i'm not sure about is the JUnit entry (C:/eclipse/plugins/org.junit_3.8.1/).
We do not use JUnit at this point in our project.

If I look at my project build path, everything seems to be OK, pointing at my jdk1.3.1, log4j.jar is included (twice now, one within the JRE libraries and one seperate one)

The project comes preconfigured from CVS  ie. from the CVS Perspective I do a checkout project as and give it a name.  My eclipse 2 project still works, so I probably got the right log4j.jar.


Anything else I should be looking at?

0
 
randisAuthor Commented:
Is there a log somewhere in eclipse that describes an actual javac line structure, with class path variables or such which would enable me to get more information about the build?
0
 
randisAuthor Commented:
Additionally, if it could not find the log4j.jar, wouldn't I get a compile error on the import of the Logger class instead of an <inderect reference> error?
0
 
objectsCommented:
> Additionally, if it could not find the log4j.jar

Correct, I don't think it has anything to do with your problem.
Check what JDK Eclipse is setup to use.
0
 
girionisCommented:
 What is the exact error message (with stack trace if possible). I thought the problem was:

> Cannot find the class file java.util.logging.Logger.  Fix...(blah blah)
0
 
randisAuthor Commented:
That's right.  the problem (eclipse 3 only) is that when Eclipse 3 builds my project, it seems to require java.util.logging.Logger , while it does not exist in JDK 1.3 and the code specifically identifies the log4j Logger.

The build errors are:
- The project was not built since build path is inclomplete.  Cannot find the class file java.util.logging.Logger.  Fix...(blah blah)
- The type java.util.logging.Logger cannot be resolved.  It is inderectly referenced from requested .class files.

There is no exception, just these messages that show up in the Errors area at the bottom.
0
 
randisAuthor Commented:
<Check what JDK Eclipse is setup to use.> answer:
Eclips 'loads' on JDK 1.4.2 with the -vm tag.  (I think it requires 1.4 to load)
But I changed the default JRE setting in the preferences for my JDK1.3.1_08.
0
 
girionisCommented:
 Well if it is a ClassNotFound then it is definetely a classpath problem. The java.util.logging.Logger class is only available in jdk1.4. It is normal that you can't find it unless you upgrade.
0
 
CEHJCommented:
>> Well if it is a ClassNotFound then it is definetely a classpath problem

Yes, and this should be fixable by what i suggested before, i.e. putting the right libraries in the appropriate jre/lib/ext directories. The will of course to be compatible with the Java version in force, otherwise you'll have to use a later Java version.
0
 
girionisCommented:
 True, with the only drawback that there is no such a class (java.util.logging.Logger) in the log4j.jar file.
0
 
CEHJCommented:
Yes but,

>>I'm compiling an application which uses Log4J for logging

and AFAIK, log4j does not depend on java.util.logging.* so there should not be a problem in theory
0
 
girionisCommented:
 Yes my comment on 12/09/2003 12:30PM GMT was referring to:

> So WHERE does eclipse find this
>java.util.logging.Logger reference... is there
>anyway for me to figure it out?

  To the original asker:

>Of course, I launch Eclipse 3 with JDK 1.4
>(since it won't start properly with 1.3)
>My project uses my eclipse defaults.  My
>eclipse defaults are set to compile for JDK
>1.3.1_08 as default (checkmark).

  So you start Eclipse with JDK1.4 but your project uses 1.3.1_08 to compile/run? There must be a conflict in classes? I suggest you do not do that and run everything in jdk1.3 (as you mentioned it is a must). If you have access in the source code try to change the logging stuff that uses the java.util.loggin package.
0
 
randisAuthor Commented:
I truly understand what both of you are saying.
I can't start eclipse 3 with jdk 1.3.  It won't start.  I looked up the eclipse page and they mention a tartet platform of jdk1.4.2

In the class that throws the error, I have:
import java.sql.Connection;
import java.sql.SQLException;
import java.util.GregorianCalendar;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;

// and a few from sub packages of metaplus : import com.metaplusmobile.atocha.*.*.*;

Later in the code, there is a "private static Logger logger = Logger.getLogger("LOG2");" line.
I do not have ANY reference to "java.util.logging." in any java file in my project (except in a programmer's comments)
The compile errors mentioned above.

---------------------------------------------
So in recap:
Eclipse needs to run on jdk 1.4
My app needs jdk 1.3
Eclipse adds requirement from it's runtime environment to the project so it causes problems for the use of an external "Logger" (external ie not in rt.jar).

If this is the case, I have no other choice than using eclipse 2 (maybe write a bug repport for eclipse 3).

Thanks for all your help.  I'll wait a day to see if you have any other ideas then split the points as you both gave me pretty god ideas.

0
 
girionisCommented:
> I have no other choice than using eclipse 2 (maybe write a bug repport for eclipse 3).

  It is not a bug since it clearly states it needs jdk1.4. I suggest you stick with the current version of eclipse or maybe suggest to upgrade the jdk so you can use latest version of eclipse.
0
 
randisAuthor Commented:
Found it. (or some of it anyways)
This class inherits from another class in a pre-compiled .jar file. This jar file seems to try to find a variable of name "logger" and convert it to a java.util.logging.Logger.  I don't know how this is done, but I know that if I rename my variable

private static Logger logger1 = Logger.getLogger("log");

It compiles just fine for that class.

I'm still somewhat in the sh*t hole since I can't modify all those classes without a better reason (production code).  If I can modfy the jar file, I won't have to check it in.

Thanks guys.
0
 
randisAuthor Commented:
We have a complexe environment on a J2ee server which uses jdk 1.3.  Changing to jdk 1.4 would cause all applications to use a new application server,  which causes multiple apps to have to be re-tested and re-deployed, which is not in scope for this task of mine.
0
 
girionisCommented:
 Ahh.. I see... Ok then. At least we got it leaking somewhere. Thanks for the points :)
0
 
randisAuthor Commented:
Yeah... I never figgured a variable name could cause so much trouble.  Your welcome.
0
 
CEHJCommented:
8-)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 9
  • 7
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now