You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Alain Vitry <al...@gmail.com> on 2022/05/02 09:15:58 UTC

Re: remote debug with java 17 (any version > 8) and netbeans 13 and ant template

Hello Moacir

Thank you for the hints. With further steps, it leads to resolution.

From the log, it is definitely a  problem instantiating the js script
engine :

-debug-remote-key:
D:\AlternativesEnergies\dev\CLM\code\CLMServices\IPStreamSrv\nbproject\remote-platform-impl.xml:143:
Unable to create javax script engine for javascript
at
org.apache.tools.ant.util.optional.JavaxScriptRunner.evaluateScript(JavaxScriptRunner.java:145)
at
org.apache.tools.ant.util.optional.JavaxScriptRunner.executeScript(JavaxScriptRunner.java:82)
at
org.apache.tools.ant.taskdefs.optional.script.ScriptDef.executeScript(ScriptDef.java:348)
at
org.apache.tools.ant.taskdefs.optional.script.ScriptDefBase.execute(ScriptDefBase.java:52)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at jdk.internal.reflect.GeneratedMethodAccessor129.invoke(Unknown Source)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1391)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1254)
at
org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:261)
at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:573)
at org.netbeans.core.execution.RunClassThread.doRun(RunClassThread.java:132)
at
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:81)
BUILD FAILED (total time: 1 second)



I followed your suggestion and included rhino on ant's classpath, and the
problem shifted indeed.

.....
Exiting D:\----------\dev\CLM\code\CLMServices\IPStreamSrv\build.xml.
Connecting to 10.11.12.50:22
cmd : cd '/home/ae/netbeans//IPStreamSrv';
'/usr/lib/jvm/java-17-openjdk-arm64/bin/java'
 -Xrunjdwp:transport=dt_socket,address=kubernetes.docker.internal:34882
-Dfile.encoding=UTF-8   -jar
/home/ae/netbeans//IPStreamSrv/dist/IPStreamSrv.jar
ERROR: transport error 202: getaddrinfo:* f**ailed to parse address*
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized
[./src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:734]


Digging into the initialisation of the variables, shows that the script
works well, and jpda.port and jpda.address are properly populated with the
local kubernetes instance:

-init-remote-platform-properties:
Setting project property: remote.platform.home.dir ->
/usr/lib/jvm/java-17-openjdk-arm64
Setting project property: remote.platform.work.dir -> /home/ae/netbeans/
Setting project property: remote.platform.host -> 10.11.12.50
Setting project property: remote.platform.port -> 22
Setting project property: remote.platform.user -> ae
Setting project property: remote.platform.auth -> KEY
Setting project property: remote.platform.keyfile ->
C:\Users\AE\.ssh\id_rsa_old_pem
Property "platforms.rpi4-jdk17.platform.exec.decorator" has not been set
Setting project property: remote.platform.exec.decorator ->
${platforms.rpi4-jdk17.platform.exec.decorator}
Condition false; not setting remote.platform.auth.passwd
Condition true; setting remote.platform.auth.key to true
Setting project property: remote.platform.auth.key -> true
Setting project property: remote.project.name -> IPStreamSrv
Setting project property: remote.dist.dir.name -> dist
Setting project property: remote.dist.jar.name -> IPStreamSrv.jar
Setting project property: remote.project.dir ->
/home/ae/netbeans//IPStreamSrv
Setting project property: remote.dist.dir ->
/home/ae/netbeans//IPStreamSrv/dist
Setting project property: remote.dist.jar ->
/home/ae/netbeans//IPStreamSrv/dist/IPStreamSrv.jar
Setting project property: remote.java.executable ->
/usr/lib/jvm/java-17-openjdk-arm64/bin/java
Adding reference: org.apache.ant.scriptrepo
 +Datatype addressport
org.apache.tools.ant.taskdefs.optional.script.ScriptDefBase
Condition false; setting remote.platform.exec.prefix to
Setting project property: remote.platform.exec.prefix ->
-copy-to-remote-platform:
 +Datatype
http://www.netbeans.org/ns/j2se-project/remote-platform/1:runwithpasswd
org.apache.tools.ant.taskdefs.MacroInstance
creating macro
http://www.netbeans.org/ns/j2se-project/remote-platform/1:runwithpasswd
 +Datatype
http://www.netbeans.org/ns/j2se-project/remote-platform/1:runwithkey
org.apache.tools.ant.taskdefs.MacroInstance
creating macro
http://www.netbeans.org/ns/j2se-project/remote-platform/1:runwithkey
-check-vm-debug:
Property "platforms.rpi4-jdk17.platform.jvm.debug" has not been set
Setting project property: remote.platform.jvm.debug ->
${platforms.rpi4-jdk17.platform.jvm.debug}
Class org.apache.tools.ant.taskdefs.condition.Contains loaded from parent
loader (parentFirst)
Class org.apache.tools.ant.types.selectors.ContainsSelector loaded from
parent loader (parentFirst)
Condition true; setting remote.platform.jvm.debug.available to true
Setting project property: remote.platform.jvm.debug.available -> true
-ask-password:
Skipped because property 'remote.platform.auth.passwd' not set.
-debug-start-debugger:
Setting project property: *jpda.address -> kubernetes.docker.internal:34882*
-debug-remote-passwd:
Skipped because property 'remote.platform.auth.passwd' not set.
-ask-passphrase:
Skipped because property 'remote.platform.passphrase' set.
-debug-remote-key:
Overriding previous definition of property "jpda.port"
Setting project property: *jpda.port -> 34882*


