IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Java Service to get log4j logger name

    Posted Tue March 28, 2006 06:50 PM

    Hi All,
    I am creating a java service that will return the service name from which it is called, compatible with log4j logging. It basically replaces the ‘:’ with a ‘.’.

    [highlight=java]
    String loggerName = null;

    NSService myService = (NSService) Service.getCallingService();
    loggerName = myService.getNSName().getFullName();
    loggerName.replaceAll(“:”,“.”);

    // pipeline out
    IDataCursor pipelineCursor = pipeline.getCursor();
    IDataUtil.put(pipelineCursor, “loggerName”, loggerName);
    pipelineCursor.destroy();

    [/highlight]
    I don’t want to invoke the pub.string:replace service in here. There is a policy against using existing java services in new java services here.

    This is the error I get.
    Method replaceAll(java.lang.String, java.lang.String) not found in class java.lang.String. loggerName.replaceAll(“:”,“.”);

    Help!!

    Thanks in advance,
    Zafar.
    ^


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 2.  RE: Java Service to get log4j logger name

    Posted Tue March 28, 2006 06:52 PM

    Method replaceAll(char, char) not found in class java.lang.String.
    loggerName.replaceAll(‘:’,‘.’);
    ^
    This is the error…


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 3.  RE: Java Service to get log4j logger name

    Posted Tue March 28, 2006 07:23 PM

    The replaceAll method was introduced in JDK 1.4. Looks like IS is being run under an older JVM.

    Interesting that there’s a restriction on calling built-in services from Java services–seems a bit strange. What’s the policy on using unpublished methods (myService.getNSName().getFullName() uses undocumented methods)?


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 4.  RE: Java Service to get log4j logger name

    Posted Tue March 28, 2006 07:37 PM

    Rob,
    I am developing using the JVM that comes default with IS 6.5.
    I compiled this with HP JVM 1.4 and it works. Maybe its something in the JVM provided with the IS that is causing this error.

    Still investigating.

    The restricion is more against invoking other services.
    The policy is, if you can do something by just using a single java call, do it that way. That would not only keep the code simple, but also reduces the dependency on other packages/services.

    In this case, replaceAll() should do what you can also do by invoking the pub.string:replace service, and deal with all the lines of code you would have to write for the same. FYI.

    Does anyone know of any known issues with the JVM webMethods provides?

    Thank you,
    Z


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 5.  RE: Java Service to get log4j logger name

    Posted Tue March 28, 2006 08:28 PM

    Got it working. The java environment variable on the server was set to an older version of java. When it was changed to point to the JDK 1.4, the service compiled successfully.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services