JMX - Accessing ServletContext in an MBean implementation

How do you access the ServletContext from a class that implements an MBean interface? My application stores logs in application scope (ServletContext) and I need to access those logs from my MBean implementation.
public class Stats implements StatsMBean {
// How do I access ServletContext here?
}Any ideas?

How aboutpublic class Stats implements StatsMBean {
  private ServletContext context;
  public Stats(ServletContext context) {
    this.context = context;
  // some methods that can now use the "context" variable.
}

Similar Messages

  • Spring / OC4J / JMX - Unauthorized access from application publishing mbean

    I get the following when my Spring app tries to publish mbeans to the OC4J MBeanServer.
    My app works fine in JBoss, i.e. JBoss doesn't throw a security exception.
    What file do I have to configure in OC4J for this to be allowed?
    java.lang.SecurityException: Unauthorized access from application: ice-crem to MBean: bean:name=portalConfig
         at oracle.oc4j.admin.jmx.shared.UserMBeanServer.checkRegisterAccess(UserMBeanServer.java:873)
         at oracle.oc4j.admin.jmx.shared.UserMBeanServer.registerMBean(UserMBeanServer.java:400)
         at oracle.oc4j.admin.jmx.server.state.LocalizationFilterMBeanServer.registerMBean(LocalizationFilterMBeanServer.java:341)

    It looks like you are trying to access MBeans in the bean: domain from an application called ice-crem.
    OC4J enforces a security proxy for MBeans. By default an application specific MBean
    can only access MBeans within the same application -- so the ice-crem application can only see MBeans in the ice-crem domain.
    If an application creates its own Custom MBeanServer, then the security proxy intercepto does not come into play since there are no OC4J System MBeans in it. Any application can access an applications Custom MBeanServer.
    What I found when using Spring with JMX was to configure it to use a Custom MBeanServer.
    <bean id="customMBeanServer"
    class="org.springframework.jmx.support.MBeanServerFactoryBean">
    <property name="defaultDomain" value="customMBeanServer"/>
    <property name="locateExistingServerIfPossible" value="false"/>
    <property name="registerWithFactory" value="true"/>
    </bean>
    and then put all the Spring exported MBeans in that.
    <bean id="exporter"
    class="org.springframework.jmx.export.MBeanExporter">
    <property name="beans">
    <map>
    <entry key="bean:name=bean1"
    value-ref="bean1"/>
    <entry key="bean:name=bean2"
    value-ref="bean2"/>
    </map>
    </property>
    <property name="server" ref="customMBeanServer"/>
    </bean>
    If you want to disable the JMX security proxy, so you can do what you are currently trying to do and what works in JBoss, then you nee dto start OC4J with this System property:
    java -Doc4j.jmx.security.proxy.off=true -jar oc4j.jarDoing that exposes the OC4J System MBeans to all deployed applications, so its not something you really want to run in production unless you then go and apply a Java2 policy style restriction on the oc4j:* mbeans.
    cheers
    -steve-

  • Getting an MBean implementation to self register

    Have a number for Jetty server/servlet combos each running in their own JVM that I want to register with a MBeanServer running in still another JVM. So I took client code to do this. The server class looks lik this:
    package com.sra.pipeline.servers.htmlexport;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import javax.management.InstanceAlreadyExistsException;
    import javax.management.MBeanException;
    import javax.management.MBeanRegistrationException;
    import javax.management.MBeanServerConnection;
    import javax.management.MalformedObjectNameException;
    import javax.management.NotCompliantMBeanException;
    import javax.management.ObjectName;
    import javax.management.ReflectionException;
    import javax.management.remote.JMXConnector;
    import javax.management.remote.JMXConnectorFactory;
    import javax.management.remote.JMXServiceURL;
    import org.jingle.jmxremote.client.MBeanServerImpl;
    import org.mortbay.jetty.Server;
    import org.mortbay.jetty.servlet.Context;
    import org.mortbay.jetty.servlet.ServletHolder;
    public class HtmlExportServer implements HtmlExportServerMBean {
         private static int port;
         private static Server server;
         private static String name = "HtmlExportServer";
         private static HtmlServlet servlet;
         public static void main(String[] args)
              throws Exception {
             registerBean();
             if(args.length == 1) {
                 port = Integer.parseInt(args[0]);
             }else {
                 port = 8090;
                        Server server = new Server(port);
                        Context context = new Context(server,"/",Context.SESSIONS);
                        servlet = new HtmlServlet();
                        context.addServlet(new ServletHolder(servlet), "/*");
                        server.start();
                        server.join();
         public String getName() {
             return name;
         public boolean haveConnection() {
             return (servlet.hasConnection());
         public boolean isRunning() {
             return (server != null);
         public static void registerBean() {
                        try {
                 JMXServiceURL url = new JMXServiceURL(
                     "service:jmx:rmi:///jndi/rmi://localhost:9999/server");
                 JMXConnector cs = JMXConnectorFactory.connect(url, null);            
                 MBeanServerConnection mbsc = cs.getMBeanServerConnection();           
                 ObjectName mbeanName = new ObjectName("com.sra.pipeline.servers:type=HtmlExportServer");
                 mbsc.createMBean("com.sra.pipeline.servers.HtmlExportServer",mbeanName);
                 //MBeanServerImpl mbsi = new MBeanServerImpl(mbsc);
                 //mbsi.registerMBean(new HtmlExportServer() , mbeanName);
             } catch (MalformedURLException e) {
                 e.printStackTrace();
             } catch (IOException e) {
                 e.printStackTrace();
             } catch (MalformedObjectNameException e) {
                 e.printStackTrace();
             } catch (NullPointerException e) {
                 e.printStackTrace();
             } catch (InstanceAlreadyExistsException e) {
                 e.printStackTrace();
             } catch (MBeanRegistrationException e) {
                 e.printStackTrace();
             } catch (NotCompliantMBeanException e) {
                 e.printStackTrace();
             } catch (ReflectionException e) {
                 e.printStackTrace();
             } catch (MBeanException e) {
                 e.printStackTrace();
    }When I used the createBean method of the MBeanServerConnection in the code above, I got
    javax.management.ReflectionException: The MBean class could not be loaded by the
    default loader repository
    this despite the fact that the MBean Interface and the implementing class are both in the classpath of the MBeanServer.
    When I used MBeanServerImpl.registerBean I get
    Exception in thread "main" javax.management.JMRuntimeException: javax.management
    .remote.JMXServerErrorException: java.lang.NoClassDefFoundError: org/jingle/util
    /dydelegation/DelegationInvocationHandler
    This class from jmxremote is also in the classpath.
    So what gives?
    Jim

    I think I am having classpath problems with this in general. I'm running this on windows with the following bat file
    set cPath=bin;lib/jetty-6.1.9.jar;lib/jetty-util-6.1.9.jar;lib/servlet-api-2.5-6.1.9.jar;lib/tools.jar;lib/tsapi.jar;lib/bcel-5.1.jar;lib/dunamis.jar;lib/jmxremote-all.jar
    java -cp %cPath%  com.sra.pipeline.servers.htmlexport.HtmlExport
    set cPath=My current error is no class definition found for javax.servlet.Servlet
    This file exists in jetty-6.1.9.jar
    Is this a problem with a polluted path, or what
    Any ideas would be appreciated.
    Jim

  • How to access ServletContext object of a webapp on remote server?

    Hi!
    I have a webapp, runs on tomcat, loads information from local db server, keeps them in servlet context, and publish these datas to web via jsp pages.
    I make run the same webapp on different location, different webserver and db server with different datas.
    Is it possible to link both ServletContext to each other, or access one from the another?
    What is the right solution, if I want to access all stored Objects of these independent webapplications, summarize and show them in one browser page, in one jsp?
    sorry for my poor english
    and thanks for any help,
    kind regards,
    henpanta

    It is not possible to access another servletcontext glueless using HTTP or any transfer protocol. Would be a potential security hole too. If you want to let communicate 2 webapps on different servers with each other, consider webservices.

  • Any way to access params passed in URL  implementing JSR 168 on Oracle Appl

    I'm trying to access the params passed through URL like : http://hostname:7777/portal/page/portal/Wes%20store%20Sample/OnlyOnePortal
    webStoreId=100&Id=10000
    I have create a portlet with jsp implementing JSR 168 on Oracle Application Server 10g
    But unable to access them in either actionProcess() as well as render() using actionRequest and renderRequest as well.
    I wonder will this possible with JSR 168 to access params passed in URL in any way
    Can any body help me do this

    access params passed in URL  implementing JSR 168 on Oracle Application Ser

  • Accessing ServletContext from Java class Data Control

    I'm writing some business service classes as plain old java classes that will be bound to a JSP using ADF and STRUTS. The business logic requires the real path of the servlet context to access a file. How do I call servletContext.getRealPath("/WEB-INF/test.xml")?
    I know this is mixing web tier code into model code, but I don't know any other way to do this.
    Thanks in advance...

    Ok, it looks like I'll have to define my own action class and pass the pathname on to the data control class.

  • How to access "Active Sessions" using MBeans

    Hi all,
    I have deployed an application at EM (Enterprise Manager).
    when I logged into EM and click the application I can see the number of active sessions under "Servlets and JSPs" topic.
    how can I access that parameter at application level..??
    (I want to access that parameter *"x"* at my web application and display Logged in users : x )
    EM shows that the number of active sessions. it updates too.. so there must be some bean or record for that parameter..
    how can I access that....??
    Regards,
    Dinuka.

    You can use something like the following:
    package middleware.magic;
    import javax.management.MBeanServerConnection;
    import javax.management.ObjectName;
    import javax.management.remote.JMXConnector;
    import javax.management.remote.JMXConnectorFactory;
    import javax.management.remote.JMXServiceURL;
    import javax.naming.Context;
    import java.io.IOException;
    import java.util.Hashtable;
    public class Browse {
        private String hostname = "172.31.0.106";
        private Integer port = 7001;
        private String username = "weblogic";
        private String password = "transfer11g";
        private String protocol = "t3";
        private String jndiRoot = "/jndi/";
        private String mBeanServer = "weblogic.management.mbeanservers.domainruntime";
        private String serviceName = "com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean";
        private JMXConnector connector;
        public static void main(String[] args) {
            Browse test = new Browse();
            try {
                MBeanServerConnection connection = test.getMBeanServerConnection();
                test.getSomeInformation(connection);
                test.closeJmxConnector();
            } catch (Exception e) {
                e.printStackTrace();
        public void getSomeInformation(MBeanServerConnection connection) throws Exception {
            ObjectName service = new ObjectName(serviceName);
            ObjectName[] serverRunTimes = (ObjectName[]) connection.getAttribute(service, "ServerRuntimes");
            for (int i = 0; i < serverRunTimes.length; i++) {
                String name = (String) connection.getAttribute(serverRunTimes, "Name");
    String version = (String) connection.getAttribute(serverRunTimes[i], "WeblogicVersion");
    String state = (String) connection.getAttribute(serverRunTimes[i], "State");
    System.out.println("Server name: " + name + ", Version: " + version + ", Server state: " + state);
    for (int i = 0; i < serverRunTimes.length; i++) {
    ObjectName[] applicationRuntimes = (ObjectName[]) connection.getAttribute(serverRunTimes[i], "ApplicationRuntimes");
    for (int j = 0; j < applicationRuntimes.length; j++) {
    String name = (String) connection.getAttribute(applicationRuntimes[j], "Name");
    ObjectName[] componentRuntimes = (ObjectName[]) connection.getAttribute(applicationRuntimes[j], "ComponentRuntimes");
    System.out.println("Application name: " + name);
    for (int k = 0; k < componentRuntimes.length; k++) {
    if (connection.getAttribute(componentRuntimes[k], "Type").equals("WebAppComponentRuntime")) {
    String componentName = (String) connection.getAttribute(componentRuntimes[k], "Name");
    Integer sessionsCurrent = (Integer) connection.getAttribute(componentRuntimes[k], "OpenSessionsCurrentCount");
    Integer sessionsHigh = (Integer) connection.getAttribute(componentRuntimes[k], "OpenSessionsHighCount");
    System.out.println(" - Component Name: " + componentName + ", Sessions Current: " + sessionsCurrent + ", Sessions High: " + sessionsHigh);
    public MBeanServerConnection getMBeanServerConnection() throws IOException {
    return getJmxConnector().getMBeanServerConnection();
    public JMXConnector getJmxConnector() throws IOException {
    JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port, jndiRoot + mBeanServer);
    Hashtable hashtable = new Hashtable();
    hashtable.put(Context.SECURITY_PRINCIPAL, username);
    hashtable.put(Context.SECURITY_CREDENTIALS, password);
    hashtable.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");
    connector = JMXConnectorFactory.connect(serviceURL, hashtable);
    return connector;
    public void closeJmxConnector() throws IOException {
    connector.close();
    Information regarding runtimeMBean can be found here: http://download.oracle.com/docs/cd/E12839_01/apirefs.1111/e13951/core/index.html.
    Open the tree Runtime MBeans, ServerRuntimeMBean and click attributes to see the available attributes (such as Name, WeblogicVersion, State etcetera).
    An example output of the program above:Server name: AdminServer, Version: WebLogic Server 10.3.2.0 Tue Oct 20 12:16:15 PDT 2009 1267925 , Server state: RUNNING
    Server name: soa_server1, Version: WebLogic Server 10.3.2.0 Tue Oct 20 12:16:15 PDT 2009 1267925 , Server state: RUNNING
    Application name: FMW Welcome Page Application_11.1.0.0.0
    - Component Name: AdminServer__11.1.0.0.0, Sessions Current: 0, Sessions High: 0
    Application name: Module-FMWDFW
    Application name: bea_wls_internal
    - Component Name: AdminServer_/bea_wls_internal, Sessions Current: 0, Sessions High: 0
    Application name: mds-soa
    Application name: bea_wls_deployment_internal
    - Component Name: AdminServer_/bea_wls_deployment_internal, Sessions Current: 0, Sessions High: 0
    Application name: wsil-wls
    - Component Name: AdminServer_/inspection.wsil, Sessions Current: 0, Sessions High: 0
    Application name: bea_wls_diagnostics
    - Component Name: AdminServer_/bea_wls_diagnostics, Sessions Current: 0, Sessions High: 0
    Application name: mejb
    Application name: bea_wls9_async_response
    - Component Name: AdminServer_/_async, Sessions Current: 0, Sessions High: 0
    Application name: uddiexplorer
    - Component Name: AdminServer_/uddiexplorer, Sessions Current: 0, Sessions High: 0
    Application name: mds-owsm
    Application name: bea_wls_management_internal2
    - Component Name: AdminServer_/bea_wls_management_internal2, Sessions Current: 0, Sessions High: 0
    Application name: consoleapp
    - Component Name: AdminServer_/console, Sessions Current: 0, Sessions High: 2
    - Component Name: AdminServer_/consolehelp, Sessions Current: 0, Sessions High: 1
    Application name: DMS Application_11.1.1.1.0
    - Component Name: AdminServer_/dms_11.1.1.1.0, Sessions Current: 0, Sessions High: 0
    Application name: em
    - Component Name: AdminServer_/em, Sessions Current: 0, Sessions High: 0
    Application name: uddi
    - Component Name: AdminServer_/uddi, Sessions Current: 0, Sessions High: 0
    Application name: MQSeriesAdapter
    Application name: OraSDPMDataSource
    Application name: JmsAdapter
    Application name: uddi
    - Component Name: soa_server1_/uddi, Sessions Current: 0, Sessions High: 0
    Application name: wsil-wls
    - Component Name: soa_server1_/inspection.wsil, Sessions Current: 0, Sessions High: 0
    Application name: SOAJMSModule
    Application name: DbAdapter
    Application name: bea_wls9_async_response
    - Component Name: soa_server1_/_async, Sessions Current: 0, Sessions High: 0
    Application name: composer
    - Component Name: soa_server1_/soa/composer, Sessions Current: 0, Sessions High: 0
    Application name: DMS Application_11.1.1.1.0
    - Component Name: soa_server1_/dms_11.1.1.1.0, Sessions Current: 0, Sessions High: 0
    Application name: Module-FMWDFW
    Application name: usermessagingdriver-email
    - Component Name: soa_server1_/sdpmessagingdriver/email-mbeanlifecycle, Sessions Current: 0, Sessions High: 0
    Application name: UMSJMSSystemResource
    Application name: AqAdapter
    Application name: FtpAdapter
    Application name: OracleBamAdapter
    Application name: SOADataSource
    Application name: usermessagingserver
    - Component Name: soa_server1_/sdpmessaging/mbeanlifecycle, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/sdpmessaging/parlayx, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/sdpmessaging/userprefs-ui, Sessions Current: 0, Sessions High: 0
    Application name: bea_wls_internal
    - Component Name: soa_server1_/bea_wls_internal, Sessions Current: 0, Sessions High: 0
    Application name: SocketAdapter
    Application name: SOALocalTxDataSource
    Application name: FileAdapter
    Application name: DefaultToDoTaskFlow
    - Component Name: soa_server1_/DefaultToDoTaskFlow, Sessions Current: 0, Sessions High: 0
    Application name: soa-infra
    - Component Name: soa_server1_/soa-infra, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/TaskService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/TaskMetadataService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/TaskQueryService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/TaskReportService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/IdentityService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/UserMetadataService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/RuntimeConfigService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/TaskEvidenceService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/CompositeMetadataService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/b2b, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/b2b, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/AGMetadataService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/AGQueryService, Sessions Current: 0, Sessions High: 0
    - Component Name: soa_server1_/integration/services/AGAdminService, Sessions Current: 0, Sessions High: 0
    Application name: wsm-pm
    - Component Name: soa_server1_/wsm-pm, Sessions Current: 0, Sessions High: 0
    Application name: mds-owsm
    Application name: b2bui
    - Component Name: soa_server1_/b2bconsole, Sessions Current: 0, Sessions High: 0
    Application name: bea_wls_diagnostics
    - Component Name: soa_server1_/bea_wls_diagnostics, Sessions Current: 0, Sessions High: 0
    Application name: bea_wls_cluster_internal
    - Component Name: soa_server1_/bea_wls_cluster_internal, Sessions Current: 0, Sessions High: 0
    Application name: EDNLocalTxDataSource
    Application name: EDNDataSource
    Application name: uddiexplorer
    - Component Name: soa_server1_/uddiexplorer, Sessions Current: 0, Sessions High: 0
    Application name: bea_wls_deployment_internal
    - Component Name: soa_server1_/bea_wls_deployment_internal, Sessions Current: 0, Sessions High: 0
    Application name: worklistapp
    - Component Name: soa_server1_/integration/worklistapp, Sessions Current: 0, Sessions High: 0
    Application name: mds-soa
    Application name: OracleAppsAdapter

  • Using Flash Access Pro 3.0 ref-implementation tools?

    I'm  adding DRM support for Flash Access to my company's products. I've just installed a Flash Access Pro 3.0 server with a 90-day Trial license issued 2012.07.26, using the "quick-start guide". The verification step (browsing to http://localhost:8080/flashaccessserver/flashaccess/license/v2) reports "License Server is setup correctly".
    I've added the license (.pfx) file path and password to 'Reference Implementation/Command Line Tools/samples/com/adobe/flashaccess/samples/licensegen/GenerateLicense.java', and compiled using "ant -f ./build-samples.xml build", then ran the app as shown below. I've double-checked that the password matches the license file using "using "openssl pkcs12 -info -in my_certificate.pfx". I also tried using the scrambled password, but that issues the error "Unable to load credential from my_certificate.pfx -- possibly wrong password", which seems to indicate that it's successfully using the plaintext password.
    Has anyone used GenerateLicense successfully? And if, so, with a Trial license, or a regular license?
    What does "Flash Access Professional License server certificate required" mean? Does it means the server is actually not running correctly? Or is there another problem?
    Thanks for any help on this issue ...
    > ant -f build-samples.xml generate-license  Buildfile: C:\cygwin\home\dougs\flash_access_pro_3\Reference Implementation\Command Line Tools\samples\build-samples.xml generate-license:
          [java] Exception in thread "main" java.lang.IllegalArgumentException: Flash Access Professional License server certificate required
          [java]     at com.adobe.flashaccess.core.license.pregen.LicenseFactoryImpl.<init>(LicenseFactoryImpl.java:100)
          [java]     at com.adobe.flashaccess.sdk.license.pregen.LicenseFactory.getInstance(LicenseFactory.java:61)
          [java]     at com.adobe.flashaccess.samples.licensegen.GenerateLicense.main(GenerateLicense.java:71)
          [java] Java Result: 1
    BUILD SUCCESSFUL Total time: 1 second

    I don't know about other things using FileMaker files but if you do use many scripts, I bet that won't be easy…
    However, if you can find one somewhere like e-Bay, FMP 5 can read 3 files, works perfectly in Classic and includes installers for 9, X and even Windows on the same disk.
    If it matters, I seem to remember the reason my FMP files are now stuck with single-user access instead on networking is that networking late X with Windows requires FMP 6… and presumably, that doesn't much matter.

  • Unmarshal Exception while accessing operations in the MBeans

    Hi,
    I am using jconsole to monitor my application.Here my MBeane shows "Attribute" and "Operation" nodes .When i access the operation .It throws an exception like "java.rmi.unmarshalException:error unmarshalling return;" .Please help me to solve this problem.

    Hi,
    Yes.you are correct.I am using Jconsole to monitor Hibernate.Instead of using RMI.Can i use some other way to connect with JConsole.
    i read some other forum comments . i.e)
    1) If you use JDK 6, you could deploy MXBeans instead of deploying MBeans
    see http://blogs.sun.com/roller/page/jmxetc?entry=writing_mxbeans_is_now_a
    2) You can also start jconsole so that it finds your application classes in its
    classpath. In that case you will need to start jconsole with the following
    flag:
    jconsole -J-Djava.class.path=<jconsole.jar>:<tools.jar>:<my-custom-classes.jar>
    3) You could possibly use RMI annotations but:
    1) you will have to run both client and server with a security manager and
    the appropriate flag to turn on RMI codebase annotations
    2) you will have to make your <my-custom-classes.jar> downloadable
    at the appropriate location.
    see http://java.sun.com/j2se/1.5.0/docs/guide/rmi/codebase.html
    for more info.
    I tried first #1 and #2. It doesn't work for webapplication.Because Custom jar should be main method otherwise #2 command doesn't work.
    is there any otherway communication between jconsole and server.please reply soon

  • Accessing Work Managers Using MBeans forum

    hi all,
    I am trying to write code using JMX that gives me all work manager that I've created on WLS 9.0 but when trying to retrieve it using getMBeansByType() shows me MBean size as zero and with getRuntimeMBean() it shows me instance not found in short it doesn't return MBeans so i am not able to get name of workmanager.
    Intially problem seems with workmanager configuration but i am sure i have configured properly
    waitting for your reply
    thanx
    Nihil

    Nevermind... It works but not with the old Jive SBS app. There is a newer one called Jive Mobile.

  • Access current node in XPathFunction implementation

    Hello,
    When implementing an XPathFunction, is there a way to access current node?
    For example,
    "//*[local-name()='test123']"
    in the above example, the built-in function, local-name, take current node as its argument.
    However, from the API of XPathFunction:
    public Object evaluate(List args) throws XPathFunctionException
    It is not apparent how to access the current node.
    I've tried:
    "//*[myFunction()=1]"
    the input arg length is zero.
    Looking forward to any suggestions!
    Thanks!

    Thanks for the reply.
    Allow me to further clarify my problem with the following example:
    //*[local-name()='foo']/*[local-name()='bar']As shown in the above example, in the second call to the "local-name" function, the implementation
    of the function should unavoidably require the reference of currently navigated xml node (a "foo" node in
    the above example).
    However, it does not seem obvious how to achieve the same functionality with XPathFunction interface.
    So, what is the proper strategy if we want to implement our customized local-name-like functions?
    Thanks!
    Looking forward to suggestions.

  • JMX jconsole -- where is my MBean?

    I'm missing something here in 5.0b2's JMX. I've put together a rudimentary standard MBean together, and want to view the data from jconsole (on the MBeans tab). Here's the code I used below to register the MBean.
    String domain = "UserDomain";
    String mbeanClassName = "iccs.support.utilities.corba.ConnectionManagementInfo";
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    ObjectName mbeanObjectName = new ObjectName(domain + ":type=" + mbeanClassName);
    mbs.createMBean(mbeanClassName, mbeanObjectName);
    This compiles and runs without error. I can connect to the process with jconsole successfully, but nothing shows up on the tab. I'm finding little documentation to help me out with this very simple case. Am I missing something?

    It seems your MBean server has no RMI connector or protocol adaptor attached.
    If you don't want the trouble to create an RMI connector use the JVM platform MBean server:
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

  • Can a bean access ServletContext?

    Hi!
    Please help me!
    I put initial beans to ServletContext in my servlets init() method.
    How can I get this beans (app scope) from another bean (session scope)?
    Can I reach ServletContext from a class that is not a servlet?
    Thaks!

    Please help me!
    I put initial beans to ServletContext in my servlets
    init() method.
    How can I get this beans (app scope) from another bean
    (session scope)?
    Can I reach ServletContext from a class that is not a
    servlet?Not in a normal JavaBean. You can do it with custom tags, but I guess that is not what you want.
    What you would have to do is create a setter method for the Bean:
    //This is part of the bean in session that requires access to one in servlet context
    public class SessionBeanClass ...
      private ServletBeanClass otherBean;
      public void setOtherBean(ServletBeanClass sbc) { otherBean = sbc; }
      public void getSomethingThatReliesOnOtherBean()
        if (otherBean == null) throw IllegalStateException("This Something can not be done until an object of type ServletBeanClass is assigned.");
        // rest of method
    }Then in the servlet you would need to assign the correct value, preferrably when the bean is first created.
    // somewhere in your servlet
        SessionBeanClass sessionBean = new SessionBeanClass();
        sessionBean.setOtherBean((ServletBeanClass)getServletContext().getAttribute("otherBean"));Or if you are using a JSP:
    <jsp:useBean id="sessionBean" class="my.package.SessionBeanClass" scope="session">
      <jsp:setProperty name="sessionBean" property="otherBean" value="${servletContext.otherBean}"/>
    </jsp:useBean>

  • Can beans access ServletContext?

    I want to use my web deployment descriptor (web.xml) to store database connection parameters. Unfortunately, the only way that I know how to access the ServletContext is through the request.getServletContext() method. Since my bean classes don't have a handle on the request object, how can I access the ServletContext to get this information?
    Any good practice advice from anyone?

    Right but I have a bean that I want to have access the servletcontext. From the bean class itself. (not the setProperty tag in JSP).

  • Accessing ServletContext from non-servlet class

    How i can get information servletcontext from a normal java class?
    I am using Tomcat.
    I have put some Strings in to the servlet context and i want to get this information from a normal java class.
    I think there was a way to do it with getServlet() but this is deprecated.

    One way to do this would be to store the info in some class of your own as a static member(arraylist/hashmap or something) and then retrieve it from your java class.
    May you can populate static field i the init() method of one of your servlet and have that servlet load on tomcat startup.

Maybe you are looking for