0 Replies Latest reply on Jun 25, 2008 11:31 PM by 666705

    weblogic.application.ApplicationException cannot be resolved error

    666705
      Hi,

      I am new to Weblogic Server. I am creating a web application in which I have created a custom MBean. Right now, I am coding the class which extends 'ApplicationLifecycleListener' in order to register the custom MBean automatically when the app is started. I am getting the following error (a red mark appears at the very top of the class, before anything else):

      “The type weblogic.application.ApplicationException cannot be resolved. It is indirectly referenced from required .class files”

      I am using WL server 10.0. When I looked at the API for 'ApplicationLifecycleListener' for WLS 10.0, the methods do not throw this exception, although the 9.0 API does. see here:
      [url http://edocs.bea.com/wls/docs100/javadocs/weblogic/application/ApplicationLifecycleListener.html]

      this is my listener class
      package Files;

      import javax.management.MBeanServer;
      import javax.management.MalformedObjectNameException;
      import javax.management.ObjectName;
      import javax.naming.InitialContext;
      import weblogic.application.*;
      import weblogic.application.ApplicationContext;
      import weblogic.application.ApplicationLifecycleEvent;
      import weblogic.application.ApplicationLifecycleListener;

      public class AppLifeCycleListenerImp extends ApplicationLifecycleListener  {
           
           private MBeanServer server;
           
           public void postStart(ApplicationLifecycleEvent evt){
                
                try{     
                     ApplicationContext appctx = evt.getApplicationContext();
                     String appID = appctx.getApplicationId();                              
                     ObjectName name = new ObjectName("RIM.SVandV:Name="+appID+",Type=customObjectMBean");
                                    
                     InitialContext ctx = new InitialContext();
                     //Listener running within J2EE module =>the JNDI name for the Runtime MBeanServer is: java:comp/env/jmx/runtime
                     server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime");
                                    
                     CustomObject mbean = new CustomObject(); 
                     mbean.setInteger1(12);mbean.setInteger2(22);
                     mbean.setString1("hello12");mbean.setString2("hello22");
                     
                     server.registerMBean(mbean, name);
                }catch (Exception e){
                     e.printStackTrace();
                }
                
           }
                
           public void preStop(ApplicationLifecycleEvent evt){
                     
                try{          
                     ApplicationContext appctx = evt.getApplicationContext();
                     String appID = appctx.getApplicationId();                              
                     ObjectName name = new ObjectName("RIM.SVandV:Name="+appID+",Type=customObjectMBean");
                     
                     server.unregisterMBean(name);
                }catch (Exception e){
                     e.printStackTrace();
                }
           }
      }
      This is my MBean class
      package Files;

      public interface CustomObjectMBean {
           
           public int getInteger1();     
           public int getInteger2();     
           public String getString1();     
           public String getString2();
      }
      and this is the MBean implementing class
      package Files;

      public class CustomObject implements CustomObjectMBean{
           
           private int integer1;
           private int integer2;
           private String string1;
           private String string2;
                
           public int getInteger1(){
                return integer1;
           }     
           public int getInteger2(){
                return integer2;
           }     
           
           public String getString1(){
                return string1;          
           }     
           public String getString2(){
                return string2;
           }
           
           public void setInteger1(int integer1){
                this.integer1 = integer1;
           }     
           public void setInteger2(int integer2){
                this.integer2=integer2;
           }     
                public void setString1(String string1){
                this.string1=string1;          
           }     
           public void setString2(String string2){
                this.string2=string2;
           }
           
      }
      any help would be great. thank you.