Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Enabling Byteman Script with Red Hat JBoss Fuse and AMQ - Part1

January 2, 2018
Chandra Shekhar Pandey
Related topics:
JavaMicroservices
Related products:
Streams for Apache KafkaRed Hat Fuse

    In a production or customer environment it is not always possible to identify issues by looking at logs, nor is it always possible to setup remote debugging using an integrated development environment (IDE) and remote debug port. Often the issues are specific to the environment and can't be reproduced. Having byteman scripts can help in these situations to identify issues without actual code changes. Whenever certain java class or logic is invoked, byteman scripts will also be invoked as per defined class and method in the byteman script.

    Here are the steps to follow:

    1.  Download Byteman binary here. I downloaded version 3.0.10: http://downloads.jboss.org/byteman/3.0.10/byteman-download-3.0.10-bin.zip.

    2.  Extract it in the same machine where Red Hat JBoss Fuse exists.

    3.  Once extracted, create a text file(byteman script) script.btm( file at location /path/to/byteman-download-3.0.10. Here byteman-download-3.0.10 is the folder created after extracting binary.

    4.  Content of this script would be:

    RULE check authpassword
    CLASS org.apache.karaf.shell.ssh.KarafJaasAuthenticator
    METHOD authenticate(java.lang.String, java.lang.String, org.apache.sshd.server.session.ServerSession)
    AT ENTRY
    IF true
    DO 
    traceOpen("file.out", "byteman.log");
    traceln("file.out"," password: "+ $2);
    ENDRULE
    

    Point to note here:

    • We want to analyse authenticate method of KarafJaasAuthenticator class. We want to check the value of the 2nd parameter, which is password.
    • We are using traceOpen so that traceln logs are finally written to byteman.log. If we don't use traceOpen, then traceln logs will be printed in Karaf's terminal, thus we might loose logs.

    5.  In Red Hat JBoss Fuse, we have to edit file ${karaf.home}/etc/config.properties and modify property org.osgi.framework.bootdelegation so that it include package 'org.jboss.byteman.*' as well, like below:

    org.osgi.framework.bootdelegation=org.apache.karaf.jaas.boot,sun.*,com.sun.*,javax.transaction,javax.transaction.*,org.apache.xalan.processor,org.apache.xpath.jaxp,org.apache.xml.dtm.ref,org.apache.xerces.jaxp.datatype,org.apache.xerces.stax,org.apache.xerces.parsers,org.apache.xerces.jaxp,org.apache.xerces.jaxp.validation,org.apache.xerces.dom,org.jboss.byteman.*

    6.   Now edit ${karaf.home}/bin/setenv file and include JAVA_OPTS jvm argument as below. This argument refers to byteman jar and byteman script script.btm.

    export JAVA_OPTS="-javaagent:/path/to/byteman-download-3.0.10/lib/byteman.jar=script:/path/to/byteman-download-3.0.10/script.btm,boot:/path/to/byteman-download-3.0.10/lib/byteman.jar"

    7.  The purpose of this script is to check to see if the password entered for authentication is being passed correctly in code or not. Similarly, there may be other use-cases where one wants to check the code execution.

    Actual java class which is invoked to login is: org.apache.karaf.shell.ssh.KarafJaasAuthenticator
    Method invoked: public boolean authenticate(final String username, final String password, final ServerSession session)

    These details we can get while troubleshooting issues. I found this class in DEBUG level logs. So troubleshooting always starts with logs.

    8.  To test, first start Red Hat JBoss Fuse using start script.

    [cpandey@cpandey bin]$ pwd
    /path/to/jboss-fuse-6.3.0.redhat-310/bin
    [cpandey@cpandey bin]$ ./start

    9.  Now run the client script to access karaf terminal. Password we entered is 'wrongpassword'.

    [cpandey@cpandey bin]$ ./client -u admin
    Logging in as admin
    Password: 
    Password:

    10.  Now check byteman.log which we configured above in script file script.btm. We should get the password entered in logs.

    [cpandey@cpandey jboss-fuse-6.3.0.redhat-310]$ pwd
    /path/to/jboss-fuse-6.3.0.redhat-310
    
    [cpandey@cpandey jboss-fuse-6.3.0.redhat-310]$ tail -f byteman.log 
     password: wrongpassword

    This example above was a real use-case. We can troubleshoot other issues if we want to get information from code where logs are not sufficient or not available. This has also been tested in Fabric environment.

    That's it. Thanks for reading!


    Take advantage of your Red Hat Developers membership and download RHEL today at no cost.

     

    Last updated: January 12, 2018

    Recent Posts

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    • Control multicluster costs with right-sizing in Red Hat Advanced Cluster Management 5

    • Lightbits is now certified for Red Hat OpenStack Services on OpenShift

    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI