2

I get this error stack when trying to SQL profile a Java 8 project which I don't get on 12.5 and below:

Profiler Agent: Established connection with the tool
Profiler Agent: Local accelerated session
Exception in thread "*** Profiler Agent Communication Thread" java.lang.NoSuchMethodError: java.nio.MappedByteBuffer.rewind()Ljava/nio/MappedByteBuffer;
    at org.netbeans.lib.profiler.server.EventBufferManager.openBufferFile(EventBufferManager.java:144)
    at org.netbeans.lib.profiler.server.ProfilerInterface.createEventBuffer(ProfilerInterface.java:682)
    at org.netbeans.lib.profiler.server.ProfilerInterface.initiateProfiling(ProfilerInterface.java:615)
    at org.netbeans.lib.profiler.server.ProfilerServer.handleClientCommand(ProfilerServer.java:1398)
    at org.netbeans.lib.profiler.server.ProfilerServer.listenToClient(ProfilerServer.java:1753)
    at org.netbeans.lib.profiler.server.ProfilerServer.run(ProfilerServer.java:676)
skomisa
  • 16,436
  • 7
  • 61
  • 102
trilogy
  • 1,738
  • 15
  • 31
  • [1] What JDK was NetBeans using for releases 12.5, 12.6 and 13? [2] Since you are getting a `NoSuchMethodError` for method `rewind()` in `java.nio.MappedByteBuffer`, this article may be of interest: _"[ByteBuffer and the Dreaded NoSuchMethodError](https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror/)"_. It states: _"A NoSuchMethodError typically is an indication for a mismatch of the Java version used to compile some code, and the Java version used for running it: some method existed at compile time, but it’s not available at runtime..."_ – skomisa Mar 15 '22 at 00:29
  • @skomisa Java8u212 for all versions – trilogy Mar 15 '22 at 12:56
  • [1] Regardless of your specific problem, you [can't use JDK8 on NetBeans 13](https://netbeans.apache.org/download/nb13/nb13.html): _"The Apache NetBeans 13 binary releases require JDK 11+, and officially support running on JDK 11 and JDK 17". I'm surprised you can even start NetBeans 13 with JDK 8. [2] Is the stack trace in your question from running on NB 12.6 or NB 13? [3] On NB 13, run NetBeans using JDK 11 or 17. Then rebuild your project after changing this setting: {your project} > Properties > Sources > Source/Binary Format: **JDK 8**. Does that resolve the issue? – skomisa Mar 15 '22 at 14:37
  • I get the same error with 12.6 yes. – trilogy Mar 15 '22 at 17:16
  • I don't have JDK 11 on my system currently – trilogy Mar 15 '22 at 17:17
  • If you want to use NB13, you _must_ install either JDK 11 or JDK 17 on your system - you have no choice. Once you do that, and NB13 is running under JDK 11 or JDK 17, see if the problem still occurs with your Java 8 project. If it does then rebuild it (as described in my earlier comment) to see if that resolves the issue. If the problem still persists, update your question with the new stack trace. (Ideally, you should have raised this issue as two separate questions; one for NB 12.6 and one for NB 13.0. I'm just focusing on NB13.) – skomisa Mar 15 '22 at 19:17
  • Shouldn't 12.6 still work for 8 though? I bet if they fix 12.6 it will fix it for 13. – trilogy Mar 15 '22 at 19:59
  • No, 12,.6 won't work with JDK 8. The [Deployment Platforms for NetBeans 12.6](https://netbeans.apache.org/download/nb126/nb126.html) states _"The Apache NetBeans 12.6 binary releases **require JDK 11+**, and officially support running on JDK 11 and JDK 17."_ (emphasis mine). You first need to be running NetBeans with a supported JDK release on both NB 12.6 and NB 13. Once that is done, update your question appropriately if the problem persists. (But if it does persist, first try the rebuild approach I described in an earlier comment.) – skomisa Mar 15 '22 at 20:25

3 Answers3

1

I had the same problem. Could not solve it with the answers supplied in comments here. The solution is to review the file nbactions.xml, preferably going back to a copy from a new project. My one perhaps got slightly corrupted by switching between different Java platforms.

user250343
  • 1,163
  • 1
  • 15
  • 24
0

I was able to make it work by going to my nbactions.xml file and commenting out the profile action such as:

            ...
            <properties>
                <exec.vmArgs></exec.vmArgs>
                <exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
                <exec.mainClass>com.macnt.app.Aplicacion</exec.mainClass>
                <exec.executable>java</exec.executable>
                <exec.appArgs></exec.appArgs>
            </properties>
        </action>

        <!-- Commented out this -->
        <!--<action>
            <actionName>profile</actionName>
            <packagings>
                <packaging>jar</packaging>
            </packagings>
            <goals>
                <goal>process-classes</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
            </goals>
            <properties>
                <exec.args>-classpath %classpath com.macnt.app.Aplicacion</exec.args>
                <exec.executable>java</exec.executable>
            </properties>
        </action>-->

    </actions>
David Rochin
  • 317
  • 3
  • 11
-1

In my case I have project written in Java 8 that is run in production with Java 8, and I used Netbeans 13 to profile it.

To run Netbeans 13, I have Java 17 on the machine. The project is configured as Source/binary format: 1.8 in properties>sources; and Java platform JDK 1.8 in properties>build>compile.

I was getting the same error about NoSuchMethodError in MappedByteBuffer.rewind() until I changed properties>build>compile to JDK 17.

I then was able to avoid this error.

Asu
  • 1,723
  • 2
  • 21
  • 32