The problem comes from the fact that we assign ${jpda.address} instead of
the port number. So if I change :

*<remote:runwithkey *
*additionaljvmargs="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>*
*to*
*<remote:runwithkey additionaljvmargs="${debug-args-line}
-Xrunjdwp:transport=${debug-transport},address=${jpda.port}"/>*


the problem is gone.

My question is then how to we permanently fix this script ? Should I raise
a ticket for it ?
If that works under previous jdk version, then the beahaviour is definitely
different as we need to modify the ant script.

To summarize what we've done:
- the problem occurs while trying to remote debug an application with jdk 17
- with jdk 17, js engine is gone, and javascript scriptdef
name="addressport" of the remote-platform-impl.xml fails to execute and
populate jpda.* values
- we fix that by adding rhino js engine to ant path (in netbeans java> ant
options)
- we then need to fix the  remote-platform-impl.xml to pass jpda.port to
the remote jvm args

Problems left :
- modify  remote-platform-impl.xml template which is used to generate the
file, as it is overwritten on project open
- find a uniform solution depending on jdk version or document the
beahaviour ?

Please let me know what is the best way to help further.
Thank you for your hindsight. Ant is still way easier to comprehend and fix
than maven and has its place in the ecosystem.


Regards,
Alain


Le sam. 30 avr. 2022 à 00:02, Moacir da Roza <mo...@gmail.com> a écrit :

> Hi Alain,
> I can replicate your error it only occur if you run netbeans with JDK17, i
> was running my netbeans with JDK 11
> Download Rhino
> https://github.com/mozilla/rhino/releases/tag/Rhino1_7_14_Release
>
> [image: image.png]
>
> And configure classpath as follow:
> [image: image.png]
>
> After, maybe you get on error:
> Error: Could not find or load main class args-line
> Caused by: java.lang.ClassNotFoundException: args-line
> Edit *remote-platform-impl.xml*.
> replace
>
> * <remote:runwithpasswd additionaljvmargs="${debug-args-line}
>  -Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>*
> by
>
> * <remote:runwithpasswd
> additionaljvmargs="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>*
> And try execute again
>
> Em sex., 29 de abr. de 2022 às 18:27, Moacir da Roza <mo...@gmail.com>
> escreveu:
>
>> Hi,
>> Please send all log to us, go to:
>> [image: image.png]
>>
>>
>>
>> And try execute again to get complete log on output, probably the
>> javascript engine is only a warning and not a an error, and the error is
>> caused by other things, if you need include external jar or support other
>> scripting engine look:
>> https://ant.apache.org/manual/install.html#librarydependencies
>> And any external jar needed by Ant needs to be include on classpath
>> option of print screen above, or you can try include the jars directly on
>> netbeans/excite/ant/lib/ ( i don't recommend )
>>
>> <https://ant.apache.org/manual/install.html#librarydependencies>
>>
>>
>> Em sex., 29 de abr. de 2022 às 11:45, Alain Vitry <al...@gmail.com>
>> escreveu:
>>
>>> Hello,
>>>
>>> I've tried to fix remote debug a raspberry pi with netbeans 13 and jdk
>>> 17 which fails because the build script relies on a javascript scriptdef
>>> and javascript engine is not available since jdk 9.
>>>
>>> In the remote-platform-impl.xml the failing bit is :
>>> <scriptdef name="addressport" language="javascript">
>>>             <attribute name="address" />
>>>             <attribute name="property" />
>>>          <![CDATA[
>>>            var address = attributes.get("address");
>>>            project.setProperty(attributes.get("property"),
>>> address.split(":")[1]);
>>>          ]]>
>>> </scriptdef>
>>>
>>> This defines the addressport property and parses for the port number
>>> from the jpda address for feeding the ssh tunnel that connects the remote
>>> app listening debugger to a local port :
>>> <remotetunnel lport="${jpda.port}" lhost="localhost"
>>> rport="${jpda.port}"/>
>>>
>>> So this basically just parses the port part from the jpda.address
>>> property.
>>>
>>> I've tried to include a javascript engine, as suggested in this
>>> discussion (
>>> https://www.mail-archive.com/commits@netbeans.apache.org/msg41381.html)
>>> with no success, probably due to lack of understanding of the process.
>>>             <classpath path="antjars/bsf.jar"/>
>>>             <classpath path="antjars/commons-logging-1.2.jar"/>
>>>             <classpath path="antjars/org.mozilla.javascript-1.7.2.jar"/>
>>>
>>> What would be an appropriate way to fix this script long term ?
>>> - a different approach than scripting  to recover the jpda port  number ?
>>> - is there another scripting engine that is easy (no dependency) to
>>> integrate ? After all we now have jshell
>>>
>>> Thank you for your hindshights,
>>> Alain
>>>
>>
>>
>> --
>> Moacir R.F
>> Desenvolvedor de Softwares
>>
>> http://www.moacirrf.com.br
>>
>
>
> --
> Moacir R.F
> Desenvolvedor de Softwares
>
> http://www.moacirrf.com.br
>