modcluster (Wildfly) is not detecting Advertize from Apache - java

I am trying to configure WildFly 8.1.0 with mod_cluster. Both WildFly and Apache are running on the same machine. The machine is Ubuntu 12.04 with Apache 2.2.x
Apache is set up correctly (I believe). I have tested that the advertise module is working correctly by running the test class Advertise found in the mod_proxy source code (github). There are no errors in the apache logs.
I am starting the server as follows: ./standalone.sh -c standalone-ha.xml
If any one can see something wrong with the configuration below and help put me out of days of misery, I would be really grateful....
Apache configuration
CreateBalancers 1
<IfModule manager_module>
#Listen 127.0.1.1:6666
Listen *:6666
ManagerBalancerName mycluster
<VirtualHost *:6666>
KeepAliveTimeout 300
MaxKeepAliveRequests 0
AdvertiseFrequency 5
ServerAdvertise On
AllowDisplay On
<Location />
Order deny,allow
Allow from 127.0.1
</Location>
<Location /mod_cluster_manager>
SetHandler mod_cluster-manager
Order deny,allow
#Deny from all
#Allow from 127.0.1
Allow from all
</Location>
</VirtualHost>
</IfModule>
VirtualHost configuration
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse / balancer://mycluster
ProxyPreserveHost On
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The results of the Advertize test class
received from /178.62.50.xxx:23364
received: HTTP/1.0 200 OK
Date: Sat, 26 Jul 2014 20:03:12 GMT
Sequence: 121
Digest: 4dedd3761d451227f36534b63ca2a8a1
Server: b23584e2-314f-404d-8fde-05069bfe5dc7
X-Manager-Address: 127.0.1.1:6666
X-Manager-Url: /b23584e2-314f-404d-8fde-05069bfe5dc7
X-Manager-Protocol: http
X-Manager-Host: 127.0.1.1
The print out from mod_cluster_manager (178.62.50.xxx:6666/mod_cluster_manager)
mod_cluster/1.2.6.Final
start of "httpd.conf" configuration
mod_proxy_cluster.c: OK
mod_sharedmem.c: OK
Protocol supported: http AJP
mod_advertise.c: OK
Server: 127.0.1.1
Server: 127.0.1.1 VirtualHost: *:80
Server: 127.0.1.1 VirtualHost: *:6666 Advertising on Group 224.0.1.105 Port 23364 for http://127.0.1.1:6666 every 5 seconds
end of "httpd.conf" configuration
Lastly, here are the relevant bits taken from standalone-ha.xml
<subsystem xmlns="urn:jboss:domain:modcluster:1.2">
<mod-cluster-config advertise-socket="modcluster" connector="ajp">
<dynamic-load-provider>
<load-metric type="cpu"/>
</dynamic-load-provider>
</mod-cluster-config>
</subsystem>
<socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/>
<interfaces>
<interface name="management">
<inet-address value="178.62.50.xxx"/>
</interface>
<interface name="public">
<inet-address value="127.0.1.1"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.1.1}"/>
</interface>
</interfaces>
The only part of the server log that relates to modcluster (output during server startup)
15:53:29,805 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017519: Undertow HTTP listener default listening on /127.0.1.1:8080
15:53:29,811 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017519: Undertow AJP listener ajp listening on /127.0.1.1:8009
15:53:29,905 INFO [org.jboss.modcluster] (ServerService Thread Pool -- 54) MODCLUSTER000001: Initializing mod_cluster version 1.3.0.Final
15:53:29,967 INFO [org.jboss.modcluster] (ServerService Thread Pool -- 54) MODCLUSTER000032: Listening to proxy advertisements on /224.0.1.105:23364

I managed to figure out the problem here, finally. The public interface also needs to reference the server IP, not 127.0.1.1.
The updated interface configuration is:
<interfaces>
<interface name="management">
<inet-address value="178.62.50.xxx"/>
</interface>
<interface name="public">
<inet-address value="178.62.50.xxx"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.1.1}"/>
</interface>
</interfaces>

