[Beginners Corner] - invoker.stopDelivery(); - could not stop Mbean for MDB 1st t
by shankha
Hi,
I am able to control my deployed MDB programatically.
Basically my code invoke the responsible MBean for that MDB and call the invoker.stopDelivery() method on that MBean.
It will restrict the MDB to get the message from Queue.
I can also withdrow the restriction of the MDB to get message from queue by invoking invoker.startDelivery(); on the MBean.
responsible MBean is
MBean Name: Domain Name: jboss.j2ee
| service: EJB
| plugin: invoker
| binding: message-driven-bean
| jndiName: MessageEJB
| MBean Java Class: org.jboss.ejb.plugins.jms.JMSContainerInvoker
--------
But the problem is after invoking invoker.stopDelivery() ,still the MDB reads the 1st queue message.
That is If I send 4 message after stop It will read the 1st one - other 3 messages are blocked unless I invoke startDelivery();
If I send 7 messages - MDB consume 1 st one :( other 6 are blocked .
then when I invoke startDelivery(); I will get the 6 messages with MDB.
Can any body help me -???
Stop delivery Code
package com.test;
|
| import org.jboss.logging.Logger;
| import org.jboss.mx.util.MBeanServerLocator;
| import org.jboss.mx.util.MBeanProxy;
| import org.jboss.ejb.plugins.jms.JMSContainerInvokerMBean;
|
| import javax.ejb.SessionBean;
| import javax.ejb.CreateException;
| import javax.ejb.SessionContext;
| import javax.ejb.EJBException;
| import javax.management.MBeanServer;
| import javax.management.ObjectName;
| import javax.management.MalformedObjectNameException;
| import javax.management.MBeanInfo;
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
|
| /**
| * Created by IntelliJ IDEA.
| * User: 151054
| * Date: Aug 30, 2007
| * Time: 2:29:30 PM
| * To change this template use File | Settings | File Templates.
| */
|
| public class MBeanTestBean implements SessionBean {
|
| //private static Logger log;
| private SessionContext mContext;
| private MBeanServer mbeanServer;
| private ObjectName mManagementService;
|
| private Context jndiCtx=null;
| private JMSContainerInvokerMBean invoker = null;
|
|
| public MBeanTestBean() {
| }
|
| public void ejbCreate() throws CreateException {
|
| if(mbeanServer == null)
| try {
| jndiCtx = new InitialContext();
| String serverName = (String)jndiCtx.lookup("java:comp/env/Server-Name");
| serverName = serverName.trim();
| if(serverName == null || serverName.length() == 0 || serverName.equals("null")) {
| try {
| mbeanServer = MBeanServerLocator.locateJBoss();
| System.out.println("@@@ --------- mbeanServer = "+mbeanServer.getDefaultDomain());
| System.out.println("@@@ --------- mbeanServer No of MBean = "+mbeanServer.getMBeanCount());
|
| }
| catch(IllegalStateException e) {
| throw new CreateException("No local JMX MBeanServer available");
| }
| } else {
| Object lServer = jndiCtx.lookup(serverName);
| if(lServer != null) {
| if(lServer instanceof MBeanServer)
| mbeanServer = (MBeanServer)lServer;
| else
| throw new CreateException("Server: " + lServer + " reference by Server-Name: " + serverName + " is not of type MBeanServer");
| } else {
| throw new CreateException("Server-Name " + serverName + " does not reference an Object in JNDI");
| }
| }
| }
| catch(NamingException ne) {
| throw new EJBException(ne);
| }
| }
|
| public void setSessionContext(SessionContext sessionContext) throws EJBException {
| }
|
| public void ejbRemove() throws EJBException {
| }
|
| public void ejbActivate() throws EJBException {
| }
|
| public void ejbPassivate() throws EJBException {
| }
|
| public void invokeMBeanFeatures(){
|
| try{
|
| //Object name = jndiCtx.lookup("MessageEJB");
|
| ObjectName objName = new ObjectName("jboss.j2ee:service=EJB,plugin=invoker,binding=message-driven-bean,jndiName=MessageEJB");
| //ObjectName objName = new ObjectName((String)name);
| MBeanInfo objMBeanInfo = mbeanServer.getMBeanInfo(objName);
| System.out.println("@@ -- MBeanTestBean :invokeMBeanFeatures : "+objMBeanInfo.getClassName());
|
| invoker = (JMSContainerInvokerMBean) MBeanProxy.get(JMSContainerInvokerMBean.class,objName,mbeanServer );
| //invoker.stopDelivery();
| System.out.println("@@ Invoker Name = " +invoker.getName());
| System.out.println("@@ Invoker Pllo Size = " +invoker.getMinPoolSize());
| //System.out.println("@@ Invoker Name = " +);
| System.out.println("@@ Invoker Message = " +invoker.getMaxMessages());
|
| invoker.stopDelivery();
|
| System.out.println("@@ Invoker Message = stopDelivery ");
|
| //invoker.getClass().newInstance().stopDelivery();
| //invoker.getClass().newInstance().stop();
|
|
|
| }catch(Exception ex){
|
| ex.printStackTrace();
| }
| }
| }
Start delivary code
| package com.test;
|
| import org.jboss.ejb.plugins.jms.JMSContainerInvokerMBean;
| import org.jboss.mx.util.MBeanServerLocator;
| import org.jboss.mx.util.MBeanProxy;
|
| import javax.ejb.SessionBean;
| import javax.ejb.CreateException;
| import javax.ejb.SessionContext;
| import javax.ejb.EJBException;
| import javax.management.MBeanServer;
| import javax.management.ObjectName;
| import javax.management.MBeanInfo;
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
|
| /**
| * Created by IntelliJ IDEA.
| * User: 151054
| * Date: Aug 30, 2007
| * Time: 7:09:22 PM
| * To change this template use File | Settings | File Templates.
| */
|
| public class MBeanStartBean implements SessionBean {
|
| private SessionContext mContext;
| private MBeanServer mbeanServer;
| private ObjectName mManagementService;
|
| private Context jndiCtx=null;
| private JMSContainerInvokerMBean invoker = null;
|
| public MBeanStartBean() {
| }
|
| public void ejbCreate() throws CreateException {
|
| if(mbeanServer == null)
| try {
| jndiCtx = new InitialContext();
| String serverName = (String)jndiCtx.lookup("java:comp/env/Server-Name");
| serverName = serverName.trim();
| if(serverName == null || serverName.length() == 0 || serverName.equals("null")) {
| try {
| mbeanServer = MBeanServerLocator.locateJBoss();
| System.out.println("@@@ --------- mbeanServer = "+mbeanServer.getDefaultDomain());
| System.out.println("@@@ --------- mbeanServer No of MBean = "+mbeanServer.getMBeanCount());
|
| }
| catch(IllegalStateException e) {
| throw new CreateException("No local JMX MBeanServer available");
| }
| } else {
| Object lServer = jndiCtx.lookup(serverName);
| if(lServer != null) {
| if(lServer instanceof MBeanServer)
| mbeanServer = (MBeanServer)lServer;
| else
| throw new CreateException("Server: " + lServer + " reference by Server-Name: " + serverName + " is not of type MBeanServer");
| } else {
| throw new CreateException("Server-Name " + serverName + " does not reference an Object in JNDI");
| }
| }
| }
| catch(NamingException ne) {
| throw new EJBException(ne);
| }
| }
|
| public void setSessionContext(SessionContext sessionContext) throws EJBException {
| }
|
| public void ejbRemove() throws EJBException {
| }
|
| public void ejbActivate() throws EJBException {
| }
|
| public void ejbPassivate() throws EJBException {
| }
|
|
| public void invokeMBeanStart(){
| try{
|
| //Object name = jndiCtx.lookup("MessageEJB");
|
| ObjectName objName = new ObjectName("jboss.j2ee:service=EJB,plugin=invoker,binding=message-driven-bean,jndiName=MessageEJB");
| //ObjectName objName = new ObjectName((String)name);
| MBeanInfo objMBeanInfo = mbeanServer.getMBeanInfo(objName);
| System.out.println("@@ -- MBeanTestBean :invokeMBeanFeatures : "+objMBeanInfo.getClassName());
|
| invoker = (JMSContainerInvokerMBean) MBeanProxy.get(JMSContainerInvokerMBean.class,objName,mbeanServer );
| //invoker.stopDelivery();
| System.out.println("@@ Invoker Name = " +invoker.getName());
| System.out.println("@@ Invoker Pllo Size = " +invoker.getMinPoolSize());
| //System.out.println("@@ Invoker Name = " +);
| System.out.println("@@ Invoker Message = " +invoker.getMaxMessages());
|
| invoker.startDelivery();
| //invoker.
| System.out.println("@@ Invoker Message = startDelivery ");
|
| //invoker.getClass().newInstance().stopDelivery();
| //invoker.getClass().newInstance().stop();
|
|
|
| }catch(Exception ex){
|
| ex.printStackTrace();
| }
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079650#4079650
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079650
17Â years, 2Â months
[Tomcat, HTTPD, Servlets & JSP] - MyFaces problem
by earniedyke
Greetings all,
I am trying to develop my first Java Server Faces application on 4.0.5 and I am getting the error below. As you can see, it does not appear to be loading myfaces-api or myfaces-impl. I have upgrade to MyFaces 1.1.5 as suggested but I am still getting this error. Below are my web.xml, faces-config.xml and the jsp I am trying to execute.
What am I missing?
Thanks in advance for any and all help.
Earnie!
2007-08-30 10:07:11,046 INFO [org.jboss.web.tomcat.tc5.TomcatDeployer] deploy, ctxPath=/Sim, warUrl=.../tmp/deploy/tmp54598Sim-exp.war/
| 2007-08-30 10:07:11,546 INFO [org.apache.myfaces.config.FacesConfigurator] Reading standard config org/apache/myfaces/resource/standard-faces-config.xml
| 2007-08-30 10:07:11,859 INFO [org.apache.myfaces.config.FacesConfigurator] Reading config /WEB-INF/faces-config.xml
| 2007-08-30 10:07:12,015 INFO [org.apache.myfaces.config.FacesConfigurator] MyFaces-package : myfaces-api not found.
| 2007-08-30 10:07:12,015 INFO [org.apache.myfaces.config.FacesConfigurator] MyFaces-package : myfaces-impl not found.
| 2007-08-30 10:07:12,015 INFO [org.apache.myfaces.config.FacesConfigurator] MyFaces-package : tomahawk-sandbox not found.
| 2007-08-30 10:07:12,015 INFO [org.apache.myfaces.config.FacesConfigurator] MyFaces-package : tomahawk not found.
| 2007-08-30 10:07:12,031 WARN [org.apache.myfaces.shared_impl.util.LocaleUtils] Locale name in faces-config.xml null or empty, setting locale to default locale : en_US
| 2007-08-30 10:07:12,250 INFO [org.apache.myfaces.config.FacesConfigurator] Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
| 2007-08-30 10:07:12,265 INFO [org.apache.myfaces.webapp.StartupServletContextListener] ServletContext 'C:\JBoss\jboss-4.0.5.GA\server\default\.\tmp\deploy\tmp54598Sim-exp.war\' initialized.
| 2007-08-30 10:07:21,343 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/Sim].[jsp]] Servlet.service() for servlet jsp threw exception
| javax.faces.FacesException: Faces context not found. getResponseWriter will fail. Check if the FacesServlet has been initialized at all in your web.xml configuration fileand if you are accessing your jsf-pages through the correct mapping. E.g.: if your FacesServlet is mapped to *.jsf (with the <servlet-mapping>-element), you need to access your pages as 'sample.jsf'. If you tried to access 'sample.jsp', you'd get this error-message.
| at javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:926)
| at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:313)
| at org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:73)
| at org.apache.jsp.Sim_jsp._jspx_meth_f_view_0(Sim_jsp.java:87)
| at org.apache.jsp.Sim_jsp._jspService(Sim_jsp.java:63)
| at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
| at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
| at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
| at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
| at java.security.AccessController.doPrivileged(Native Method)
| at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
| at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
| at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:161)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:245)
| at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
| at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
| at java.security.AccessController.doPrivileged(Native Method)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
| at java.security.AccessController.doPrivileged(Native Method)
| at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
| at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
| at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:217)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:197)
| at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
| at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
| at java.security.AccessController.doPrivileged(Native Method)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| at java.lang.Thread.run(Thread.java:595)
|
web.xml
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
|
| <web-app>
|
| <display-name>Sim Execution Web App</display-name>
|
| <context-param>
| <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
| <param-value>server</param-value>
| <description>
| State saving method: "client" or "server" (= default)
| See JSF Specification 2.5.2
| </description>
| </context-param>
|
| <context-param>
| <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
| <param-value>true</param-value>
| <description>
| This parameter tells MyFaces if javascript code should be allowed in the
| rendered HTML output.
| If javascript is allowed, command_link anchors will have javascript code
| that submits the corresponding form.
| If javascript is not allowed, the state saving info and nested parameters
| will be added as url parameters.
| Default: "true"
| </description>
| </context-param>
|
| <context-param>
| <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
| <param-value>false</param-value>
| <description>
| This parameter tells MyFaces if javascript code should be allowed in the
| rendered HTML output.
| If javascript is allowed, command_link anchors will have javascript code
| that submits the corresponding form.
| If javascript is not allowed, the state saving info and nested parameters
| will be added as url parameters.
| Default: "false"
|
| Setting this param to true should be combined with STATE_SAVING_METHOD "server" for
| best results.
|
| This is an EXPERIMENTAL feature. You also have to enable the detector
| filter/filter mapping below to get JavaScript detection working.
| </description>
| </context-param>
|
| <context-param>
| <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
| <param-value>true</param-value>
| <description>
| If true, rendered HTML code will be formatted, so that it is "human readable".
| i.e. additional line separators and whitespace will be written, that do not
| influence the HTML code.
| Default: "true"
| </description>
| </context-param>
|
| <context-param>
| <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
| <param-value>true</param-value>
| <description>
| If true, a javascript function will be rendered that is able to restore the
| former vertical scroll on every request. Convenient feature if you have pages
| with long lists and you do not want the browser page to always jump to the top
| if you trigger a link or button action that stays on the same page.
| Default: "false"
| </description>
| </context-param>
|
| <listener>
| <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
| </listener>
|
| <servlet>
| <servlet-name>Faces Servlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.faces</url-pattern>
| </servlet-mapping>
|
| </web-app>
faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
| <!DOCTYPE faces-config PUBLIC
| "-//Sun Microsystems, Inc.//DTD JSF Config 1.1//EN"
| "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
| <faces-config>
| <navigation-rule>
| <from-view-id>/Sim.jsp</from-view-id>
| <navigation-case>
| <from-outcome>success</from-outcome>
| <to-view-id>/SimResponse.jsp</to-view-id>
| </navigation-case>
| </navigation-rule>
| <navigation-rule>
| <from-view-id>/Sim.jsp</from-view-id>
| <navigation-case>
| <from-outcome>success</from-outcome>
| <to-view-id>/SimResponse.jsp</to-view-id>
| </navigation-case>
| </navigation-rule>
|
| <managed-bean>
| <managed-bean-name>simBean</managed-bean-name>
| <managed-bean-class>
| org.ebsinc.sim.bean.SimBean
| </managed-bean-class>
| <managed-bean-scope>session</managed-bean-scope>
| </managed-bean>
|
| </faces-config>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079643#4079643
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079643
17Â years, 2Â months
[JBoss Seam] - Re: s:link jta - transaction, rollbackonly
by motte1979
It seams that the lifecycle for s:link and s:button is different from h:commanButton:
The log shows me for s:button and s:link the following informations
2007-08-30 16:26:06,924 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] beginning transaction prior to phase: RESTORE_VIEW 1
| 2007-08-30 16:26:06,966 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] committing transaction after phase: RESTORE_VIEW 1
| 2007-08-30 16:26:06,969 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] beginning transaction prior to phase: RENDER_RESPONSE 6
| 2007-08-30 16:26:06,996 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] committing transaction after phase: INVOKE_APPLICATION 5
| 2007-08-30 16:26:07,002 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] beginning transaction prior to phase: INVOKE_APPLICATION 5
| 2007-08-30 16:26:07,418 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] committing transaction after phase: RENDER_RESPONSE 6
|
|
for h:commandButton looks like
| 2007-08-30 16:22:13,633 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] beginning transaction prior to phase: RESTORE_VIEW 1
| 2007-08-30 16:22:14,659 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] committing transaction after phase: INVOKE_APPLICATION 5
| 2007-08-30 16:22:14,677 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] beginning transaction prior to phase: RENDER_RESPONSE 6
| 2007-08-30 16:22:16,022 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] committing transaction after phase: RENDER_RESPONSE 6
|
Does anyone know the reason for seam 2.0.0.BETA1 doing this?
I'm using JSF-impl bundled with JBoss 4.2.0 -> jsf_impl_1.2_04-b10-p01
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079639#4079639
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079639
17Â years, 2Â months