Following the Glassfish WIKIs description on how to do port unification (HTTP->HTTPS) results in a ClassCastException and the HTTP port not being usable.
https://glassfish.java.net/wiki-archive/GlassFish%20MS3%20Port%20Unification%20Demo.html
Attention: Change the mentioned classes package names with org.glassfish.grizzly.config.portunif 'cause the demo operates on Grizzly 1.x.
A proper forward to the HTTPS port.
Domain.xml:
<protocol name="http-redirect">
<protocol-chain-instance-handler>
<protocol-chain>
<protocol-filter classname="org.glassfish.grizzly.config.portunif.HttpRedirectFilter" name="redirect-filter"></protocol-filter>
</protocol-chain>
</protocol-chain-instance-handler>
</protocol>
<protocol name="pu-protocol">
<port-unification>
<protocol-finder protocol="http-listener-2" classname="org.glassfish.grizzly.config.portunif.HttpProtocolFinder" name="http-finder"></protocol-finder>
<protocol-finder protocol="http-redirect" classname="org.glassfish.grizzly.config.portunif.HttpProtocolFinder" name="http-redirect"></protocol-finder>
</port-unification>
</protocol>
</protocols>
<network-listeners>
<network-listener protocol="pu-protocol" port="8080" name="http-listener-1" thread-pool="http-thread-pool" transport="tcp"></network-listener>
<network-listener protocol="http-listener-2" port="8181" name="http-listener-2" thread-pool="http-thread-pool" transport="tcp"></network-listener>
<network-listener protocol="admin-listener" port="4848" name="admin-listener" thread-pool="admin-thread-pool" transport="tcp"></network-listener>
</network-listeners>
Stacktrace:
[2017-03-20T11:26:12.395+0100] [Payara 4.1] [WARNING] [] [org.glassfish.grizzly.filterchain.DefaultFilterChain] [tid: _ThreadID=85 _ThreadName=http-thread-pool::http-listener-1(3)] [timeMillis: 1490005572395] [levelValue: 900] [[
GRIZZLY0013: Exception during FilterChain execution
java.lang.ClassCastException: org.glassfish.grizzly.memory.HeapMemoryManager$TrimmableHeapBuffer cannot be cast to org.glassfish.grizzly.http.HttpContent
at org.glassfish.grizzly.config.portunif.HttpRedirectFilter.handleRead(HttpRedirectFilter.java:99)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:526)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
]]
Start the domain
./asadmin start-domain domain1
Make changes to the domain.xml configuration:
Follow the steps in the GF WIKI:
https://glassfish.java.net/wiki-archive/GlassFish%20MS3%20Port%20Unification%20Demo.html
Attention: Change the mentioned classes package names with org.glassfish.grizzly.config.portunif.
Greetings @svendiedrichsen,
Payara Server already uses port unification for its admin web console when the secure admin listener is enabled. In this case, the protocolpu-protocol and the HTTP Protocol finderhttp-finder are already available from the go. I've tested this behaviour and the recommended way to proceed is to run the following asadmin commands from a fresh domain:
asadmin enable-secure-admin
asadmin create-protocol http-redirect
asadmin create-protocol-filter --protocol http-redirect --classname org.glassfish.grizzly.config.portunif.HttpRedirectFilter redirect-filter
asadmin create-protocol-finder --protocol pu-protocol --targetprotocol http-redirect --classname org.glassfish.grizzly.config.portunif.HttpProtocolFinder http-redirect
asadmin set configs.config.server-config.network-config.network-listeners.network-listener.http-listener-1.protocol=pu-protocol
This way, you'll end up with the following configuration in the domain.xml:
<protocol name="sec-admin-listener" security-enabled="true">
<http encoded-slash-enabled="true" default-virtual-server="__asadmin">
<file-cache></file-cache>
</http>
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" client-auth="want" cert-nickname="fturizo_certificate"></ssl>
</protocol>
<protocol name="admin-http-redirect">
<http-redirect secure="true"></http-redirect>
</protocol>
<protocol name="http-redirect">
<protocol-chain-instance-handler>
<protocol-chain>
<protocol-filter classname="org.glassfish.grizzly.config.portunif.HttpRedirectFilter" name="redirect-filter"></protocol-filter>
</protocol-chain>
</protocol-chain-instance-handler>
</protocol>
<protocol name="pu-protocol">
<port-unification>
<protocol-finder protocol="sec-admin-listener" classname="org.glassfish.grizzly.config.portunif.HttpProtocolFinder" name="http-finder"></protocol-finder>
<protocol-finder protocol="admin-http-redirect" classname="org.glassfish.grizzly.config.portunif.HttpProtocolFinder" name="admin-http-redirect"></protocol-finder>
<protocol-finder protocol="http-redirect" classname="org.glassfish.grizzly.config.portunif.HttpProtocolFinder" name="http-redirect"></protocol-finder>
</port-unification>
</protocol>
<network-listeners>
<network-listener protocol="pu-protocol" port="8080" name="http-listener-1" thread-pool="http-thread-pool" transport="tcp"></network-listener>
<network-listener protocol="http-listener-2" port="8181" name="http-listener-2" thread-pool="http-thread-pool" transport="tcp"></network-listener>
<network-listener protocol="pu-protocol" port="4848" name="admin-listener" thread-pool="admin-thread-pool" transport="tcp"></network-listener>
</network-listeners>
And the port unification should work out without issues.
Thank you very much, I'll check this out.
Most helpful comment
Greetings @svendiedrichsen,
Payara Server already uses port unification for its admin web console when the secure admin listener is enabled. In this case, the protocol
pu-protocoland the HTTP Protocol finderhttp-finderare already available from the go. I've tested this behaviour and the recommended way to proceed is to run the following asadmin commands from a fresh domain:This way, you'll end up with the following configuration in the domain.xml:
And the port unification should work out without issues.