You need to:
use EnableMCPMReceive in that <VirtualHost *:6666> so as to allow it to consume MCMP messages from WildFly
<Location /> in that EnableMCPMReceive enabled VirtualHost must allow IP addresses of WildFly servers
with WildFly, never bind to localhost -- it doesn't make any sense in the mod_cluster environment except when the boxes (Apache and WildFly instances) are located all in a single box; which is likely a local development situation only
the whole chain of events is as follows:
Apache sends a UDP multicast message stating its location (by default the VirtualHost with which is the advertising enabled)
WildFly catches the message and mod_cluster subsystem sends CONFIG and STATUS messages containing its JvmRoute (instance-id), Host, Port, protocol..., load... The Host and Port must be reachable from the Apache HTTP Server.
Apache HTTP Server talks to the WildFly server on its Host:Port with STATUS-RSP messages etc. The communication is bidirectional.
Please, don't confuse this with request routing, by default, client requests are delivered from Apache HTTP Server to WildFly and back via AJP whereas the MCMP messages use HTTP.
HTH
K

Related

Configure JBoss EAP 7 with HTTPS TLS 1.2

I am trying to configure a JBOSS EAP 7.0 server to use HTTPS and TLS 1.2.
I have created a certificcate using the command:
keytool -keystore <PATH>\keystore2.jks -alias servercert -validity 365 -genkey
I have then added the following to the standalone.xml using the cli tool.
<security-realm name="HTTPSRealm">
<server-identities>
<ssl>
<keystore path="<PATH>\keystore2.jks" keystore-password="password" alias="servercert"/>
</ssl>
</server-identities>
</security-realm>
</security-realms>
...
<https-listener name="https" security-realm="HTTPSRealm" socket-binding="https"/>
The port binding for HTTPS is
<socket-binding name="https" port="${jboss.https.port:8082}"/>
When I try and access my web application using https on port 8082 I get a connection closed error from my browswer.
Can anyone tell me what I have done wrong and how to enable HTTPS? There doesn't seem to be any errors being created in the logs and the listener is listed on start-up.
The Certificate seemed to be broken I generated another one and it worked fine.

Spring Boot + Apache Reverse Proxy: This combination of host and port requires TLS

What I have:
I have a Spring Boot app as a docker image in a private registry
SSL Certificate from Let's Encrypt
I ran this commands:
wget https://dl.eff.org/certbot-auto(get certbot)
chmod a+x certbot-auto (make it exec)
./certbot-auto (run it)
openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out keystore.p12 -name tomcat -CAfile chain.pem -caname root (convert to Spring boot compatible keys)
In my Spring Boot app, I added this entries to the properties:
security.require-ssl=true
server.ssl.key-store={key_store_location}
server.ssl.key-store-password={key_store_password}
server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias=tomcat
At this point I can access my app through: https://example.com:8080/ and the certificate is valid.
Then I do this:
My /etc/apache2/sites-enabled/000-default.conf file looks like this:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
ServerAdmin webmaster#localhost
ServerName {domain}
SSLEngine on
SSLProxyEngine On
SSLProtocol All -SSLv2 -SSLv3 # Disable SSL versions with POODLE vulnerability
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:8080/
ProxyPassReverse / https://localhost:8080/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
After I start apache2 and open https://example.com/ I get
Bad Request
This combination of host and port requires TLS.
But, if I enter https://example.com:80/ everything works.
So my question is: what do I need to do to get rid of the port and just get https://example.com/ to work?
Thank you.
EDIT: After I added 443 as suggested, the issue remains with the same error.
Full configuration file:
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
ServerAdmin webmaster#localhost
ServerName example.com
SSLEngine on
SSLProxyEngine On
SSLProtocol All -SSLv2 -SSLv3
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:8080/
ProxyPassReverse / https://localhost:8080/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<VirtualHost *:443>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
ServerAdmin webmaster#localhost
ServerName example.com
SSLEngine on
SSLProxyEngine On
SSLProtocol All -SSLv2 -SSLv3
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:8080/
ProxyPassReverse / https://localhost:8080/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Default Https port is 443. Could you please created SSL VirtualHost for 443 and add all entry inside VirtualHost and test.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Listen 443 https
<VirtualHost Apache-IP:443>
ServerAdmin webmaster#localhost
ServerName {domain}
SSLEngine on
SSLProxyEngine On
SSLProtocol All -SSLv2 -SSLv3 # Disable SSL versions with POODLE vulnerability
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:8080/
ProxyPassReverse / https://localhost:8080/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Dialog between wildfly and haproxy - Invalid PROXY protocol header

