From users-return-1736-archive-asf-public=cust-asf.ponee.io@netbeans.apache.org Thu Oct 4 10:07:23 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5E4DC180658 for ; Thu, 4 Oct 2018 10:07:22 +0200 (CEST) Received: (qmail 38738 invoked by uid 500); 4 Oct 2018 08:07:20 -0000 Mailing-List: contact users-help@netbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@netbeans.apache.org Received: (qmail 38727 invoked by uid 99); 4 Oct 2018 08:07:20 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2018 08:07:20 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 4D74FC5A9C for ; Thu, 4 Oct 2018 08:07:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.897 X-Spam-Level: * X-Spam-Status: No, score=1.897 tagged_above=-999 required=6.31 tests=[DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=googlemail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id E9pd5Y5SjegW for ; Thu, 4 Oct 2018 08:07:19 +0000 (UTC) Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id C5BAD5F11D for ; Thu, 4 Oct 2018 08:07:18 +0000 (UTC) Received: by mail-yb1-f182.google.com with SMTP id h1-v6so3552335ybm.4 for ; Thu, 04 Oct 2018 01:07:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=id1oC++ZkoTpJgdmX2wezpraFFnQYAnmHT4u4gBb3dI=; b=V4LW9ONqIPaW0CaMWuZ31C6J1AfGVHTR8wVRQQscfAsAtGYpuUN7+3aBqL+ZNRZiHy 7oQ4w4fi+VOBChpIetdTUT+HOpizYAsf+OoUw1LnJ4ezqreJ63kwzd0QLY/6DQYpcD5k 8CAUQ8ci2IU7d52mDCvyqEaO8SpxmYDejrBVUA801DUFf34bJ6KRAbsAgRcqktzoMGc6 U9Q+NS+n+0TxGxBw0+sVddr6Jb07BcYMkn1kJ7Qqah6BDvT2rXx0iyzIFW1VTgMHe/bQ xNpWll2W40KtxUC/H7oOKDLh4qyK4nLsUGdosmzjTsdy1h9oeiSPeBB2+0Y2j2IJQzlf AlSw== X-Gm-Message-State: ABuFfohkhRUYTFJdAa7AYkuGBNlZQEv0ETs/L3nHyc6Zt+N4BUJRPIIA CdyeNi2LrwILP5Vd2y9LEbVXjrs7HZmCxLfz8doycqEaa+E= X-Google-Smtp-Source: ACcGV616PUk7Urja+ek7lySAXeUQupkcflvKr3guYaTjZGPCvTDM0+ipjGRY9nlUv+S1amThJm/G+WXL8SEYWmHMxlc= X-Received: by 2002:a25:7556:: with SMTP id q83-v6mr2840141ybc.458.1538640438151; Thu, 04 Oct 2018 01:07:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Geertjan Wielenga Date: Thu, 4 Oct 2018 10:07:06 +0200 Message-ID: Subject: Re: Netbeans ant build script not finding Log4j2 V2.11.1 module-info.class To: users@netbeans.incubator.apache.org Content-Type: multipart/alternative; boundary="000000000000c0d010057762a462" --000000000000c0d010057762a462 Content-Type: text/plain; charset="UTF-8" https://github.com/apache/incubator-netbeans/pull/941 We've identified the problem and done work on fixing it. Gj On Thu, Oct 4, 2018 at 10:03 AM Pete Whelpton wrote: > Sorry, typo: > > 5) Navigate to your Classes node -> , open > module-info.java and add the following line: > requires org.apache.logging.log4j.core; > > should say: > > 5) Navigate to your Classes node -> , open > module-info.java and add the following line: > requires *org.apache.logging.log4j*; > > On Thu, Oct 4, 2018 at 8:52 AM Pete Whelpton wrote: > >> Hi Emma, >> >> Yes, I think there is something awry with the log4j-api-2.11.1.jar. To >> get it working just using ModulePath, I first: >> >> 1) Opened the log4j-api-2.11.1.jar file in Archive Manager >> >> 2) Copied the module-info.class file from /META-INF/versions/9/ folder to >> the root of the archive >> >> After both the api and core jars are (re)added to your module path, you >> can use "requires org.apache.logging.log4j;" in your own module-info >> file. Netbeans will find this in code completion. :) >> >> What I believe happens during classloading is first the release specific >> location is checked, and if not it falls back to the default (root) >> location. Loading via ModulePath requires a compiled module-info in the >> "base" folder of the classes. >> In the case of the log4j-api-2.11.1.jar file, the release specific >> location (/META-INF/versions/9/) contains only only one class - >> presumably the one and only class with Java9 specific code. >> >> However, when class loading falls back to the root to find the other >> classes, there is no module-info there, which is why I believe it fails. >> >> As to whether best practice would be to have the whole >> org.apache.logging.log4j under /META-INF/versions/9/, or to have a >> module-info in the root as I did, I don't know enough to tell you. >> >> >> >> Full steps below to create the project and reference the clases, if you >> need them: >> >> 1) Netbeans -> File -> New Project -> Java Modular Project call it >> "Log4j2TestCasePDW" and platform JDK10 >> >> 2) Right click Project node -> New -> Module and call it >> "Log4j2TestCase". >> >> 3) Right click Project node -> Properties -> Libraries and the click >> "Browse" next to the library folder. >> Accept the defaults to create a /lib folder and to copy libraries >> to the folder >> >> 4) Still in the Libraries properties, using the ellipsis (...) next to >> ModulePath, choose "Add JAR/Folder" and add the following two .jar files >> (making sure "copy to library folder" is checked: >> log4j-api-2.11.1.jar >> log4j-core-2.11.1.jar >> >> N.B. For any Netbeans devs reading, there seems to be a bit of a minor >> bug in NB here - if you highlight both and try and add them both at the >> same time, one JAR will go in ModulePath and one in ClassPath. >> >> 5) Navigate to your Classes node -> , open >> module-info.java and add the following line: >> requires org.apache.logging.log4j.core; >> >> N.B. If you press ctrl-space to bring up code completion after typing >> "requires", you will see the modules you can import. the >> "org.apache.logging.log4j" >> >> 6) Copy your test package and .java file under the Classes node >> >> 7) Right click -> Run on your Log4j2TestCase.java file >> >> >> You will get a console output similar to: >> >> "02:20:00.367 [main] ERROR log4j2testcase.Log4j2TestCase - >> *** Log4j2 error message" >> >> >> Hope that helps, >> >> P >> >> >> On Wed, Oct 3, 2018 at 12:51 PM Emma Atkinson >> wrote: >> >>> To recreate the test case and Netbeans set up. >>> >>> - I created a Java Application using the new project function. I >>> set it up to run on JDK 10. >>> >>> >>> - I added a module-info.java file using a RMB on Project Navigator > >>> Log4j2TestCase > Source Packages > New > Java Module Info... >>> >>> >>> - I created a Library entry (named Apache Log4j2 2.11) that refers >>> to the log4j-api-2.11.1.jar via Tools > Libraries pressing New Library... >>> button. I only added the one jar, no javadoc, no sources. >>> >>> >>> - Using a RMB on the Project Navigator > Log4j2TestCase > Libraries >>> > Add Library... I added the Library entry named Apache Log4j2 2.11. >>> >>> >>> - Using a RMB on the Project Navigator > Log4j2TestCase > Libraries >>> > Add JAR/Folder ... I added a separate reference to log4j-api-2.11.1.jar >>> and log4j-core-2.11.1.jar. Netbeans put the log4j-core-2.11.1.jar on the >>> modulepath and added a line to my module-info.java. >>> >>> >>> - RMB on Project Navigator > Log4j2TestCase selected Properties > >>> Libraries. I moved the reference to the jar files down into the classpath. >>> >>> >>> - I edited the module-info.java file to delete the automatically >>> added line >>> * requires *org.apache.logging.log4j.core*;* >>> >>> >>> - I added two import statements to the Log4j2TestCase.java >>> (containing the main entry point) >>> * import* org.apache.logging.log4j.LogManager; >>> * import* org.apache.logging.log4j.Logger; >>> >>> As it stands Log4j will not find its configuration XML file so it will >>> say that it is using default setting which means it output errors and above >>> and suppresses messages that are warnings, info and debug. >>> >>> - I created an object called LOGGER. >>> >>> >>> - I created a LOGGER.error("some text "); so that it would output to >>> the console under default settings if it ran. >>> >>> But first we need to build the application. >>> >>> - Select the module-info.java file and using a RMB menu option to >>> Compile File. The ant build script will run and eventually output an error >>> message saying that it cannot find the module log4j.api. >>> >>> I hope this is comprehensive enough. >>> >>> >>> >>> --000000000000c0d010057762a462 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

We'v= e identified the problem and done work on fixing it.

Gj

On Thu, Oc= t 4, 2018 at 10:03 AM Pete Whelpton <peedeeboy@gmail.com> wrote:
Sorry, typo:

5) Navigate to your Classes= node -> <default package>, open module-info.java and add the foll= owing line:
=C2=A0 =C2=A0requires org.apache.logging.log4j.core;

