Retransforming classes on remote JVM using Java agent - javaagents

I try to retransform a class in a remote virtual machine (on the same host).
An agent (packed in jar with correct values in manifest) is loaded, but the transformer never called, although I ask the Instrumentation to retransform the class explicitly in my Agent agentmain method (I verified that the following code is called):
instrumentation.addTransformer(new MyClassFileTransformer(), true);
instrumentation.retransformClasses(Class.forName("example.MyClassToTransform"));
Any ideas why the retransformation doesn't happen and what should I fix?

Related

How to generate TLS certificate bound gRPC server with protoc

Using protoc, in golang in my case, the generated server files are not bound to a TLS certificate and key that I have created. In fact I had to instantiate the grpc server using this approach:
creds, _ := credentials.NewServerTLSFromFile("server.crt", "server.key")
s := grpc.NewServer(grpc.Creds(creds))
s.Serve(listener)
and because this code is not the generated one, I need to use the above to register my service descriptor and handler:
s.RegisterService(&_My_serviceDesc, &handler.MailServer{})
The original generated _My_serviceDesc variable is in the generated package, therefore inaccessible from my main package, so I had to define it in mythemain package where I am starting the server above. Also, this same variable references a handler defined with an underscore _My_Handler which I also had to redefine in the main package.
I chacked the protoc documentation and help and there seems to be no way to do this otherwise. I wonder why it is not possible to associate it to the certificates that I need. This seems very odd...
TLS config is done on the gRPC server (when calling grpc.NewServer).
You can register service on the created server as normal.
See the TLS example here: https://github.com/grpc/grpc-go/tree/master/examples/features/encryption

Exporting CEP definition file from the authoring tool to an (external) repository

We are having problems with the exporting of the CEP definition file from the authoring tool to an (external) repository.
In the response preview from the developer tools of the browser we get the following error message:
"HTTP Status 500 - A javax.ws.rs.ext.MessageBodyReader implementation was not found for class org.apache.wink.json4j.JSONArray type and text/html;charset=utf-8 media type. Verify that all entity providers are correctly registered. Add a custom javax.ws.rs.ext.MessageBodyReader provider to handle the type and media type if a JAX-RS entity provider does not currently exist."
How can we make sure we are able to export to an external repository?
Your problem is that the external repository is not available.
Since you didn't mention this, my guess is that you are using the default external repository which is http://localhost:8080/ProtonOnWebServerAdmin/resources/definitions
but don't have a running instance of ProtonOnWebServerAdmin. You have got to have ProtonOnWebServerAdmin running on a Tomcat server on your local machine for it to actually process the request.
If you're using anything else - make sure that repository knows how to handle the request.

Stream Management (XEP-0198) in Prosody

I am using Prosody for stream management. But I am suffering from some issues.
How can I ensure that stream management is enabled on prosody ? Is there any command to test on terminal ?
I also tried to add mod_smacks.lua modules in modules. but I don't know how to enable it on server.
I am using XMPPFramework as chat client on iOS. There is already a method to check support for stream management or not, but it is returning me always false so far.
Please help me out to enable stream management in prosody.
After you added mod_smacks.lua into your /usr/lib/prosody/modules/ add
"smacks";
to your
modules_enabled = {
...
}
in your /etc/prosody/prosody.cfg.lua if you want the module to be loaded every time prosody starts.
Then restart prosody.
Prosodyctl does not show loaded modules.
You can check if the module is loaded via ad-hoc commands (or telnet if activated). You can even load and unload modules via ad-hoc/telnet.
You get more information about mod_smacks here.

Message Driven bean external configuration for JBoss with IBM MQ

I am working on a Notification Service using IBM MQ messaging provider with JBoss eap 6.1 environment. I am successfully able to send messages via MQ JCA provider rar i.e. wmq.jmsra.rar file. However on consumer part my current configuration looks like this
#MessageDriven(
activationConfig = {
#ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
#ActivationConfigProperty(propertyName="destination", propertyValue="F2.QUEUE"),
#ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:jboss/jms/TopicFactory"),
#ActivationConfigProperty(propertyName="queueManager", propertyValue="TOPIC.MANAGER"),
#ActivationConfigProperty(propertyName="hostName", propertyValue="10.239.217.242"),
#ActivationConfigProperty(propertyName="userName", propertyValue="root"),
#ActivationConfigProperty(propertyName = "channel", propertyValue = "TOPIC.CHANNEL"),
#ActivationConfigProperty(propertyName = "port", propertyValue = "1422")
})
My problem is that consumer of this service does not want to add any port numbers, hostName, queueManager properties in these beans. Also they do not want to use ejb-jar.xml to externalize these configs. I have researched and found that we can add a domain IBM Message Driven Bean but with no success. Any suggestions on what I can do here to externalize all these configurations ?
EDIT: Adding --> The JCA resource adapter is deployed at consumer end if it makes it any easier.
Thanks
You can actually externalize an MDBs activation spec properties to the server configuration file.
Create the ejb-jar.xml file, but do not put the actual value in the file, use a property placeholder:
<activation-config-property>
<activation-config-property-name>hostName</activation-config-property-name>
<activation-config-property-value>${wmq.host}</activation-config-property-value>
</activation-config-property>
Do this for all of the desired properties.
Ensure that property replacement for Java EE spec files (ejb-jar.xml, in this case) is enabled in the server configuration file:
<subsystem xmlns="urn:jboss:domain:ee:1.2">
<spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
Then, in the server configuration file, provide values for your properties:
<system-properties>
<property name="wmq.host" value="10.0.0.150"/>
Once your MDBs are packaged, you will not need to change any of the files in the MDB jar - just provide the properties in the server configuration.
you can avoid to add host name, port number and so on in MDB, you just want to define destinationType in MDB, and rest of the thing u can configure in your application server, like Activation Specification, Queues and Queue Connection Factories.
I have done the same thing but i used IBM Websphere Application Server.

How can I get notified when log4j fails?

like http://www.experts123.com/q/is-log4j-a-reliable-logging-system.html said: log4j doesn't throw any unexpected exception at run-time. If I want application infomation to be logged to a remote host, when the remote host is not reachable for network interruption or its ip address is changed, I want to send a mail to notify network administrator or switch to other appender like DailyRollingFileAppender.
since I can't catch the exception, so what else should I do to make me get notified when log4j fails ?
I have solved it.
use DOMConfigurator to configure FallbackErrorHandler, a spare appender when log4j fails.
I first use PropertyConfigurer but it warns that FallBackErrorHandler is not a proper element, I don't know why, but it worked well when change to DOMConfigurator.