how to enable NIO / atmosphere on tomcat 6 - java

I'm trying out atmosphere on tomcat 6 but only long polling works not websockets. The message i receive in the console output is
Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.
Any info on this would be appreciated, thanks
Update: After modifying web.xml and server.xml the error message goes but the chat application always fallsback to long polling - I've tried several different .war deployments of websocket demos and they all behave the same.
I tried Tomcat 7 also, but it still uses long polling.
Some log info for startup
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Installed Default AtmosphereInterceptor [Android Interceptor Support, SSE Interceptor Support, JSONP Interceptor Support]. Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults in your xml to disable them.
10:42:30.423 [main] WARN o.atmosphere.cpr.AtmosphereFramework - No BroadcasterCache configured. Broadcasted message between client reconnection will be LOST. It is recommended to configure the HeaderBroadcasterCache.
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - HttpSession supported: false
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
10:42:30.423 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Using Broadcaster: org.atmosphere.jersey.JerseyBroadcaster
10:42:30.428 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Atmosphere Framework 1.0.0.beta5 started.
27/08/2012 10:42:30 AM org.apache.coyote.http11.Http11NioProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
27/08/2012 10:42:30 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 11568 ms
When the chat client connects
27/08/2012 10:47:57 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
When a message is sent
10:48:09.256 [http-8080-exec-2] DEBUG o.a.cpr.AsynchronousProcessor - Cancelling the connection for request AtmosphereRequest{ contextPath=/atmosphere-rest-chat servletPath=/chat pathInfo=null requestURI=/atmosphere-rest-chat/chat requestURL=http://mogwai:8080/atmosphere-rest-chat/chat destroyable=true}

In context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Loader delegate="true"/>
</Context>
In server.xml:
<Connector connectionTimeout="20000" port="8080"
protocol="org.apache.coyote.http11.Http11NioProtocol"
redirectPort="8443"/>
Make sure you only have one implementation of CometProcessor defined in your classpath. You may want to remove catalina.jar from your webpass if it's bundled in. See this thread for more info:
http://mail-archives.apache.org/mod_mbox/tomcat-users/200707.mbox/%3C11785700.post#talk.nabble.com%3E

Related

Payara Server does not work with Netbeans 12.6 and JDK 17

We are migrating web apps that use java 1.7 here at the company. We then chose to use the latest stable version of JDK 17 and Payara server (we already use Glassfish), however when linking the server on NetBeans the Java 17 LTS platform does not appear to be selected in the server properties. Has anyone ever experienced this?
I have the same issue with NB 12.6 and I was expecting NB team to fix this with NB 13.
But unfortunately, the issue still exists on 13.
Seems related changes in this PR didn't go NB 13 distribution.
After digging for a while found a workaround.
Build latest NetBeans from source as described in this link
Extract and copy org-netbeans-modules-payara-tooling.jar from built zip into /netbeans/enterprise/modules/ folder in NB 12/13 installation location. (The folder is exact in the built zip)
Of course, the other option is to use NB compiled from source.
I faced the same problem as you when adding the Payara server: JDK 17 was not offered as a platform for Payara even though NetBeans was running fine on JDK 17. The Java SE Platform window even explicitly gave me the error Payara server could not be started with JDK 17 (Default). Please select another Java SE Platform. when starting Payara.
I don't have a true solution, but a simple workaround is to add JDK 11 as a second Java platform in NetBeans (Tools > Java Platforms > Add Platform...), and then select JDK 11 instead. Payara runs fine under JDK 11:
After that, just go to http://localhost:4848/ (or whatever alternative port you chose) once the server has been started to verify that Payara is working:
Notes :
You can only use LTS releases for Payara, which currently means that your only JDK options are 8, 11 and 17. See Why Payara Platform Only Supports LTS Versions of JDK for more information on that.
I selected the most recent version of Payara that was offered: 5.2021.9.
I don't know why Payara can't be started using JDK 17 even when NetBeans itself is running on JDK 17, but I suspect that it may be relevant that NetBeans 12.6 only offers "experimental support" for JDK 17. You can pursue this by creating a NetBeans Bug Report, though you will have to register first.
FYI, I have pasted below the content of the Payara server log in case you still have problems:
INFO: Create bundle provisioner class = class
com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.
Registered
com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime#537969f1
in service registry.
#!## LogManagerService.postConstruct : rootFolder=C:\Payara\glassfish
#!## LogManagerService.postConstruct : templateDir=C:\Payara\glassfish\lib\templates
#!## LogManagerService.postConstruct : src=C:\Payara\glassfish\lib\templates\logging.properties
#!## LogManagerService.postConstruct : dest=C:\Payara\glassfish\domains\domain1\config\logging.properties
Running Payara Version: Payara Server 5.2021.9 #badassfish (build
878)|#] Server log file is using Formatter class:
com.sun.enterprise.server.logging.ODLLogFormatter|#] Registered
fish.payara.ha.hazelcast.store.HazelcastBackingStoreFactoryProxy for
persistence-type = hazelcast in BackingStoreFactoryRegistry|#]
Hazelcast Instance Bound to JNDI at payara/Hazelcast|#] JSR107
Caching Provider Bound to JNDI at payara/CachingProvider|#] JSR107
Default Cache Manager Bound to JNDI at payara/CacheManager|#]
Network Listener http-listener-1 started in: 4ms - bound to
[/0.0.0.0:8080]|#] HV000001: Hibernate Validator 6.1.5.Final|#]
Network Listener http-listener-2 started in: 1ms - bound to
[/0.0.0.0:8181]|#] Network Listener admin-listener started in: 2ms -
bound to [/0.0.0.0:4848]|#] Grizzly 2.4.4 started in: 5,262ms -
bound to [http-listener-1:8080, http-listener-2:8181,
admin-listener:4848]|#] Network Listener iiop-service started in:
2ms - bound to [/0.0.0.0:3700]|#] Payara Server 5.2021.9
#badassfish (878) startup time : Felix (2,025ms), startup services(6,171ms), total(8,196ms)|#] Data Grid Status Payara Data
Grid State: DG Version: 4 DG Name: development DG Size: 1 Instances: {
DataGrid: development Name: server Lite: false This: true UUID:
ffa0f7cb-6228-45bd-a4a0-21e098f4bef9 Address: /192.168.50.15:4900 }|#]
Payara Notification Service bootstrapped.|#] Bootstrapping
Monitoring Console Runtime|#] Starting monitoring data collection
for server|#] Starting monitoring watch collection for server|#]
Network Listener JMS_PROXY_default_JMS_host started in: 2ms - bound to
[/0.0.0.0:7676]|#] JMXStartupService has started JMXConnector on
JMXService URL
service:jmx:rmi://0.0.0.0:8686/jndi/rmi://0.0.0.0:8686/jmxrmi|#]
GlassFishORBFactory service initialized.|#] Listening to REST
requests at context: /management/domain.|#] Skipping registration of
inhabitant for service reference
[org.osgi.service.metatype.MetaTypeProvider] as the service object
could not be obtained.|#] Java security manager is disabled.|#]
Entering Security Startup Service.|#] Loading policy provider
com.sun.enterprise.security.provider.PolicyWrapper.|#] Security
Service(s) started successfully.|#] Created HTTP listener
http-listener-1 on host/port 0.0.0.0:8080|#] Created HTTP listener
http-listener-2 on host/port 0.0.0.0:8181|#] Created HTTP listener
admin-listener on host/port 0.0.0.0:4848|#] Created virtual server
server|#] Created virtual server __asadmin|#] Virtual server
server loaded default web module |#] Loading application __admingui
done in 1,757 ms|#] Initializing Mojarra |version.string| for
context ''|#] Loading application [__admingui] at [/]|#] Context
path from ServletContext: differs from path from bundle: /|#]
Redirecting to /common/version.jsf|#] Admin Console: Initializing
Session Attributes...|#]
INFO: Create bundle provisioner class = class
com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.
Registered
com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime#537969f1
in service registry.
#!## LogManagerService.postConstruct : rootFolder=C:\Payara\glassfish
#!## LogManagerService.postConstruct : templateDir=C:\Payara\glassfish\lib\templates
#!## LogManagerService.postConstruct : src=C:\Payara\glassfish\lib\templates\logging.properties
#!## LogManagerService.postConstruct : dest=C:\Payara\glassfish\domains\domain1\config\logging.properties
Running Payara Version: Payara Server 5.2021.9 #badassfish (build
878)|#] Server log file is using Formatter class:
com.sun.enterprise.server.logging.ODLLogFormatter|#] Registered
fish.payara.ha.hazelcast.store.HazelcastBackingStoreFactoryProxy for
persistence-type = hazelcast in BackingStoreFactoryRegistry|#]
Hazelcast Instance Bound to JNDI at payara/Hazelcast|#] JSR107
Caching Provider Bound to JNDI at payara/CachingProvider|#] JSR107
Default Cache Manager Bound to JNDI at payara/CacheManager|#]
Network Listener http-listener-1 started in: 4ms - bound to
[/0.0.0.0:8080]|#] HV000001: Hibernate Validator 6.1.5.Final|#]
Network Listener http-listener-2 started in: 1ms - bound to
[/0.0.0.0:8181]|#] Network Listener admin-listener started in: 2ms -
bound to [/0.0.0.0:4848]|#] Grizzly 2.4.4 started in: 5,262ms -
bound to [http-listener-1:8080, http-listener-2:8181,
admin-listener:4848]|#] Network Listener iiop-service started in:
2ms - bound to [/0.0.0.0:3700]|#] Payara Server 5.2021.9
#badassfish (878) startup time : Felix (2,025ms), startup services(6,171ms), total(8,196ms)|#] Data Grid Status Payara Data
Grid State: DG Version: 4 DG Name: development DG Size: 1 Instances: {
DataGrid: development Name: server Lite: false This: true UUID:
ffa0f7cb-6228-45bd-a4a0-21e098f4bef9 Address: /192.168.50.15:4900 }|#]
Payara Notification Service bootstrapped.|#] Bootstrapping
Monitoring Console Runtime|#] Starting monitoring data collection
for server|#] Starting monitoring watch collection for server|#]
Network Listener JMS_PROXY_default_JMS_host started in: 2ms - bound to
[/0.0.0.0:7676]|#] JMXStartupService has started JMXConnector on
JMXService URL
service:jmx:rmi://0.0.0.0:8686/jndi/rmi://0.0.0.0:8686/jmxrmi|#]
GlassFishORBFactory service initialized.|#] Listening to REST
requests at context: /management/domain.|#] Skipping registration of
inhabitant for service reference
[org.osgi.service.metatype.MetaTypeProvider] as the service object
could not be obtained.|#] Java security manager is disabled.|#]
Entering Security Startup Service.|#] Loading policy provider
com.sun.enterprise.security.provider.PolicyWrapper.|#] Security
Service(s) started successfully.|#] Created HTTP listener
http-listener-1 on host/port 0.0.0.0:8080|#] Created HTTP listener
http-listener-2 on host/port 0.0.0.0:8181|#] Created HTTP listener
admin-listener on host/port 0.0.0.0:4848|#] Created virtual server
server|#] Created virtual server __asadmin|#] Virtual server
server loaded default web module |#] Loading application __admingui
done in 1,757 ms|#] Initializing Mojarra |version.string| for
context ''|#] Loading application [__admingui] at [/]|#] Context
path from ServletContext: differs from path from bundle: /|#]
Redirecting to /common/version.jsf|#] Admin Console: Initializing
Session Attributes...|#]

