1
votes

Good morning, I'm triying to use Apache Tomcat 9 with NetBeans 11.1 and JDK 11 in macOS but it doesn't work.

I have installed Apache Tomcat 9.0.31 and configure the Tomcat server in NetBeans, but when I try to start the server the logs looks like it's ok:

NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
26-Feb-2020 10:00:53.276 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/9.0.31
26-Feb-2020 10:00:53.279 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Feb 5 2020 19:32:12 UTC
26-Feb-2020 10:00:53.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.31.0
26-Feb-2020 10:00:53.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Mac OS X
26-Feb-2020 10:00:53.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.13.6
26-Feb-2020 10:00:53.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          x86_64
26-Feb-2020 10:00:53.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/Contents/Home
26-Feb-2020 10:00:53.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           11.0.6+8-LTS
26-Feb-2020 10:00:53.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
26-Feb-2020 10:00:53.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/apache-tomcat-9.0.31
26-Feb-2020 10:00:53.280 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/apache-tomcat-9.0.31
26-Feb-2020 10:00:53.297 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
26-Feb-2020 10:00:53.297 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
26-Feb-2020 10:00:53.297 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
26-Feb-2020 10:00:53.297 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/Library/Tomcat/conf/logging.properties
26-Feb-2020 10:00:53.297 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
26-Feb-2020 10:00:53.298 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
26-Feb-2020 10:00:53.298 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
26-Feb-2020 10:00:53.298 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
26-Feb-2020 10:00:53.298 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
26-Feb-2020 10:00:53.298 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/Library/Tomcat
26-Feb-2020 10:00:53.298 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/Library/Tomcat
26-Feb-2020 10:00:53.298 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/Library/Tomcat/temp
26-Feb-2020 10:00:53.298 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/user/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
26-Feb-2020 10:00:53.587 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
26-Feb-2020 10:00:53.620 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [527] milliseconds
26-Feb-2020 10:00:53.674 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
26-Feb-2020 10:00:53.674 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.31]
26-Feb-2020 10:00:53.681 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/apache-tomcat-9.0.31/webapps/docs]
26-Feb-2020 10:00:53.908 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/apache-tomcat-9.0.31/webapps/docs] has finished in [226] ms
26-Feb-2020 10:00:53.908 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/apache-tomcat-9.0.31/webapps/manager]
26-Feb-2020 10:00:53.940 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/apache-tomcat-9.0.31/webapps/manager] has finished in [31] ms
26-Feb-2020 10:00:53.940 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/apache-tomcat-9.0.31/webapps/examples]
26-Feb-2020 10:00:54.169 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/apache-tomcat-9.0.31/webapps/examples] has finished in [229] ms
26-Feb-2020 10:00:54.169 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/apache-tomcat-9.0.31/webapps/ROOT]
26-Feb-2020 10:00:54.187 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/apache-tomcat-9.0.31/webapps/ROOT] has finished in [17] ms
26-Feb-2020 10:00:54.187 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/apache-tomcat-9.0.31/webapps/host-manager]
26-Feb-2020 10:00:54.204 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/apache-tomcat-9.0.31/webapps/host-manager] has finished in [17] ms
26-Feb-2020 10:00:54.210 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
26-Feb-2020 10:00:54.219 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [598] milliseconds

If I go to http://localhost:8080 in web browser I can see that the Tomcat server is running. The problem is that Netbeans says: "Starting apache Tomcat..." and minutes later an error from netbeans appear that says: "Starting of Tomcat failed", I can't deploy any web application from NetBeans, but in the web browser I can see that is running.

I tried to configure the environment variables like JRE_HOME, JAVA_HOME, CATALINA_HOME, CATALINA_BASE. Also check "No Proxy" in Netbeans General Proxy Settings and configure the connector in server.xml like:

<Connector
      connectionTimeout="20000"
      port="8080"
      protocol="HTTP/1.1"
      redirectPort="8443"
      server="Apache-Coyote/1.1"
    />

But it doesn't work.

I don't know what I can do to resolve it.

Thanks in advance.

(Update)

I have resolved it with: https://issues.apache.org/jira/browse/NETBEANS-3903

2

2 Answers

0
votes

I am not a mac user but Ubuntu. I face with this kind of problems too. What I do is to stop tomcat from terminal, then try to run my application from Netbeans or start tomcat from Netbeans(Services tab).

In addition, if you didn't define tomcat user with manager-gui,manager-script you may not use your tomcat from netbeans(I am not sure about admin role).

<role rolename="admin"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user password="YOUR_PASSWORD" roles="admin,manager-gui,manager-script" username="YOUR_USERNAME" />
0
votes

I also had a similar problem with Netbeans 12, I fixed it by changing my JDK version to the latest version.