[Freeswitch-users] Issue of access JNDI from java application through mod_java

Lin, Xiaoping xlin at soleocommunications.com
Thu Aug 24 20:00:24 UTC 2017


I ran into error when trying to bring in a third party package into Java Frame work.
It failed in resolving a JNDI name. It works as a stand alone application, but does not work inside java application through mod_java
I appreciate any help or input.

Many Thanks!

The configuration file:

<configuration name="java.conf" description="Java Plug-Ins">
  <javavm path="/usr/java/jdk1.8.0_31/jre/lib/amd64/server/libjvm.so"/>
  <options>
    <option value="-server"/>
    <option value="-XDebug"/>
    <option vlaue="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=14400"/>
    <option value="-Dcom.soleo.utils.datafill.DatafillDirectory=/usr/local/XMLNetworkGateway/VoiceService/datafill"/>
    <option value="-Dcom.sun.management.jmxremote=true" />
    <option value="-Dcom.sun.management.jmxremote.port=8000"/>
    <option value="-Dcom.sun.management.jmxremote.authenticate=false"/>
    <option value="-Dcom.sun.management.jmxremote.ssl=false"/>
    <option value="-Dcom.sun.management.jmxremote.local.only=false"/>
    <option value="-Djava.class.path=$${script_dir}/freeswitch.jar:$${script_dir}/example.jar:/usr/local/freeswitch/java_libs/java_websocket.jar:/usr/local/freeswitch/java_libs/gson-2.8.0.jar:/usr/local/freeswitch/VoiceClient/SessionFactory.jar:/usr/local/XMLNetworkGateway/lib/SRPBaseCommonAPI.jar:/usr/local/XMLNetworkGateway/lib/SoleoDSARSAccess.jar:/usr/local/XMLNetworkGateway/lib/SoleoUtils.jar:/usr/local/XMLNetworkGateway/lib/soleo-counterlib.jar:/usr/local/XMLNetworkGateway/lib/joda-time.jar:/usr/local/XMLNetworkGateway/lib/java-sdk-3.8.0-jar-with-dependencies.jar:/usr/local/XMLNetworkGateway/lib/ListingUtils.jar:/usr/local/XMLNetworkGateway/lib/TTSTextProcessor.jar:/usr/local/XMLNetworkGateway/lib/FSVoiceClient.jar"/>
        <option value="-Xmx512m"/>
    <option value="-XX:+HeapDumpOnOutOfMemoryError"/>
    <!--<option value="-XX:MaxMetaspaceSize=128m"/>-->
    <option value="-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled"/>
    <option value="-XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark"/>
  </options>
  <startup class="org/freeswitch/example/ApplicationLauncher" method="startup"/>
</configuration>


The error from my log

Aug 24, 2017 12:35:24.688 com.ibm.watson.developer_cloud.util.CredentialUtils getKeyUsingJNDI
FINE: JNDI watson-developer-cloud/speech_to_text/credentials not found.


Checking the code

It failed at

private static String getKeyUsingJNDI(String serviceName) {
    if (!isClassAvailable("javax.naming.Context") || !isClassAvailable("javax.naming.InitialContext")) {
      log.info("JNDI string lookups is not available.");
      return null;
    }
    String lookupName = "watson-developer-cloud/" + serviceName + "/credentials";
    try {
      Context context = new InitialContext();
      return (String) context.lookup(lookupName);
    } catch (Exception e) {
      log.fine("JNDI " + lookupName + " not found.");
      return null;
    }
  }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170824/b8a228cf/attachment.html>


More information about the FreeSWITCH-users mailing list