ActiveMq does not stop if broker is not available

Getting the below error while stopping the Apache ActiveMQ 5.15.6. Setting the createConnector="false" becuase do not want default JMX connection.
Note:- Start the ActiveMQ(activemq-admin.bat start)
Stop the ActiveMQ(activemq-admin.bat stop)
<managementContext createConnector="false"/>
Error:
Connecting to JMX URL:
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi INFO: Broker not
available at: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi

Tomcat webapp hangs at startup due to db-connection

We have deployed a war file to tomcat container (java/hibernate web application). When starting tomcat, the deployment process freezes at the point where the Database Connection is being initialized. And then, tomcat server never starts. It's the company's test database which fails on startup, when changing to the development server, it works fine. However, I can connect to the test database using the db-visualiser tool.
Here is what we can see in the catalina log, when launching tomcat.
15:16:59.481 [Thread-1] INFO o.h.c.DriverManagerConnectionProvider.configure 64 - Using Hibernate built-in connection pool (not for production use!)
15:16:59.481 [Thread-1] INFO o.h.c.DriverManagerConnectionProvider.configure 65 - Hibernate connection pool size: 20
15:16:59.482 [Thread-1] INFO o.h.c.DriverManagerConnectionProvider.configure 68 - autocommit mode: false
15:16:59.562 [Thread-1] INFO o.h.c.DriverManagerConnectionProvider.configure 103 - using driver: com.sybase.jdbc3.jdbc.SybDriver at URL: jdbc:sybase:Tds:servername:5000/dbname
15:16:59.563 [Thread-1] INFO o.h.c.DriverManagerConnectionProvider.configure 109 - connection properties: {user=username, password=password}
The environments are as follows: Java6, hibernate, tomcat6, sybase
Turned out that the log file on the server was takling too much space. It was deleted and the server became responsive again

