All Apps and Add-ons

JMS Messaging Modular Input Custom Message Handler throws java.lang.AbstractMethodError

mcormier_splunk
Splunk Employee
Splunk Employee

We are running the JMS MI on on linux (Java 😎 with a custom message handler. In jms.py, a Java Exception (java.lang.AbstractMethodError) is thrown. I am using the pattern defined in this Answer:
https://answers.splunk.com/answers/310006/how-to-convert-byte-characters-coming-out-of-mq-th.html

I'm not sure what interface has changed to cause this. Is there a place we should look to debug this?

Thanks,

Mike

Damien_Dallimor
Ultra Champion

Did you compile your custom handler with Java 7 ?

The 0033 hex in the compiled class file means was compiled with Java 7. So if you compiled with Java 8 , I think that is the cause of your error message. You can still run with Java 8 after compiling with Java 7.

alt text

0 Karma

mcormier_splunk
Splunk Employee
Splunk Employee

I simplified this as much as possible (see code below), and even copied the class AbstractMessageHandler.java into the package, recompiled with Java 7 and we still get the following error:

02-04-2016 16:10:02.947 -0500 ERROR ExecProcessor - message from "python /web/splunk/etc/apps/jms_ta/bin/jms.py" Exception in thread "Thread-3" java.lang.AbstractMethodError: com.splunk.modinput.jms.AbstractMessageHandler.handleMessage(Ljavax/jms/Message;Lcom/splunk/modinput/jms/JMSModularInput$MessageReceiver;)Lcom/splunk/modinput/Stream;

02-04-2016 16:10:02.947 -0500 ERROR ExecProcessor - message from "python /web/splunk/etc/apps/jms_ta/bin/jms.py"        at com.splunk.modinput.jms.JMSModularInput$MessageReceiver.streamMessageEvent(Unknown Source)

02-04-2016 16:10:02.947 -0500 ERROR ExecProcessor - message from "python /web/splunk/etc/apps/jms_ta/bin/jms.py"        at com.splunk.modinput.jms.JMSModularInput$MessageReceiver.browseQueue(Unknown Source)

02-04-2016 16:10:02.947 -0500 ERROR ExecProcessor - message from "python /web/splunk/etc/apps/jms_ta/bin/jms.py"        at com.splunk.modinput.jms.JMSModularInput$MessageReceiver.run(Unknown Source)

package com.tsys.jms;

import com.splunk.modinput.SplunkLogEvent;
import com.splunk.modinput.jms.AbstractMessageHandler;
import com.splunk.modinput.jms.JMSModularInput.MessageReceiver;
import java.util.Map;
import javax.jms.Message;

public class BinaryToText extends AbstractMessageHandler {


@Override
public void handleMessage(Message message, MessageReceiver context)
        throws Exception {

    SplunkLogEvent splunkEvent = buildCommonEventMessagePart(message, context);

    String bodyContent = "Hello World";
    splunkEvent.addPair("msg_body", bodyContent);

    String text = splunkEvent.toString();
    transportMessage(text,String.valueOf(System.currentTimeMillis()),"");
}

@Override
public void setParams(Map<String, String> params) {
    // Do nothing , params not used
}
}
0 Karma

effem2
Path Finder

What was the Solution to this?

0 Karma

mcormier_splunk
Splunk Employee
Splunk Employee

I compiled the custom message handler with Java 8. I will recompile with Java 7 and see if that works.

0 Karma

mcormier_splunk
Splunk Employee
Splunk Employee

I have recompiled the handler with Java 7, and am using Java 7 on the linux box. Same error occurs (see output below). What would be the next step to debugging this?

02-04-2016 10:49:02.427 -0500 ERROR ExecProcessor - message from "python /web/splunk/etc/apps/jms_ta/bin/jms.py" Exception in thread "Thread-3" java.lang.AbstractMethodError: com.splunk.modinput.jms.AbstractMessageHandler.handleMessage(Ljavax/jms/Message;Lcom/splunk/modinput/jms/JMSModularInput$MessageReceiver;)Lcom/splunk/modinput/Stream;

02-04-2016 10:49:02.427 -0500 ERROR ExecProcessor - message from "python /web/splunk/etc/apps/jms_ta/bin/jms.py"        at com.splunk.modinput.jms.JMSModularInput$MessageReceiver.streamMessageEvent(Unknown Source)

02-04-2016 10:49:02.427 -0500 ERROR ExecProcessor - message from "python /web/splunk/etc/apps/jms_ta/bin/jms.py"        at com.splunk.modinput.jms.JMSModularInput$MessageReceiver.browseQueue(Unknown Source)

02-04-2016 10:49:02.427 -0500 ERROR ExecProcessor - message from "python /web/splunk/etc/apps/jms_ta/bin/jms.py"        at com.splunk.modinput.jms.JMSModularInput$MessageReceiver.run(Unknown Source)
0 Karma

mcormier_splunk
Splunk Employee
Splunk Employee

Adding sanitized source code:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tsys.convertjmsbinary;

import com.splunk.modinput.SplunkLogEvent;
import com.splunk.modinput.jms.AbstractMessageHandler;
import com.splunk.modinput.jms.JMSModularInput.MessageReceiver;
import java.util.Map;
import javax.jms.BytesMessage;
import javax.jms.JMSException;
import javax.jms.Message;

public class jmsConvertToBinary extends AbstractMessageHandler {

public fieldManager fM = null;
public String fileName = null;


@Override
public void handleMessage(Message message, MessageReceiver context)
        throws Exception {

    SplunkLogEvent splunkEvent = buildCommonEventMessagePart(message, context);

    String bodyContent = convertToBinary(message);
    splunkEvent.addPair("msg_body", bodyContent);

    String text = splunkEvent.toString();
    transportMessage(text,String.valueOf(System.currentTimeMillis()),"");
}

private String convertToBinary(Message message) {

    BytesMessage msg;
    String decodedContent = "";
    byte[] data;

    //write some code to get the message content and decode it
    if (fM == null)
        return("no message format file");

    msg = (BytesMessage) message;
    try {
        data = new byte[(int) msg.getBodyLength()];
        msg.readBytes(data);
        if (fM != null)
            decodedContent = fM.convertBytesToFields(data);
    } catch (JMSException ex) {
        System.err.println("JMS Exception: " + ex.getMessage());
    }  
    return(decodedContent);
}

@Override
public void setParams(Map<String, String> params) {
    // Do nothing , params not used
    fileName = params.get("msg.format.file");
    if (fileName != null)
        fM = new fieldManager(fileName);
    else
        fM = null;
}

}

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...