Splunk Search

how to make Java bridge server status is running.?

SanthoshSreshta
Contributor

Hi Splunkers,

I have installed java 1.8 and splunk 6.2.3 and splunk DB Connect app is 1.2
I have setup the environment variables and setup java path upto bin as : D:\Java\jre
after all i have restarted the the splunk. after giving the path it showed updated successfully. but still unable to get java bridge server as not running.
please help me out.
I am sharing the file path: C:\Program Files \Splunk \var \log \splunk

2015-06-24 10:23:20,572 INFO Checking for obsolete java libraries in C:\Program Files\Splunk\etc\apps\dbx\bin\lib
2015-06-24 10:23:20,576 INFO Started JavaBridgeServer PID=2156
2015-06-24 10:23:21,198 ERROR Java process returned error code 1! Error: Initializing Splunk context... Environment: SplunkEnvironment{SPLUNK_HOME=C:\Program Files\Splunk,SPLUNK_DB=C:\Program Files\Splunk\var\lib\splunk} Configuring Log4j... Exception in thread "main" com.splunk.env.SplunkEnvironmentException: Unable to create directory C:\Program Files\Splunk\var\lib\splunk\persistentstorage\dbx\global  at com.splunk.env.SplunkEnvironment.getSubDirectory(SplunkEnvironment.java:81)  at com.splunk.env.SplunkEnvironment.getPersistentStorageDirectory(SplunkEnvironment.java:150)   at com.splunk.persistence.PersistentValueStoreFactory.createStore(PersistentValueStoreFactory.java:60)  at com.splunk.persistence.PersistentValueStoreFactory.createGlobalStore(PersistentValueStoreFactory.java:51)    at com.splunk.env.SplunkContext.initialize(SplunkContext.java:109)  at com.splunk.bridge.JavaBridgeServer.main(JavaBridgeServer.java:34) 
2015-06-24 10:23:21,198 ERROR Command output: None

This is in javaBridgeServer file:

# Copyright (C) 2005-2015 Splunk Inc. All Rights Reserved.
import sys,os
import signal
from spp.java import JavaEnv
from spp.java.bridge import executeBridgeCommand
from spp.util import getConfInContext

import logging

DEFAULT_CONF = "jbridge_server"
DEFAULT_MAX_LOGFILE_BYTES = 100000000
DEFAULT_MAX_LOGFILE_COUNT = 5
DEFAULT_LOG_FILENAME = 'jbridge.log'
DEFAULT_LOG_LEVEL = logging.INFO 
appName = 'dbx'

def getLogConfig(sessionKey=None, appName=appName, cfgName=DEFAULT_CONF):
   logConfig = dict()
   logConfig['filename'] = DEFAULT_LOG_FILENAME
   logConfig['maxCount'] = DEFAULT_MAX_LOGFILE_COUNT
   logConfig['fileSize'] = DEFAULT_MAX_LOGFILE_BYTES
   logConfig['logLevel'] = DEFAULT_LOG_LEVEL 

   try:
       rawConfig = getConfInContext(cfgName, appName)
   except:
       return logConfig 

   if 'log' not in rawConfig:
      return logConfig

   if 'filename' in rawConfig['log']:
      logConfig['filename'] = rawConfig['log'].get('filename')

   if 'logLevel' in rawConfig['log']:
      logLevel = rawConfig['log'].get('logLevel').upper() 
      if (logging._levelNames.get(logLevel)):
         logConfig['logLevel'] = logging._levelNames.get(logLevel)

   if 'maxCount' in rawConfig['log']:
      logConfig['maxCount'] = int(rawConfig['log'].get('maxCount'))

   if 'fileSize' in rawConfig['log']:
      logConfig['fileSize'] = int(rawConfig['log'].get('fileSize'))

   return logConfig

#setup logging
logConfig = getLogConfig()
logFilename = os.path.join(os.environ['SPLUNK_HOME'], 'var', 'log', 'splunk', logConfig['filename']) 
handler = logging.handlers.RotatingFileHandler(filename=logFilename, mode='a', maxBytes=logConfig['fileSize'], backupCount=logConfig['maxCount'])
logger = logging.getLogger('spp.dbx.javabridge')
logger.setLevel(logConfig['logLevel'])
formatter = logging.Formatter(fmt='%(asctime)s %(levelname)s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)

def log(msg):
    logger.debug(msg)


try:
    executeBridgeCommand("com.splunk.bridge.cmd.Shutdown", checkStatus=True)
    log("JavaBridgeServer was still running...")
except:
    pass

java = JavaEnv()
OBSOLETE = ("jtds-1.2.jar")
logger.info("Checking for obsolete java libraries in %s", java.lib_path)
for file in os.listdir(java.lib_path):
    if file in OBSOLETE:
        logger.info("Deleting obsolete jar file %s", file)
        os.remove(os.path.join(java.lib_path, file))
logger.debug("Starting JavaBridgeServer...")
process = java.execute("com.splunk.bridge.JavaBridgeServer", [str(os.getpid())])
logger.info("Started JavaBridgeServer PID=%d", process.process.pid)


def signal_cleanup(s, f):
    cleanup()


def cleanup():
    log("cleanup callback... terminating process")
    try:
        log("sending shutdown command to jbridge server")
        executeBridgeCommand("com.splunk.bridge.cmd.Shutdown", checkStatus=True)
    except Exception, e:
        log("Error terminating process: %s" % e)
    try:
        log("terminating jbridge process")
        process.terminate()
    except:
        log("Error terminating jbridge process")
    log("termining wrapper process sys.exit(1)")
    sys.exit(1)


watcher = None
running = True

if os.name == 'nt':
    try:
        def win32sighandler(*args):
            logger.debug("WIN32 SIGNAL %s", args)
            cleanup()
            return True

        import win32api

        win32api.SetConsoleCtrlHandler(win32sighandler, True)
        logger.debug("win32 handler registered")
    except Exception, e:
        log.error("Error registering Win32 callback: %s", e)
else:
    signal.signal(signal.SIGTERM, signal_cleanup)

    if hasattr(os, 'uname') and os.uname()[0] == 'Linux':
        from threading import Thread
        import time

        class PPIDWatcher(Thread):
            def __init__(self):
                super(PPIDWatcher, self).__init__()

            def run(self):
                ppid = os.getppid()
                while running:
                    time.sleep(1)
                    try:
                        os.kill(ppid, 0)
                    except:
                        logger.warn("Parent process pid=%d vanished. Shutting down Javabridge Server.", ppid)
                        cleanup()
                        break

        log("starting pid watcher...")
        watcher = PPIDWatcher()
        watcher.start()

try:
    process.waitFor(checkReturnCode=True)
except Exception, e:
    log("Error waiting for process: %s" % e)
running = False
log("JavaBridgeServer terminated")
if watcher: watcher.join()
sys.exit(0)

please can any one resolve my issue please. even am unable to understand the links on this issue.

Thanks in advance,
Santhosh.

0 Karma
1 Solution

splunker12er
Motivator

JAVA_HOME : C:/Program Files/Java/jdk1.8.0_45/jre

Ensure you have set the correct JAVA_HOME environment variable. also install the driver, as mentioned the docs. restart the splunkd

View solution in original post

splunker12er
Motivator

JAVA_HOME : C:/Program Files/Java/jdk1.8.0_45/jre

Ensure you have set the correct JAVA_HOME environment variable. also install the driver, as mentioned the docs. restart the splunkd

SanthoshSreshta
Contributor

Thanks @splunker12er .
I have uninstalled the app and java and again installed java 1.8 and splunk successively and gave path. then got it 🙂

0 Karma

davebrooking
Contributor

The stack trace is saying that Splunk has insufficient permissions to create the folder C:\Program Files\Splunk\var\lib\splunk\persistentstorage\dbx\global. Check the user with which you've installed Splunk has permissions to create files in the folder C:\Program Files\Splunk\var\lib\splunk\persistentstorage and it's subfolders.

I've just gone through a similar situation. Splunk doesn't seem to set up permissions in a WIndows environment as well as it does in a Linux environment.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...