Connecting Java client to Hazelcast-Kubernetes fails

I'm running a kubernetes cluster in which I am deploying a "cloud native hazelcast" following the instructions on the kubernetes-hazelcast github page. Once I have a number of hazelcast instances running, I try to connect a java client to one of the instances but for some reason the connection fails.
Some background
Using a kubernetes external endpoint I can connect to hazelcast from outside the kubernetes cluster. When I do a REST call with curl kubernetes-master:32469/hazelcast/rest/cluster, I get a correct response from hazelcast with it's cluster information. So I know my endpoint works.
The hazelcast-kubernetes deployment uses the hazelcast-kubernetes-bootstrapper which allows some configuration by setting environment variables with the replication controller, but I'm using all defaults. So my group and password are "someGroup" and "someSecret".
The java client
My Java client code is really straightforward:
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(0);
clientConfig.getNetworkConfig().setConnectionTimeout(10000);
clientConfig.getNetworkConfig().setConnectionAttemptPeriod(2000);
clientConfig.getNetworkConfig().addAddress("kubernetes-master:32469");
clientConfig.getGroupConfig().setName("someGroup");
clientConfig.getGroupConfig().setPassword("someSecret")
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
When start my client this is the log output of the hazelcast container
2016-07-05 12:54:38.143 INFO 5 --- [thread-Acceptor] com.hazelcast.nio.tcp.SocketAcceptor : [172.16.15.4]:5701 [someGroup] [3.5.2] Accepting socket connection from /172.16.29.0:54333
2016-07-05 12:54:38.143 INFO 5 --- [ cached4] c.h.nio.tcp.TcpIpConnectionManager : [172.16.15.4]:5701 [someGroup] [3.5.2] Established socket connection between /172.16.15.4:5701
2016-07-05 12:54:38.157 INFO 5 --- [.IO.thread-in-1] c.h.nio.tcp.SocketClientMessageReader : [172.16.15.4]:5701 [someGroup] [3.5.2] Unknown client type: <
And the console output of the client
jul 05, 2016 2:54:37 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_someGroup][3.6.2] is STARTING
jul 05, 2016 2:54:38 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_someGroup][3.6.2] is STARTED
jul 05, 2016 2:54:48 PM com.hazelcast.client.spi.impl.ClusterListenerSupport
WARNING: Unable to get alive cluster connection, try in 0 ms later, attempt 1 of 2147483647.
jul 05, 2016 2:54:58 PM com.hazelcast.client.spi.impl.ClusterListenerSupport
WARNING: Unable to get alive cluster connection, try in 0 ms later, attempt 2 of 2147483647.
jul 05, 2016 2:55:08 PM com.hazelcast.client.spi.impl.ClusterListenerSupport
etc...
The client just keeps trying to connect but no connection is ever established.
What am I missing?
So why won't my client connect to the hazelcast instance? Is it some configuration part I'm missing?
Not sure about the official kubernetes support, however Hazelcast has a kubernetes discovery plugin (based on the new discovery spi) that works on both, client and nodes: https://github.com/noctarius/hazelcast-kubernetes-discovery
Looking at the console logs, you have different Hazelcast versions between Node and Client? Can you either update both to be 3.6.4 i.e., the latest or just change the cluster to be 3.6.2 to match with client. 3.6.x has many configuration changes and many bug fixes as well.

