resolve AMQ-2212|https://issues.apache.org/activemq/browse/AMQ-2212 - fix resource resolving for RAR with weblogic - set the thread context class loader for the thread that starts the embedded broker

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@766053 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2009-04-17 15:34:34 +00:00
parent 7a4d84a5b8
commit a259babc34
5 changed files with 63 additions and 36 deletions

View File

@ -74,6 +74,11 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement
@Override
public void run () {
try {
// ensure RAR resources are available to xbean (needed for weblogic)
log.debug("original thread context classLoader: " + Thread.currentThread().getContextClassLoader());
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
log.debug("current (from getClass()) thread context classLoader: " + Thread.currentThread().getContextClassLoader());
synchronized( ActiveMQResourceAdapter.this ) {
broker = BrokerFactory.createBroker(new URI(brokerXmlConfig));
}

View File

@ -197,6 +197,14 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
@ -222,3 +230,4 @@
</build>
</project>

View File

@ -284,7 +284,10 @@
<config-property-type>java.lang.String</config-property-type>
<config-property-value></config-property-value>
<!--
To use the broker-config.xml from the root for the RAR
<config-property-value>xbean:broker-config.xml</config-property-value>
To use an external file or url location
<config-property-value>xbean:file:///amq/config/jee/broker-config.xml</config-property-value>
-->
</config-property>

View File

@ -18,47 +18,22 @@
<!-- START SNIPPET: xbean -->
<beans xmlns="http://activemq.apache.org/schema/core">
<broker useJmx="true">
<!-- In ActiveMQ 4, you can setup destination policies. note: this xml format may still change a bit -->
<destinationPolicy>
<policyMap><policyEntries>
<policyEntry topic="FOO.>">
<dispatchPolicy>
<strictOrderDispatchPolicy />
</dispatchPolicy>
<subscriptionRecoveryPolicy>
<lastImageSubscriptionRecoveryPolicy />
</subscriptionRecoveryPolicy>
</policyEntry>
</policyEntries></policyMap>
</destinationPolicy>
<!-- shutdown hook is disabled as RAR classloader may be gone at shutdown -->
<broker useJmx="true" useShutdownHook="false">
<managementContext>
<!-- use appserver provided context instead of creating one,
for jboss use: -Djboss.platform.mbeanserver -->
<managementContext createConnector="false"/>
</managementContext>
<persistenceAdapter>
<journaledJDBC journalLogFiles="5" dataDirectory="../data"/>
<!-- To use a different datasource, use th following syntax : -->
<!--
<journaledJDBC journalLogFiles="5" dataDirectory="../data" dataSource="#postgres-ds"/>
-->
</persistenceAdapter>
<transportConnectors>
<!-- prefixing a connector with discovery: causes the connector to be advertiesed over rendezvous -->
<transportConnector uri="tcp://localhost:61616" discoveryUri="multicast://default"/>
<transportConnector uri="tcp://localhost:61616"/>
</transportConnectors>
<networkConnectors>
<!-- by default just auto discover the other brokers -->
<networkConnector uri="multicast://default"/>
<!--
<networkConnector uri="static://(tcp://host1:61616,tcp://host2:61616)"/>
-->
</networkConnectors>
</broker>
</beans>

View File

@ -0,0 +1,35 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------
log4j.rootLogger=INFO, stdout
log4j.logger.org.apache.activemq.spring=WARN
log4j.logger.org.springframework=WARN
log4j.logger.org.apache.xbean.spring=WARN
# CONSOLE appender not used by default
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
# File appender
log4j.appender.out=org.apache.log4j.FileAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
log4j.appender.out.file=activemq-ra.log
log4j.appender.out.append=true