Hi,

Jay SenSharma

Jay SenSharma

Here is a Simple demonstration to Enable Spring Console Extension to Monitor the Spring Bean Details in AdminConsole.  For more details please refer to : http://download.oracle.com/docs/cd/E12840_01/wls/docs103/programming/spring.html#wp1081223

Step1). Create a Directory somewhere sothat we can develope a Simple Spring Application inorder to achieve this:

Example: C:PostOnSpring

Step2). Open a Command Window  and run “. ./setWLSEnv.sh”

Step3). Use the following command to deploy the “weblogic-spring.jar” file as a Library (Optional Package) in the targeted Server where we are intended to deploy our Spring Applications.

For details of  Optional Package TestCase/Demo —>please refer to : Optional Packages In WebLogic

C:PostOnSpring>java weblogic.Deployer -library -deploy -source C:bea103wlserver_10.3serverlibweblogic-spring.jar -targets AdminServer -adminurl t3://localhost:7001 -user weblogic -password weblogic

Step4). Login to Admin Console —>Home—>Preferences (Link top of the page)—> Extensions (TAB)—>     spring-console (Check)

and then click on the “Enable” Button

Step5). Restart your Server in order to take the Changes Affect.

================Developing Spring Application Part================

Step6). Create a Spring WebApplication directory with name “SpringBeanReference” inside “C:PostOnSpring”.

Step7). Create “index.jsp” page inside “C:PostOnSpringSpringBeanReference”.

Step8). Create “META-INF” and “WEB-INF” Directories inside “C:PostOnSpring”

Step9). Inside “META-INF” directory provide the “MANIFEST.MF” file with the following informations…to make sure that the Application gets linked to the Optional Package which we have deployed on step 2)

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

NOTE: Make Sure that there is no extra spaces in the Above  4 lines either at the beginning or at the end of each lines.

Step10). Create a “lib” directory inside “C:PostOnSpringSpringBeanReferenceWEB-INF” and place the following 3-Jar files there:

spring.jar
wlcommons-logging.jar
commons-logging.jar

Step11). Create “classes” Directory inside “C:PostOnSpringSpringBeanReferenceWEB-INF” and provide the following 1-Interface and 1-Implementation Class there like following:

“HelloService.java”

package pack;
public interface HelloService {
public String sayHello(Name name);
}

and
“HelloService_Impl”

package pack;
public class HelloService_Impl implements HelloService {
    public HelloService_Impl()
      {
        System.out.println("ntHelloService_Impl() object Created...");
       }

    public String sayHello(Name name)
       {
         System.out.println("ntsayHello() of HelloService_Impl called");
         return "**** Hello  " + name.getFirstName() + " " + name.getLastName();
        }
}

Step12). CCompile above two classes there:

C:PostOnSpringSpringBeanReferenceWEB-INFclasses> javac -d . HelloService.java
C:PostOnSpringSpringBeanReferenceWEB-INFclasses> javac -d . HelloService_Impl.java

Step13). Provide a Simple Servlet just to see beans are accessible on not inside “C:PostOnSpringSpringBeanReferenceWEB-INFclasses” provide the “MyServlet.java.java”

package servlets;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.*;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import pack.Name;
public class MyServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
PrintWriter out=res.getWriter();
ServletContext servletContext =this.getServletContext();
WebApplicationContext springContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
// Call your HelloBean here
}
}

Step14).  Provide the follwing “applicationContext.xml” … inside “C:PostOnSpringSpringBeanReferenceWEB-INF” directory

Step15).Please provide the “web.xml” file ..inside “C:PostOnSpringSpringBeanReferenceWEB-INF” like following;

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Spring_ReferenceBean</display-name>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>servlets.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>MyServlet</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>

Step16). Provide the “commons-logging.properties” file inside “C:PostOnSpringSpringBeanReferenceWEB-INFclasses” with the following Line of code inside it:

org.apache.commons.logging.LogFactory = weblogic.logging.commons.LogFactoryImpl

Step17).Deploy the Application and then Login to the AdminConsole…..

Deployments—> Deployment Summary—> SpringBeanReference —->Configuration (Tab)—>Spring Framework (SubTab)

.
.
Thanks
Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.