zabbix server can't connect to java gateway

I have installed zabbix server and java gateway in same linux server and started zabbix-server and zabbix-java-gateway service. the OS is CentOS 6.5, java is JDK1.6.0_45, IP is 192.98.12.240, zabbix server and zabbix java gateway version is 2.2.9. I have stop iptables service.
Then in zabbix web console, I added a host that enabled jmx interface. My host IP is 192.98.12.198 and JMX post is 9999. In Jconsole, I can connect to this JMX enabled java application. But in zabbix web console, it show error:
below are my zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=4
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
JavaGateway=192.98.12.240
JavaGatewayPort=10052
StartJavaPollers=5
SNMPTrapperFile=/var/log/snmptt/snmptt.log
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
below are my zabbix_java_gateway.conf
LISTEN_IP=192.98.12.240
LISTEN_PORT=10052
PID_FILE="/var/run/zabbix/zabbix_java.pid"
START_POLLERS=5
below are some snippes of zabbix_server.log
13573:20150321:100114.503 In substitute_key_macros() data:'jmx[java.lang:type=Memory,HeapMemoryUsage.used]'
13573:20150321:100114.503 End of substitute_key_macros():SUCCEED data:'jmx[java.lang:type=Memory,HeapMemoryUsage.used]'
13573:20150321:100114.503 In substitute_simple_macros() data:'9999'
13573:20150321:100114.503 In substitute_simple_macros() data:EMPTY
13573:20150321:100114.503 In substitute_simple_macros() data:EMPTY
13573:20150321:100114.503 In get_values_java() host:'myhost' addr:'192.98.12.198' num:1
13573:20150321:100114.503 getting Java values failed: cannot connect to [[192.98.12.240]:10052]: [13] Permission denied
13573:20150321:100114.503 End of get_values_java()
13573:20150321:100114.503 In deactivate_host() hostid:10106 itemid:23899 type:16
13573:20150321:100114.503 query [txnlev:1] [begin;]
13573:20150321:100114.503 query [txnlev:1] [update hosts set jmx_disable_until=1426903334,jmx_error='cannot connect to [[192.98.12.240]:10052]: [13] Permission denied' where hostid=10106]
13573:20150321:100114.504 query [txnlev:1] [commit;]
13573:20150321:100114.526 deactivate_host() errors_from:1426901309 available:2
13573:20150321:100114.526 End of deactivate_host()
13573:20150321:100114.526 End of get_values():1
below are my zabbix_java_gateway.log
2015-03-21 10:54:29.078 [main] INFO com.zabbix.gateway.JavaGateway - Zabbix Java Gateway 2.2.9 (revision 52686) has started
2015-03-21 10:54:29.086 [main] DEBUG c.z.gateway.ConfigurationManager - starting to parse configuration parameters
2015-03-21 10:54:29.086 [main] DEBUG c.z.gateway.ConfigurationManager - found pidFile configuration parameter with value '/var/run/zabbix/zabbix_java.pid'
2015-03-21 10:54:29.087 [main] DEBUG c.z.gateway.ConfigurationManager - received pidFile configuration parameter, daemonizing
2015-03-21 10:54:29.088 [main] DEBUG c.z.gateway.ConfigurationManager - found listenIP configuration parameter with value '192.98.12.240'
2015-03-21 10:54:29.089 [main] DEBUG c.z.gateway.ConfigurationManager - found listenPort configuration parameter with value '10052'
2015-03-21 10:54:29.089 [main] DEBUG c.z.gateway.ConfigurationManager - found startPollers configuration parameter with value '5'
2015-03-21 10:54:29.089 [main] DEBUG c.z.gateway.ConfigurationManager - finished parsing configuration parameters
2015-03-21 10:54:29.092 [main] INFO com.zabbix.gateway.JavaGateway - listening on /192.98.12.240:10052
2015-03-21 10:54:29.097 [main] DEBUG com.zabbix.gateway.JavaGateway - created a thread pool of 5 pollers
Please Help and Thanks.
ps: I had changed JavaGateway in zabbix_server.conf to localhost or 127.0.0.1, I didn't work too.
# Modify zabbix_server.conf
JavaGateway=127.0.0.1
# Modify zabbix_java_gateway.conf
LISTEN_IP=127.0.0.1
# Restart Services
service zabbix-server restart
service zabbix-java-gateway restart
Note : Make sure SELinux or iptables not blocking the requests.
I found the solution myself.
Add -Djava.net.preferIPv4Stack=true to the VM options solve the problem

Categories

Resources