The Spring console extension is based on RuntimeMBeans registered using the WebLogic Server infrastructure; therefore, it provides a cluster view of the Spring applications and more management functionality for Spring Beans. It creates a Spring tab parallel to the Web or EJB applications, and it allows user to view the configuration information of the Spring bean on the WebLogic Administration Console.

To use the Spring console extension, we must turn on support for Spring beans and enable the Spring console extension. To enable the Spring console extension in the Administration Console, perform the following steps:

  • In the banner toolbar region at the top of the Console, click Preferences.
  • On the Preferences page, click Extensions.
  • Select the check box next to spring-console, then click Enable.
  • Restart the server, the change to take effect.

Next, deploy the weblogic-spring.jar (located in the ${WL_HOME}/server/lib directory) as a JavaEE optional package. To deploy the optional package using the Administration Console the steps that are described here can be used.

To be able to use the Spring console extension, we must have a Web component as part of our application. We take the application introduced in the post Spring and Hibernate4 as the basis and extend this application with a Web module. Edit the web.xml deployment descriptor such that a Spring Context is created

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring-config.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

To generate runtime MBeans for the application, the WeblogicSpringApplicationListener from weblogic-spring.jar must be added as a listener to the root Spring context:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
    <bean class="weblogic.spring.monitoring.WeblogicSpringApplicationListener"/>
    <bean id="company" class="model.logic.CompanyBean">
        <property name="sessionFactory" ref="sessionfactory"/>
        <property name="jmsTemplate" ref="jmstemplate"/>
    </bean>
    <!-- Hibernate Config -->
    <bean id="sessionfactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="datasource"/>
        <property name="jtaTransactionManager" ref="transactionManager"/>
        <property name="mappingResources">
            <list>
                <value>model/entities/person.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop>
                <prop key="hibernate.listeners.envers.autoRegister">${hibernate.listeners.envers.autoRegister}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            </props>
        </property>
    </bean>
    <!-- Transaction Config -->
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
    <tx:annotation-driven transaction-manager="transactionManager"/>
    <!-- Resource Config -->
    <jee:jndi-lookup id="datasource" jndi-name="jdbc/exampleDS" resource-ref="false"/>
    <jee:jndi-lookup id="connectionfactory" jndi-name="jms/ConnectionFactory" resource-ref="false"/>
    <jee:jndi-lookup id="destination" jndi-name="jms/CompanyQueue" resource-ref="false"/>
    <!-- JMS Config -->
    <bean id="jmstemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="connectionfactory"/>
        <property name="defaultDestination" ref="destination"/>
    </bean>
    <bean class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="connectionFactory" ref="connectionfactory"/>
        <property name="destination" ref="destination"/>
        <property name="transactionManager" ref="transactionManager"/>
        <property name="messageListener" ref="companymdp"/>
    </bean>
    <bean id="companymdp" class="model.logic.CompanyMDP"/>
    <!-- Extra -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:spring.properties</value>
            </list>
        </property>
    </bean>
</beans>

Finally, add (or change) the MANIFEST.MF (located in the META-INF directory) and make sure the following lines are included:

Extension-List: WeblogicSpring
WeblogicSpring-Extension-Name: weblogic-spring
WeblogicSpring-Specification-Version: 12.1.1.0
WeblogicSpring-Implementation-Version: 12.1.1.0

For the version and extension name to use, check the MANIFEST.MF included in the weblogic-spring.jar, in our case it contained the following:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: R28.2.0-79-146777-1.6.0_29-20111005-1808-windows-ia32 (Oracle Corporation)
Extension-Name: weblogic-spring
Implementation-Vendor: BEA Systems
Implementation-Title: WebLogic Server 12.1  Wed Dec 7 08:40:57 PST 2011 1445491
Implementation-Version: 12.1.1.0
Specification-Vendor: BEA Systems
Specification-Title: WebLogic Server
Specification-Version: 12.1.1.0

Deploy the application. By clicking on the deployment Spring Framework, Configuration tab, we obtain the following information

Issue some requests to the testservlet and click Spring Framework, Monitoring tab. Here, we can obtain the following information

References

[1] Spring Console Extension in WebLogic Server.
[2] Spring 2.5.x and WebLogic Server 10.3 Integration.