How do I deploy my Custom MBean into Tomcat 7? - apache

I have successfully created MBeans and deployed it. I can also see that my Custom MBean is deployed in MBeans section in JConsole.
How can I deploy it to Tomcat 7?
I found may tutorials online, which are too old. I have not found any tutorial for Tomcat 7 so far. Please help me in finding a tutorial which suits Tomcat Version 7.
I used a tutorial which was based on Tomcat 6. But I could not succeed because, one of the listeners used in the Server.xml file "ServerLifecycleListener" is not used anymore in Tomcat 7.

You need to add mbeans-descriptors.xml as following and it needs to be placed in same package as the class file it describes.
Adding MBean descriptions
<mbean name="LDAPRealm"
className="org.apache.catalina.mbeans.ClassNameMBean"
description="Custom LDAPRealm"
domain="Catalina"
group="Realm"
type="com.myfirm.mypackage.LDAPRealm">
<attribute name="className"
description="Fully qualified class name of the managed object"
type="java.lang.String"
writeable="false"/>
<attribute name="debug"
description="The debugging detail level for this component"
type="int"/>
.
.
You could refer this as well:
Container level Custom JXM MBean in Tomcat 7

Related

Purpose of localConnector-1.0 feature in Websphere server with IntelliJ

I was following a tutorial for setting up a WebSphere Liberty Server Here and didn't really know what a part of the tutorial did. I completed the tutorial and it works fine.
On step 3 it has me modify the server.xml with these two lines and I dont really know what they do.
<applicationMonitor updateTrigger="mbean" />
<feature>localConnector-1.0</feature>
I Found the documentation for localConnector-1.0 but its a little over my head
https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.liberty.autogen.nd.doc/ae/rwlp_feature_localConnector-1.0.html
I think localConnector allows IntelliJ to run the server somehow but i dont know what updateTrigger="mbean" does.
If anyone has an explanation that would be great. Thanks!
The localConnector-1.0 feature enables the local JMX connector on Liberty so that the JMX Client (IntelliJ) can connect to and administer Liberty.
You can find more documentation on the feature here: https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_admin_localconnector.html
updateTrigger="mbean" is setting the application updates to only occur when trigger by an mbean call (whereas the default is to poll for changes).
You can find more documentation here:
https://www.ibm.com/support/knowledgecenter/SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_setup_dyn_upd.html

org.apache.catalina.LifecycleException: Failed to stop component [SingleSignOn[]]

I am using Apache Tomcat 8.5.12 with JOSSO single sign on .
After configuration I can not start the tomcat server and I get this error.
Everything is well configured.
Does anyone have an idea that can help me to start the server ?enter image description here
Apache Tomcat 8.5 doesn't play nice with the JOSSO Agent for Apache Tomcat 8 as the former has changed the approach for hooking into the event bus. Therefore, an ad-hoc SSO agent is needed, included in an early access release of JOSSO 1.8.12, available here for download : https://github.com/atricore/josso1/releases/tag/1.8.12-rc1-release
A binary distribution is included, hence there's no need to build from the source.
In order to install it, make sure to manually replace the "old" agent artifacts - namely the JOSSO Agent for Tomcat 8 JAR files - with the ones that ship with 1.8.12 RC1.
As far as configuration is concerned, the following changes in the $CATALINA_HOME/lib/josso-agent-config.xml descriptor need to be applied for the JOSSO Agent for Apache Tomcat 8.5 to be instantiated.
From:
<bean class="org.josso.tc80.agent.CatalinaSSOAgent" name="josso-tc80-agent">
To:
<bean class="org.josso.tc85.agent.CatalinaSSOAgent" name="josso-tc85-agent">
As of the JOSSO server component, there is no need to perform any upgrade nor configuration change.

To implement SSL on JMX

I am new to jmx and ssl. Now I am trying to implement jmx with ssl.
I have created keystore and truststore as specified in the link http://www.techbrainwave.com/?p=953.
And implemented a simple java application in eclipse as in https://blogs.oracle.com/jmxetc/entry/jmx_connecting_through_firewalls_using. I configured kestore and truststore files like this,
System.setProperty("javax.net.ssl.keyStore", "C:\\Users\\Administrator\\Desktop\\Certificates\\keystore.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "123456");
Now I have to run the application with jboss. So I edited properties - services.xml. set the same properties with tag like this,
<attribute name="Properties">
javax.net.ssl.trustStore = C:\\Users\\Administrator\\Desktop\\certificates\\truststore.jks
</attribute>
It is working now. My doubt is is this the correct way of implementing jmx and SSL with jboss? or do I have any other way to implement it? please tell me if I am wrong.
Thanks in advance,
its a right way, you can check this link for more details, if you need to run your application in jboss you can specify the properties in wrapper conf

ExtendedFormAuthenticator in JBoss 7

I'm porting a legacy application from JBoss 4.2.3 to JBoss 7 (the web profile version). They used a custom login module and used a valve to capture the login failure reason into j_exception. They did this by putting context.xml into the web-inf directory of the war, with the following contents:
<!-- Add the ExtendedFormAuthenticator to get access to the username/password/exception ->
<Context cookies="true" crossContext="true">
<Valve className="org.jboss.web.tomcat.security.ExtendedFormAuthenticator"
includePassword="true" ></Valve>
</Context>
The login is working for me, but not that valve. When there's a login exception, the j_exception is still empty and the logic that depends on analyzing why the login was rejected fails. According to this link: http://community.jboss.org/wiki/ExtendedFormAuthenticator, everything looks right. However that link is very old, and it's possible things have changed since then. What's the new way?
It seems that security valves are now defined directly in jboss-web.xml, like this:
<jboss-web>
<security-domain>mydomain</security-domain>
<valve>
<class-name>org.jboss.web.tomcat.security.ExtendedFormAuthenticator</class-name>
<param>
<param-name>includePassword</param-name>
<param-value>true</param-value>
</param>
</valve>
</jboss-web>
However, the ExtendedFormAuthenticator class wasn't ported to JBoss 7.0.1. A ticket has been opened for me, so it should be present in JBoss 7.1.0:
https://issues.jboss.org/browse/AS7-1963

Connecting a remote JMS client to GlassFish 3

I am trying to connect to GlassFish 3's JMS service from a standalone remote client. However I am getting a java.lang.ClassNotFoundException: com.sun.messaging.jms.ra.ResourceAdapter. Any ideas on how to fix this?
Here's my setup so far:
Glassfish 3 JMS Service in LOCAL mode (I am assuming that EMBEDED mode will not work in this case because it bypasses the network stack)
JNDI properties are specified as follows:
java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory
java.naming.factory.url.pkgs=com.sun.enterprise.naming
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
gf-client-module.jar (in GLASSFISH_HOME/modules) added to the standalone application's classpath. Also tried adding other jars present in the modules directory (such as jms-core.jar), but still getting the same ClassNotFoundException.
Any help would be much appreciated.
Instead of using all of the individual Glassfish jar files that you might need (such as gf-client-module.jar, imqjmsra.jar, and imqbroker.jar), the preferred method is to use the gf-client.jar file. It can be found at $GLASSFISH_HOME/lib.
There is more information at http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB. That document pertains to using EJBs in standalone clients, but the solution is the same for using JMS.
Ok. I found a solution. See here for details, but the short answer is that I needed to add two jars to the classpath: imqjmsra.jar and imqbroker.jar. These were available inside a rar called imqjmsra.rar which can be found under glassfish's mq directory. I had to extract the two jars from this rar!
This is the complete list of client jars for glassfish 3 :
auto-depends.jar
deployment-common.jar
glassfish-corba-internal-api.jar
internal-api.jar
management-api.jar
bean-validator.jar
dol.jar
glassfish-corba-newtimer.jar
javax.ejb.jar
orb-connector.jar
common-util.jar
ejb-container.jar
glassfish-corba-omgapi.jar
javax.jms.jar
orb-iiop.jar
config-api.jar
ejb.security.jar
glassfish-corba-orb.jar
javax.resource.jar
security.jar
config-types.jar
glassfish-api.jar
glassfish-corba-orbgeneric.jar
javax.servlet.jar
ssl-impl.jar
config.jar
glassfish-corba-asm.jar
glassfish-naming.jar
javax.transaction.jar
transaction-internal-api.jar
connectors-internal-api.jar
glassfish-corba-codegen.jar
gmbal.jar
jta.jar
container-common.jar
glassfish-corba-csiv2-idl.jar
hk2-core.jar
kernel.jar
As mentioned in the Ivan A Krizsan's notes for the EJB certification, and depending on the Glassfish version, this should be enough:
GlassFish 3 (and GlassFish 4 too, I've just tested it): $GLASSFISH_HOME/lib/gf-client.jar
GlassFish 2: $GLASSFISH_HOME/lib/appserv-rt.jar and $APS_HOME/lib/javaee.jar