=
should say:

5) Navigate to your Classes= node -> <default package>, open module-info.java and add the foll= owing line:
=C2=A0 =C2=A0requires org= .apache.logging.log4j;

=
On Thu, Oct 4, 2018 at 8:52 AM Pete Whelpton <peedeeboy@gmail.com&g= t; wrote:
Hi Emma,

Ye= s, I think there is something awry with the=C2=A0log4j-api-2.11.1.jar.=C2=A0 To get it working just using ModulePa= th, I first:

=
1) Opened the=C2=A0log4j-api-2.11.1.jar file in Archive Manager=

2) Copied the module-info.class file from /= META-INF/versions/9/ folder to the root of the archive

Af= ter both the api and core jars are (re)added to your module path, you can u= se "requires org.apache.logging.log4j;" = in your own module-info file.=C2=A0 Netbeans will find this in code complet= ion. :)

What I believe happens du= ring classloading is first the release specific location is checked, and if= not it falls back to the default (root) location.=C2=A0 Loading via Module= Path requires a compiled module-info in the "base" folder of the = classes.
In the case of the log4= j-api-2.11.1.jar file, the release specific location (/META-INF/versions/9/) contains only only one class -= presumably the one and only class with Java9 specific code.

However, when class loading falls back to the root to find the other clas= ses, there is no module-info there, which is why I believe it fails.=

