If you are using the CXF-Servlet to load the Application, CXF just
create a XmlWebApplicationContext based on the location parameter.
If you are using spring ContextLoaderListener, it will application
configuration files according the ContextLoader. Can you check if your
war has some other application configuration files.
On 7/8/11 6:41 AM, Sonam Nepali wrote:
Hi,
I have noticed that when loading beans in a webapp, on WebLogic, by passing a init-parameter in the
CXF-Servlet configuration (see "Sample 2" below), I am able to load my spring beans
perfectly well. But if I pass the bean configuration to a Spring ContextLoaderListener as in
"Sample 3" below, I get Weblogic security exceptions. I know this maybe irrelevant on a
CXF forum but I thought it was interesting enough that I share to see if I could hear some
feedbacks.
I am creating a DefaultMessageListener that connects to a remote Topic with a
connectionFactory configuration and waits for messages. Loadings beans via
ContextLoaderListener vs CXFServlet apparently has some different behaviors.
The following is my bean configuration:
Sample 1:
<bean id="helloWorld" class="x.y.HelloWorld"/>
<context:property-placeholder location="classpath:MyProps.properties" />
<bean id="jmsContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="myTopicConnectionFactory"
/>
<property name="destination" ref="myTopic" />
<property name="messageListener" ref="helloWorld" />
<property name="messageSelector" value="${myMessageSelector}"/>
</bean>
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<map>
<entry key="java.naming.factory.initial"
value="${myJavaNamingFactoryInitial}" />
<entry key="java.naming.provider.url"
value="t3://foresight-test.co.ihc.com:9002" />
<entry key="java.naming.security.principal" value=""/>
<entry key="java.naming.security.credentials" value=""/>
</map>
</property>
</bean>
<bean id="foreSightTopicConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName">
<value>${myJMSConnectionFactoryJndiName}</value>
</property>
</bean>
<bean id="myTopic" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName">
<value>${myJMSTopicJndiName}</value>
</property>
</bean>
Sample 2:
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<init-param>
<param-name>config-location</param-name>
<param-value>WEB-INF/beans.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
Sample 3:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/beans.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<display-name>CXF Servlet</display-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
Sample 3: Stacktrace
2011-07-07 16:28:15,654 [[STANDBY] ExecuteThread: '4' for queue:
'weblogic.kernel.Default (self-tuning)'] INFO
org.springframework.context.support.DefaultLifecycleProcessor - Starting beans
in phase 2147483647
2011-07-07 16:28:15,654 [[STANDBY] ExecuteThread: '4' for queue:
'weblogic.kernel.Default (self-tuning)'] DEBUG
org.springframework.context.support.DefaultLifecycleProcessor - Starting bean
'jmsContainer' of type [class
org.springframework.jms.listener.DefaultMessageListenerContainer]
2011-07-07 16:28:15,670 [[STANDBY] ExecuteThread: '4' for queue:
'weblogic.kernel.Default (self-tuning)'] DEBUG
org.springframework.jms.listener.DefaultMessageListenerContainer - Could not
establish shared JMS Connection - leaving it up to asynchronous invokers to
establish a Connection as soon as possible
java.lang.SecurityException: [Security:090398]Invalid Subject:
principals=[weblogic, Administrators]
thanks
-Sonam
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang