Solved

Eclipse 3,  Log4j JDK 1.3 compile problem.

Posted on 2003-12-08
23
1,355 Views
Last Modified: 2013-11-23
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
Comment
Question by:randis
  • 9
  • 7
  • 5
  • +2
23 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 9895993
If you put log4j.jar into all your jre/lib/ext directories, Eclipse should pick it up
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 9896016
I get this error message every time I install a new ECLIPSE version and on any project.
Just don't worry.
;JOOP!
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 200 total points
ID: 9896038
> is there anyway for me to figure it out?

  Try to look at the project's classpath.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9896064
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
 
LVL 1

Author Comment

by:randis
ID: 9898608
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
 
LVL 1

Author Comment

by:randis
ID: 9898634
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
 
LVL 1

Author Comment

by:randis
ID: 9898679
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
 
LVL 92

Expert Comment

by:objects
ID: 9900646
> 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
 
LVL 35

Expert Comment

by:girionis
ID: 9902460
 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
 
LVL 1

Author Comment

by:randis
ID: 9903267
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
 
LVL 1

Author Comment

by:randis
ID: 9903492
<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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 35

Expert Comment

by:girionis
ID: 9903574
 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
 
LVL 86

Expert Comment

by:CEHJ
ID: 9903623
>> 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
 
LVL 35

Expert Comment

by:girionis
ID: 9903710
 True, with the only drawback that there is no such a class (java.util.logging.Logger) in the log4j.jar file.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9903845
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
 
LVL 35

Expert Comment

by:girionis
ID: 9903921
 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
 
LVL 1

Author Comment

by:randis
ID: 9904098
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
 
LVL 35

Expert Comment

by:girionis
ID: 9904123
> 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
 
LVL 1

Author Comment

by:randis
ID: 9904308
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
 
LVL 1

Author Comment

by:randis
ID: 9904324
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
 
LVL 35

Expert Comment

by:girionis
ID: 9904371
 Ahh.. I see... Ok then. At least we got it leaking somewhere. Thanks for the points :)
0
 
LVL 1

Author Comment

by:randis
ID: 9904451
Yeah... I never figgured a variable name could cause so much trouble.  Your welcome.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9904890
8-)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now