Issue
I installed Netbeans 11.2 IDE on my Mac. Under Services -> Servers I added GlassFish Server as a server.
Then I opened a maven project. I could "clean and build" it. Then I wanted to run it but this resulted in the following error message:
No suitable Deployment Server is defined for the project or globally.
I guess this has something to do with the following: there is a window in Netbeans called "Output - Java DB Database Process" and when I started the GlassFish Server the window showed me this message:
Sat Feb 08 18:02:45 CET 2020 : Security manager installed using the Basic server security policy.
Sat Feb 08 18:02:46 CET 2020 : Could not listen on port 1527 on host localhost: java.net.BindException: Address already in use (Bind failed)
I used the following command to check which process was using port 1527:
sudo lsof -n -i :1527 | grep LISTEN
This resulted in the following output (note: I removed the real username and the real IP address)
java 6722 <user> 36u IPv6 <IP Address> 0t0 TCP 127.0.0.1:tlisrv (LISTEN)
Since this is a java process I don't want to just kill it.
What should I do?
P.S.:
The version of the GlassFish Server is 5.1.0, see Screenshot:
P.P.S.: this question didn't help me: NetBeans: No suitable Deployment Server is defined for the project or globally
P.P.P.S.: the server log says - among other things - the following:
Context path from ServletContext: differs from path from bundle: /|#]
Here's a screenshot of the log:
P.P.P.P.S:
the content of the file nb-configuration.xml is the following:
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv3ee6</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
</properties>
</project-shared-configuration>
Solution
For glassfish 5.1 you should change this parameters in nb-configuration.xml
- netbeans_2e_hint_2e_j2eeVersion
- netbeans_2e_hint_2e_deploy_2e_server
Try fist changing gfv3ee6 to gfv5ee8 and then change 1.7-web to 1.8-web
For me worked this config:
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.8-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv5ee8</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
</properties>
It should resolve this error:
No suitable Deployment Server is defined for the project or globally.
As for
Context path from ServletContext: differs from path from bundle: /|#
error try to close (or kill, including NetBeans itself) all java processes and start NetBeans again and run the project. It looks like your project was deployed to a different instance of glassfish (the previous version?).
I suppose you shouldn't worry about these messages:
Sat Feb 08 18:02:45 CET 2020 : Security manager installed using the Basic server security policy.
Sat Feb 08 18:02:46 CET 2020 : Could not listen on port 1527 on host localhost: java.net.BindException: Address already in use (Bind failed)
unless it indeed because of the previous instances of glassfish. In such a case just stop the previous instance or kill it.
Answered By - Dmitry.M
Answer Checked By - Robin (JavaFixing Admin)