I have one linux machine with 2 Wildfly servers listening on 2 différents https ports.
I have one domain and 2 sub-domain: aa.mydomain.fr et bb.mydomain.fr that i redirect to my 2 wildlfy servers using a Haproxy (i didn't find other solutions to redirect 2 sub-domain in dealing with 2 different https ports and one linux server IP)
My HapProxy server configuration (for aa.mydomain.fr only):
global
log 127.0.0.1:514 local0 info
daemon
maxconn 4096
tune.ssl.default-dh-param 1024
ssl-default-bind-options ssl-min-ver TLSv1.2
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
log global
option httplog
option forwardfor
frontend http-in
bind linux_server_ip:80
acl is_demo_site hdr_end(host) aa.mydomain.fr
use_backend demo_site if is_demo_site
frontend https-in
bind linux_server_ip:443 ssl crt /etc/haproxy/cert/mycert.pem
acl is_demo_https_site hdr_end(host) aa.mydomain.fr
use_backend demo_https_site if is_demo_https_site
backend demo_site
server s1 linux_server_ip:8xxx maxconn 32
backend demo_https_site
server s3 linux_server_ip:8yyy maxconn 32
http-request set-header X-Forwarded-Proto https
My wildfly server conf for sub-domain aa.mydomain.fr:
<subsystem xmlns="urn:jboss:domain:undertow:8.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" proxy-address-forwarding="true" enable-http2="true"/>
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true" proxy-protocol="true"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<access-log pattern="%a %t %H %p %U %s %S %T" directory="${jboss.home.dir}/standalone/log" prefix="access_"/>
<http-invoker security-realm="ApplicationRealm"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
</subsystem>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<socket-binding name="http" port="${jboss.http.port:8xxx}"/>
<socket-binding name="https" port="${jboss.https.port:8yyy}"/>
...
</socket-binding-group>
The http redirection works fine but not the https one which return an 502 error code bad Gateway and i have this error message in my wildfly server log:
2019-09-10 10:47:11,746 TRACE [org.xnio.nio] (default I/O-2) Running task org.xnio.nio.QueuedNioTcpServer$1#7b85bf52
2019-09-10 10:47:11,746 TRACE [org.xnio.nio] (default I/O-2) Running task org.xnio.nio.NioHandle$1#dd77838
2019-09-10 10:47:11,746 DEBUG [io.undertow.request.io] (default I/O-2) UT005013: An IOException occurred: java.io.IOException: UT000179: Invalid PROXY protocol header
at io.undertow.core#2.0.15.Final//io.undertow.server.protocol.proxy.ProxyProtocolReadListener.handleEvent(ProxyProtocolReadListener.java:90)
at io.undertow.core#2.0.15.Final//io.undertow.server.protocol.proxy.ProxyProtocolReadListener.handleEvent(ProxyProtocolReadListener.java:34)
at org.jboss.xnio#3.6.5.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.jboss.xnio#3.6.5.Final//org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.jboss.xnio.nio#3.6.5.Final//org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
at org.jboss.xnio.nio#3.6.5.Final//org.xnio.nio.NioHandle$1.run(NioHandle.java:50)
at org.jboss.xnio.nio#3.6.5.Final//org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:612)
at org.jboss.xnio.nio#3.6.5.Final//org.xnio.nio.WorkerThread.run(WorkerThread.java:479)
2019-09-10 10:47:11,747 TRACE [org.xnio.nio] (default I/O-2) Cancelling key channel=java.nio.channels.SocketChannel[connected local=/linux_server_ip:8xxx remote=/linux_server_ip:49866], selector=sun.nio.ch.EPollSelectorImpl#4a7d8873, interestOps=1, readyOps=0 of java.nio.channels.SocketChannel[connected local=/linux_server_ip:8xxx remote=/linux_server_ip:49866] (same thread)
2019-09-10 10:47:11,747 TRACE [org.xnio.nio] (default I/O-2) Added task org.xnio.nio.QueuedNioTcpServer$2#1939a2a9
Details of the error:
private static final byte[] NAME = "PROXY ".getBytes(StandardCharsets.US_ASCII);
…
public void handleEvent(StreamSourceChannel streamSourceChannel) {
PooledByteBuffer buffer = bufferPool.allocate();
boolean freeBuffer = true;
try {
for (; ; ) {
int res = streamSourceChannel.read(buffer.getBuffer());
if (res == -1) {
IoUtils.safeClose(streamConnection);
return;
} else if (res == 0) {
return;
} else {
buffer.getBuffer().flip();
while (buffer.getBuffer().hasRemaining()) {
char c = (char) buffer.getBuffer().get();
if (byteCount < NAME.length) {
//first we verify that we have the correct protocol
if (c != NAME[byteCount]) {
throw **UndertowMessages.MESSAGES.invalidProxyHeader()**;
}
…
Notes:
I use a "Let's encrypt" SSL certificat.
I get the same error code if i remove the "option forwardfor" in the Haproxy conf.
If i add "accept-proxy" in frontend https-in section and "send-proxy" in backend demo_https_site, i get the Following message in haproxy.log: "Received something which does not look like a PROXY protocol header".
When i monitor the header request with FF monitor tools, i don't see X-Forwarded detail...
Software details:
Haproxy v1.8.8/Wildfly v15.0.1
I don't know if the issue come from my wildfly conf or my haproxy conf, can somebody suggest idea or fix please ?
Best regards.
One way I think you could fix this is by adding proxy protocol to your https proxy with the send-proxy or send-proxy-v2 option. e.g:
backend demo_https_site
server s3 linux_server_ip:8yyy maxconn 32 send-proxy
Another way would be to remove proxy-protocol from wildfly, e.g:
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
However, this will means the client's source ip would have to be derived from the X-Forwarded-For header.

reach local WildFly server over LAN

So my firewall is OFF and my standalone.xml contains
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<any-ipv4-address/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:192.168.56.1}"/>
</interface>
</interfaces>
Running netstat gives
C:\Users\Ram>netstat -an | find "8080"
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING
TCP 127.0.0.1:50200 127.0.0.1:8080 TIME_WAIT
Running telnet from another computer connected to the network
C:\Users\Rami>telnet 192.168.56.1 8080
Connecting To 192.168.56.1...Could not open connection to the host, on port 8080
: Connect failed
I can reach the server homepage typing http://192.168.56.1:8080/ on the computer that has the server started on but not from any other device connected to my local home network.
The configuration looks fine, I assume that there is some other Windows /network configuration besides the firewall setting preventing your access.
Try telnet hostname port from your client to your server to check if port is accessible (see this SU answer).

Apache ActiveMQ Starts then Stops Abruptly On Windows

I am running apachemq on windows xp.I have no web server services running or any database of any sort,but i keep on getting this error once i start active mq
ERROR | Failed to start Apache ActiveMQ ([localhost,
ID:computer_1-3725-13902958 73141-0:1], java.net.URISyntaxException:
Illegal character in hostname at index 13:
ws://computer_1:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857
600)
This is the complete log
C:\apache_activemq>.\bin\activemq
Java Runtime: Oracle Corporation 1.7.0_21 C:\Program Files\Java\jdk1.7.0_21\jre
Heap sizes: current=1013632k free=996854k max=1013632k
JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.c
onfig.file=logging.properties -Dhawtio.realm=activemq -Dhawtio.role=admins -Dhaw
tio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal -Djava.security
.auth.login.config=C:\apache_activemq\bin\..\conf\login.config -Dactivemq.classp
ath=C:\apache_activemq\bin\..\conf;C:\apache_activemq\bin\../conf;C:\apache_acti
vemq\bin\../conf; -Dactivemq.home=C:\apache_activemq\bin\.. -Dactivemq.base=C:\a
pache_activemq\bin\.. -Dactivemq.conf=C:\apache_activemq\bin\..\conf -Dactivemq.
data=C:\apache_activemq\bin\..\data -Djava.io.tmpdir=C:\apache_activemq\bin\..\d
ata\tmp
Extensions classpath:
[C:\apache_activemq\bin\..\lib,C:\apache_activemq\bin\..\lib\camel,C:\apache_a
ctivemq\bin\..\lib\optional,C:\apache_activemq\bin\..\lib\web,C:\apache_activemq
\bin\..\lib\extra]
ACTIVEMQ_HOME: C:\apache_activemq\bin\..
ACTIVEMQ_BASE: C:\apache_activemq\bin\..
ACTIVEMQ_CONF: C:\apache_activemq\bin\..\conf
ACTIVEMQ_DATA: C:\apache_activemq\bin\..\data
Loading message broker from: xbean:activemq.xml
INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1#726b5b: startu
p date [Tue Jan 21 12:17:33 EAT 2014]; root of context hierarchy
INFO | PListStore:[C:\apache_activemq\bin\..\data\localhost\tmp_storage] starte
d
INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[C:\apache_activemq\b
in\..\data\kahadb]
INFO | JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099
/jmxrmi
INFO | KahaDB is version 5
INFO | Recovering from the journal ...
INFO | Recovery replayed 14 operations from the journal in 0.16 seconds.
INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
is starting
INFO | Listening for connections at: tcp://0.0.0.0:61616?maximumConnections=100
0&wireFormat.maxFrameSize=104857600
INFO | Connector openwire started
INFO | Listening for connections at: amqp://0.0.0.0:5672?maximumConnections=100
0&wireFormat.maxFrameSize=104857600
INFO | Connector amqp started
INFO | Listening for connections at: stomp://0.0.0.0:61613?maximumConnections=1
000&wireFormat.maxFrameSize=104857600
INFO | Connector stomp started
INFO | Listening for connections at: mqtt://0.0.0.0:1883?maximumConnections=100
0&wireFormat.maxFrameSize=104857600
INFO | Connector mqtt started
ERROR | Failed to start Apache ActiveMQ ([localhost, ID:computer_1-3725-13902958
73141-0:1], java.net.URISyntaxException: Illegal character in hostname at index
13: ws://computer_1:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857
600)
INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
is shutting down
INFO | Connector openwire stopped
INFO | Connector amqp stopped
INFO | Connector stomp stopped
INFO | Connector mqtt stopped
INFO | Connector ws stopped
INFO | PListStore:[C:\apache_activemq\bin\..\data\localhost\tmp_storage] stoppe
d
INFO | Stopping async queue tasks
INFO | Stopping async topic tasks
INFO | Stopped KahaDB
INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
uptime 13.059 seconds
INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
is shutdown
INFO | Closing org.apache.activemq.xbean.XBeanBrokerFactory$1#726b5b: startup d
ate [Tue Jan 21 12:17:33 EAT 2014]; root of context hierarchy
WARN | Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refr
esh' before invoking lifecycle methods via the context: org.apache.activemq.xbea
n.XBeanBrokerFactory$1#726b5b: startup date [Tue Jan 21 12:17:33 EAT 2014]; root
of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLif
ecycleProcessor(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.doClos
e(AbstractApplicationContext.java:1057)
at org.springframework.context.support.AbstractApplicationContext.close(
AbstractApplicationContext.java:1010)
at org.apache.activemq.hooks.SpringContextHook.run(SpringContextHook.jav
a:30)
at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:782)
at org.apache.activemq.xbean.XBeanBrokerService.stop(XBeanBrokerService.
java:122)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:574
)
at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBean
BrokerService.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1608)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1549)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:479)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:64)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:52)
at org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(XBeanBrokerFact
ory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext
(XBeanBrokerFactory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBroker
Factory.java:67)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:71)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:54)
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:87)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:150)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
at org.apache.activemq.console.Main.main(Main.java:115)
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: java.la
ng.IllegalStateException: BeanFactory not initialized or already closed - call '
refresh' before accessing beans via the ApplicationContext
java.lang.RuntimeException: Failed to execute start task. Reason: java.lang.Ille
galStateException: BeanFactory not initialized or already closed - call 'refresh
' before accessing beans via the ApplicationContext
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:91)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:150)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
at org.apache.activemq.console.Main.main(Main.java:115)
Caused by: java.lang.IllegalStateException: BeanFactory not initialized or alrea
dy closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationCon
text.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
at org.springframework.context.support.AbstractApplicationContext.destro
yBeans(AbstractApplicationContext.java:1090)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:487)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:64)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:52)
at org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(XBeanBrokerFact
ory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext
(XBeanBrokerFactory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBroker
Factory.java:67)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:71)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:54)
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:87)
... 10 more
ERROR: java.lang.IllegalStateException: BeanFactory not initialized or already c
losed - call 'refresh' before accessing beans via the ApplicationContext
java.lang.IllegalStateException: BeanFactory not initialized or already closed -
call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationCon
text.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
at org.springframework.context.support.AbstractApplicationContext.destro
yBeans(AbstractApplicationContext.java:1090)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:487)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:64)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:52)
at org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(XBeanBrokerFact
ory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext
(XBeanBrokerFactory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBroker
Factory.java:67)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:71)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:54)
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:87)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:150)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
at org.apache.activemq.console.Main.main(Main.java:115)
C:\apache_activemq>
My %SystemRoot%\system32\drivers\etc\hosts looks like this
127.0.0.1 localhost
127.0.0.1 mpa.one.microsoft.com
My activemq.xml looks like this
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- START SNIPPET: example -->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<!-- Allows log searching in hawtio console -->
<bean id="logQuery" class="org.fusesource.insight.log.log4j.Log4jLogQuery"
lazy-init="false" scope="singleton"
init-method="start" destroy-method="stop">
</bean>
<!--
The <broker> element is used to configure the ActiveMQ broker.
-->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" >
<!-- The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see:
http://activemq.apache.org/slow-consumer-handling.html
-->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"/>
</pendingMessageLimitStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
<!--
The managementContext is used to configure how ActiveMQ is exposed in
JMX. By default, ActiveMQ uses the MBean server that is started by
the JVM. For more information, see:
http://activemq.apache.org/jmx.html
-->
<managementContext>
<managementContext createConnector="true"/>
</managementContext>
<!--
Configure message persistence for the broker. The default persistence
mechanism is the KahaDB store (identified by the kahaDB tag).
For more information, see:
http://activemq.apache.org/persistence.html
-->
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>
<!--
The systemUsage controls the maximum amount of space the broker will
use before disabling caching and/or slowing down producers. For more information, see:
http://activemq.apache.org/producer-flow-control.html
-->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70" />
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<!--
The transport connectors expose ActiveMQ over a given protocol to
clients and other brokers. For more information, see:
http://activemq.apache.org/configuring-transports.html
-->
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<!-- destroy the spring context on shutdown to stop jetty -->
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
</shutdownHooks>
</broker>
<!--
Enable web consoles, REST and Ajax APIs and demos
The web consoles requires by default login, you can disable this in the jetty.xml file
Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
-->
<import resource="jetty.xml"/>
</beans>
<!-- END SNIPPET: example -->
How should i fix this error?.
I had similar problem. The problem gone after reboot. Try to reboot PC and start activemq first.
Probably it related that some ports were already taken.
My hostname which is localhost did not contain any underscores.The only underscore was in my computer name.My old name was computer_1 but i changed it to computer1 and now i am able to use localhost:8161 activemq web console.
To know how to change the computer name when on windows,do google it or refer to windows documentation.This error has nothing to do with hostname proper but rather the computer name.
Check your "activemq.log" in your "data" folder, in my case I obtain this error because I was using a "redeliveryPlugin" and it requires a schedulerSupport="true" in broker definition.

Categories

Resources