As to whether best practice would be to have the whole= org.apache.logging.log4j under=C2=A0/M= ETA-INF/versions/9/, or to have a module-info in the root as I did, I don&#= 39;t know enough to tell you.


Full steps= below to create the project and reference the clases, if you need them:
1) Netbeans -> File -> New Project -> Java Modul= ar Project=C2=A0 call it "Log4j2TestCasePDW" and platform JDK10
<= br clear=3D"none">
2) Right click Project node -> New -> Module=C2=A0= and call it "Log4j2TestCase".

3) Right click= Project node -> Properties -> Libraries and the click "Browse&q= uot; next to the library folder.
=C2=A0 =C2=A0=C2=A0 =C2=A0 Accept the defa= ults to create a /lib folder and to copy libraries to the folder

4) Still in the Libraries properties, using the ellipsis (...) n= ext to ModulePath, choose "Add JAR/Folder" and add the following = two .jar files (making sure "copy to library folder" is checked:<= /div>
= =C2=A0 =C2=A0 =C2=A0 =C2=A0log4j-api-2.11.1.jar
=C2=A0 =C2=A0 =C2=A0 =C2=A0= log4j-core-2.11.1.jar

N.B.=C2=A0 For any Netbeans devs = reading, there seems to be a bit of a minor bug in NB here - if you highlig= ht both and try and add them both at the same time, one JAR will go in Modu= lePath and one in ClassPath.=C2=A0

5) Navigate to your = Classes node -> <default package>, open module-info.java and add t= he following line:
=C2=A0 =C2=A0requires org.apache.logging.log4j.core;
N.B. If you press ctrl-space to bring up code completion a= fter typing "requires", you will see the modules you can import.= =C2=A0 the "org.apache.logging.log4j"

6) Copy= your test package and .java file under the Classes node

7) Right click -> Run on your Log4j2TestCase.java file


You will get a console output similar to:

"02:20:00.367 [main] ERROR = log4j2testcase.Log4j2TestCase -=C2=A0
=C2=A0*** Log4j2 error me= ssage"


Hope tha= t helps,

P


On Wed, Oct 3, 2018 at 12:51 PM Emm= a Atkinson <emma.atkinson2@gmail.com> wrote:
To recreate the test case and= Netbeans set up.=C2=A0
  • I created a Java Application= using the new project function.=C2=A0 I set it up to run on JDK 10.=C2=A0 =
  • I added a module-info.java file using a RMB on= Project Navigator > Log4j2TestCase > Source Packages > New > J= ava Module Info...
  • I created a Library entry (n= amed Apache Log4j2 2.11) that refers to the log4j-api-2.11.1.jar via Tools = > Libraries pressing New Library... button.=C2=A0 I only added the one j= ar, no javadoc, no sources.
  • Using a RMB on the = Project Navigator > Log4j2TestCase > Libraries > Add Library... I = added the Library entry named Apache Log4j2 2.11.
    <= li>Using a RMB on the Project Navigator > Log4j2TestCase > Libraries = > Add JAR/Folder ... I added a separate reference to log4j-api-2.11.1.ja= r and log4j-core-2.11.1.jar.=C2=A0 Netbeans put the log4j-core-2.11.1.jar o= n the modulepath and added a line to my module-info.java.
  • RMB on Project Navigator > Log4j2TestCase=C2=A0 selected Prop= erties > Libraries.=C2=A0 I moved the reference to the jar files down in= to the classpath.
  • I edited the module-info.java= file to delete the automatically added line
    requires
    org.apache= .logging.log4j.core;
  • I added = two import statements to the Log4j2TestCase.java (containing the main entry= point)
    import
    org.apache.logging.log4j.LogManager;
    import<= /b> org.apache.logging.log4j.Logger;
As it stands Log4j= will not find its configuration XML file so it will say that it is using d= efault setting which means it output errors and above and suppresses messag= es that are warnings, info and debug.=C2=A0
  • I create= d an object called LOGGER.
  • I created a LOGGER.e= rror("some text "); so that it would output to the console under = default settings if it ran.
But first we nee= d to build the application.
  • Select the module-info.java f= ile and using a RMB menu option to Compile File.=C2=A0 The ant build script= will run and eventually output an error message saying that it cannot find= the module log4j.api.
I hope this is comprehensive enough.



--000000000000c0d010057762a462--