Can not locate Java class using JNI within C++ DLL

I am using trying to use JNI to call a Java class from C++. The Java class uses JMS to send messages to a JMS message queue. At first I coded the C++ in a console application that created the JavaVM and used JNI to access the Java class. All worked fine. Then I called the Java class using JNI from threads and ran into the problem of the Java class not able to locate the JMS related classes. This was solved by placing the following line in the constructor of the Java class.
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
Then I moved the JNI code from a console application to a DLL in specific an extension DLL that is called by SQL Server or Oracle server. The DLL will use JNI to call the Java class and send messages to a JMS message queue.
The problem I am having now when the DLL code is called by SQL Server the call to
JNI_CreateJavaVM
appears to work correctly but the call to find the Java class using
jvmEnv->FindClass(pName)
fails. It appears the is a class loading problem which occurs due to the fact JNI is called from a DLL. When the VM is created I pass the class path information using the statement
-Djava.class.path=
And as I stated before it all works when running from a console application. I am new to JNI and really need help in the form of some sample code that will solve this problem. I believe I need to somehow load the classpath information from the DLL but I can not find examples on how to do this using JNI. I have tried several ways using URLClassLoader and getSystemClassLoader from JNI and either it does not work or it crashes very badly.
I used the following code to determine what the existing class path is and the string returns empty.
jcls = jvmEnv->FindClass("java/lang/System");
jmid = jvmEnv->GetStaticMethodID(jcls, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
jstrClassPath = jvmEnv->NewStringUTF("java.class.path");
jstr = (jstring)jvmEnv->CallStaticObjectMethod(jcls, jmid, jstrClassPath);
m_jstr = (jstring)jvmEnv->NewGlobalRef(jstr);
pstr = jvmEnv->GetStringUTFChars(m_jstr, 0);
Can anyone please help with example code that will solve this problem. Thanks in advance for any help.
Charles�

I have determined the problem occurs when the application/component is compiled using VC 6.0. The test application was compiled using VC 7.1 and works correctly by locating the class path information. If the test application is compiled using VC 6.0 it has the same problem.
The jvm.dll I am using is version 1.4.2.80. Currently this is not an option to compile all the applications that use JNI using VC 7.1 so can someone please tell me how to solve this problem.

Similar Messages

  • Tomcat-4.0.2 can not locate Java Class

    I have an application which runs fine under Tomcat-3.x. Now I am trying to run under Tomcat-4.0.2, right after I login to my application (As you can see the new Tomcat does find my application's index.html fine), I got an error:
    Apache Tomcat/4.0.2 - HTTP Status 500 - Internal Server Error
    type Exception report
    message Internal Server Error
    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred between lines: 8 and 13 in the jsp file: /login.jsp
    Generated servlet error:
    C:\jakarta-tomcat-4.0.2\work\localhost\adms\login$jsp.java:80: Undefined variable or class name: Utility
    boolean auth=Utility.ldapAuthenticate(userEmail,password);
    It looks Tomcat can not find the Utility class, even though it is under usual place: WEB-INF/classes.
    Now, I even copies all the directory structures into $CATALINA_HOME\webapps, still no luck.
    I am running on W2K.
    Can anyone shed me some light? Thanks.

    Oh! I can do it now.
    Just import the class you want...
    <%@page import="Utilities" %>
    and put that class in WEB-INF/classes

  • I can not drag java class onto uml class diagram - why??

    Hi
    1. I created a new java web project
    2. I created a new uml project.
    3. I created new classes in the java web project.
    4. I created a new "class diagram" in the uml project.
    PROBLEM:
    1. When I drag one of the classes onto the class diagram screen, nothing happens. That is, when I perform the "drop"...nothing happens.
    (NOTE: when I drag a "package" to the class diagram, a box representing the java package appears... I just cant get this to work for a class(s) )
    QUESTION:
    Should I be able to drag a class (or classes) from my web project src folder onto the UML project's class diagram and have UML representations of the classes appear?

    Hi Shay
    Unfortunately, I cannot view the suggested youtube stuff at work. (I'll try to view it when I get home)
    But, in the meantime, I did kind of get things working...
    After creating the java project and uml project (and initial class diagram), I had to
    1. drag the java packages (containing the classes I wanted diagrammed) onto the root node of the UML project (i.e., located on the left side "navigation" bar). Afterward, the package appeared under the UML project....Then,
    2. One by one I had to drag the individual java classes from the java project onto the root node of the UML project (i.e,. the classes then appeared under their respective packages under the UML project) . Then,
    3. Then, finally, I could drag the java classes (listed under their respective packages under the UML project) onto the class diagram panel, where the rendered properly.
    I dont know if this is supposed to be the way to "reverse engineer" java classes to be part of a UML class diagram... But, it was the only way I found that worked... thus far, anyway.
    Thanks again for reading my post and answering so promptly.... That was much appreciated!
    s

  • TOMCAT NOT LOCATING JAVA CLASSES

    Environment : NT4/JDK1.3.1/TOMCAT3.3
    Application: Javamail
    We are trying to execute a javaapplication, under tomcat/NT. We have tried copying the classes to all sorts of directories but that does not seem to work...the error appears as below
    ++++++++++++++
    Internal Servlet Error:
    org.apache.jasper.JasperException: Unable to compile C:\tomcat\work\DEFAULT\examples\sendMMSMail_1.java:9: Class SendMMSMail not found in import.
    import SendMMSMail;
    ^
    1 error
         at org.apache.tomcat.facade.JasperLiaison.javac(Unknown Source)
         at org.apache.tomcat.facade.JasperLiaison.processJspFile(Unknown Source)
         at org.apache.tomcat.facade.JspInterceptor.requestMap(Unknown Source)
         at org.apache.tomcat.core.ContextManager.processRequest(Unknown Source)
         at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)
         at org.apache.tomcat.core.ContextManager.service(Unknown Source)
         at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown Source)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:484)

    Try to locate the classes you need in a jar file and add the path to this jar in your classpath,reboot and it will possibly work.

  • Than how can i get java class by using it's class file?

    Hi
    After compilation of a java program, it creates a class file.
    After getting class file suppose class file has been deleted.
    Than how can i get java class by using it's class file?
    Thanks in advance.

    get a decompiler and run your class file through it--I'll assume you want the source code back and that you are not trying to recover a missing class file by attempting to use the class file that is missing--if it's missing, then I've not a clue on how to get it back by using what is already missing.
    BTW: many of your compilers have source control--if it does, just restore your missing file.

  • How can i call a VB6 project from my java application using JNI

    hi
    can anyone tell me the procedure of calling a VB6 project from any java application using JNI
    if anyone does know then tell me the detail procedure of doing that. I know that i have to create a dll of that VB6 project then to call it from the java application.
    if anyone know that procedure of creating dll file of an existing VB6 project please reply
    please if anyone know then let me know

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • External USB not recognized on my iMac (intel) in Disk Utility, Finder as well as in Terminal diskutil list but is listed in System Profile, which includes the location ID of 0xfa400000 / 5.  Can the location ID be used to restore USB identity ?

    My 1TB Seagate external USB not recognized by my iMac (intel) in Disk Utility, nor in Finder as well as in Terminal "diskutil list" but it is listed within the System Profile, which includes the location ID of 0xfa400000 / 5.  Can the location ID be used to restore the identity of my external USB ?

    Hello JNotorious,
    Thank you for using Apple Support Communities.
    For more information, take a look at:
    USB and FireWire Quick Assist
    http://support.apple.com/kb/ht1151
    Have a nice day,
    Mario

  • My aperture library lives on an external hard drive that is corrupt and I can not locate the library. I do have it backed up with TM. How do I safely restore the library from TM to my laptop? I am using the newest version of aperture on my macbook pr

    My aperture library lives on an external hard drive that is corrupt and I can not locate the library. I do have it backed up with TM. How do I safely restore the library from TM to my laptop? I am using the newest version of aperture on my macbook pro.

    Hello Sandra,
    The article linked below details how to go about restoring items from Time Machine in Snow Leopard.
    Mac OS X 10.6: Recovering items using Time Machine and Spotlight
    http://support.apple.com/kb/PH6379
    Sincerely,
    Allen

  • I am using UPK developer 12.1.0 single user. My sofware has crashed and needs reinstallation. Please suggest how can I take back up of my source files. I am unable to open the application and i can not locate the library backup folder on my local machine.

    I am using UPK developer 12.1.0 single user. My sofware has crashed and needs reinstallation. Please suggest how can I take back up of my source files. I am unable to open the application and i can not locate the library backup folder on my local machine.
    Also, does reinstallation takes the back up automatically or the files will be lost. Please help.

    Here are a bunch of scripts to get folder size under all circumstances.  Take your pick.
    https://gallery.technet.microsoft.com/scriptcenter/site/search?query=get%20folder%20size&f%5B0%5D.Value=get%20folder%20size&f%5B0%5D.Type=SearchText&ac=2
    ¯\_(ツ)_/¯

  • Can anyone help i want to call java class using visual basic

    I want to call java class using visual basic and send some arguments to the main class

    Hi,
    I don't know VB, but you can surely launch a command line like :
    javaw.exe mypackage.MyMainClass myArgument1
    Regards

  • Problems creating a Java Array using JNI-HELP!

    Hi,
    I am trying to create a Java Array using JNI.I have posted the code below. The problem is that the oth element is added correctly to the Array but when the JVM gets to the next element...it goes for a toss. It is not able to create a new instance of the object in GetUGEntity() function...there seems to be some problem in creating a new instance of the object!
    Can somebody help me with this?
    jobject GetUGEntity(JNIEnv *env, UF_DISP_j3d_entity_t* entity_list)
         int numVerts=0, numStrips=0;
         jfieldID fid;
         jdoubleArray jTransform=NULL;
         jstring jstrName=NULL;
         jdoubleArray jNormals=NULL;
         //Init an Entity object
         cout<< "**Getting New Class Reference...";
         jclass jEntity = env->FindClass("Lcom/wipro/java3d/rmi/Entity;");
         cout << "**got Class reference..."<<endl;
         if (jEntity == NULL)
              return NULL;
         cout<<"Creating new object instance...";
         jmethodID mIDInit = env->GetMethodID(jEntity, "<init>", "()V");
         cout<<"Got java method id...";
         jobject javaObj = env->NewObject(jEntity, mIDInit);
         if (javaObj==NULL)
              return NULL;
         cout << "Created!" << endl;
         //Entity ID
         cout<< "**Setting eid...";
         fid=env->GetFieldID(jEntity,"eid","I");
         jint eid = (jint)(entity_list)->eid;
         env->SetIntField(javaObj, fid, eid);
         //env->DeleteLocalRef(eid);
         cout << "Done!" << endl;
         cout << "Done!" << endl;
         cout<< "**Returning jobject...";
         return javaObj;
    jobjectArray createJArray(JNIEnv* env, UF_DISP_j3d_entity_t** entity_list, int noOfEntities )
         UF_DISP_j3d_entity_t* tempVar=NULL;
         cout<<"*Creating Jobjectarray...";
         jobjectArray jEntityArray = (jobjectArray) env->NewObjectArray(noOfEntities,
              env->FindClass("Lcom/wipro/java3d/rmi/Entity;"),NULL);
         cout<<"Created!"<<endl;
         for(int i=0; i<noOfEntities;++i)
              tempVar = &(*entity_list);
              if (tempVar !=NULL)
                   cout<<"*Trying to get Entity...."<<endl;
                   jobject jEntity = GetUGEntity(env, tempVar);
                   if (jEntity!= NULL)
                        cout<<"Got Entity!" <<endl;
                        cout <<"*Setting Array Element....";
                        env->SetObjectArrayElement(jEntityArray, i, jEntity);
                        cout << "Done!" << endl;
                   else
                        printf("ERROR: Did not get Entity Reference");
              else
                   printf("ERROR: Got a NULL Reference!");
         return jEntityArray;

    Hi Deepak,
    Could you please let us know upto which line your code is going safe. Try printing the value in the structure before you send that to the method GetUGEntity().
    I am not too sure that would be a problem. But I have faced a problem like this, wherein I tried to access a structure for which I have not allocated memory and hence got exception because of that.
    Since your JNI code seems to be error free, I got doubt on your C part. Sorry.
    Dhamo.

  • Cannot locate Java class oracle.tip.adapter.db.DBWriteInteractionSpec

    I have created a BPEL process in which i have used DB Adapter when i try to deploy the soa suite coposite i am getting the following error.
    [09:36:10 PM] Error deploying archive sca_TicketBooking_rev1.0.jar to partition "default" on server soa_server1 [http://utl-7c8735e613f:8001]
    [09:36:10 PM] HTTP error code returned [500]
    [09:36:10 PM] Error message from server:
    There was an error deploying the composite on soa_server1: [JCABinding] [TicketBooking.TicketBooking/1.0]Unable to complete unload due to: Cannot locate Java class oracle.tip.adapter.db.DBWriteInteractionSpec: Cannot locate Java class oracle.tip.adapter.db.DBWriteInteractionSpec.
    [09:36:10 PM] Check server log for more details.
    [09:36:10 PM] Error deploying archive sca_TicketBooking_rev1.0.jar to partition "default" on server soa_server1 [http://utl-7c8735e613f:8001]
    [09:36:10 PM] #### Deployment incomplete. ####
    [09:36:10 PM] Error deploying archive file:/D:/Personal/OracleWork/RnDProjects/TicketBooking/TicketBooking/deploy/sca_TicketBooking_rev1.0.jar
    (oracle.tip.tools.ide.fabric.deploy.common.SOARemoteDeployer)
    I already created the data source and JNDI Name in the DBAdapter but still getting the error while deploying the application.
    One mistake that i think i have made after creating the data source now the DBAdapter.rar file taking the path as follows.
    Source Path:     C:\ Oracle\ Middleware\ Oracle_SOA1\ soa\ connectors\ was\ DbAdapter. rar
    Deployment Plan: C:\ Oracle\ Middleware\ Oracle_SOA1\ soa\ connectors\ was\ Plan. xml
    initially the path was as follows:
    Source Path:     C:\ Oracle\ Middleware\ Oracle_SOA1\ soa\ connectors\ DbAdapter. rar
    Deployment Plan: C:\ Oracle\ Middleware\ Oracle_SOA1\ soa\ connectors\ Plan. xml
    Please help me i have googled a lot but can't find the answer anywhere.
    Thanks in advance

    Mate ,
    Just check the health status and state of DB Adapter in the deployments of WLAdminConsole.
    If its inactive , redeploy and update it ,also make sure its targeted to the right server.

  • Tomcat can't locate my class files

    Tomcat can't locat my class file for my javabeans in a jsp page.
    (Tomcat 4.1.24/windows XP)
    I have created inside of webapps a directory thesis and also the WEB-INF\classes and WEB-INF\lib. I don't know what should I put in web.xml so it is basically almost empty.
    this is the error I get where Searcher is my javabean:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\thesis\search_jsp.java:89: cannot resolve symbol
    [javac] symbol : class Searcher
    [javac] location: class org.apache.jsp.search_jsp
    [javac] Searcher seek = null;
    [javac] ^
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\thesis\search_jsp.java:91: cannot resolve symbol
    [javac] symbol : class Searcher
    [javac] location: class org.apache.jsp.search_jsp
    [javac] seek = (Searcher) pageContext.getAttribute("seek", PageContext.PAGE_SCOPE);
    [javac] ^
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\thesis\search_jsp.java:94: cannot resolve symbol
    [javac] symbol : class Searcher
    [javac] location: class org.apache.jsp.search_jsp
    [javac] seek = (Searcher) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "Searcher");
    [javac] ^
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\thesis\search_jsp.java:111: cannot resolve symbol
    [javac] symbol : class Searcher
    [javac] location: class org.apache.jsp.search_jsp
    [javac] out.print(JspRuntimeLibrary.toString((((Searcher)pageContext.findAttribute("seek")).getAnalyze())));
    [javac] ^
    [javac] 4 errors
         at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
         at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
         at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
         at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:536)

    did you create the Searcher class? if so stick it in a package and put it under your web-inf directory. then use an <%@ page import="" %> statement to import the code.
    if you didn't create the class is it in some jar library you downloaded? if so stick the jar file in your web-inf/lib folder.
    -S-

  • Can not find Main Class - Can't Run Application

    I have at this for a while and it is drivng me crazy... I have an application that I want execute in a bat file. I have checked the runtime environment by executing java and javaw, both which give option on error messages. I have set the classpath to point too the class subdirectory. Here it is.., Every time I execute the bath file or execute the javaw command, I get the "Can not find main class" message.
    I am using XP ...
    Help please...
    Thanks for all your help.

    when you set the classpath I presume you mean that your running java or javaw as:
    javaw.exe -cp %classpath%;.;c:\library\myfiles com.mycomp.myapp.MainClassIf your using a jar then you must specify the jar in the class path.
    Don't presume it will find the jar. Other than that, you will have
    to provide more details.

  • Can not locate driver download page.

    Can not locate driver download page.
    Officejet Pro 8500 A909a
    MS Vista Ultimate 64 Bit.
    When using my Linux PC to try and locate drivers for another PC, the website just keeps sending me in circles and never displays the drivers to download.  Seems like in the past this has been a problem too.  This occures with latest version of Firefox-37.0.1 and the current version of Chromium-37.0.2062.120 Built on Debian 7.6, running on Debian 7.8 (281580) (64-bit).
    Navigate to hp.com
    Select: Support | Download Drivers
    Under 'Drivers and Downloads' tab
    - enter product id: officejet pro 8500 A909a
    - Select 'Go'
     Expand the '+' that lists one link and select it.
    None of the following links give a driver download!
    - Troubleshooting
    - How To
    - Product Info.
    - Users Guide
    - Video Tutorials
    - More Options
    Maybe one of the options should be 'Driver Downloads'.
    Just my $.02.
    This question was solved.
    View Solution.

    Hi,
    Many links in there. Please use the following direct driver (for Windows all):
       http://ftp.hp.com/pub/softlib/software12/COL31041/mp-110033-2/OJ_AIO_P8500_A909_Full_Win_WW_140_408-...
    (Note: Many printers for the whole 8500 series use same drivers).
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

Maybe you are looking for

  • Key figure non-cumulative/ Inflow / Outflow

    On the tab page Aggregation of a Key-figure, you are able to choose non-Cumulative values with in- and out-flow. What is the exact function of the in- and out-flow fields?

  • BDC not creating documents for J1is

    Dear All, I have written BDC for tcode - J1is but it is not creating official excise documents when i upload the data with BDC. But when we do manually it is creating official excise documents perfectly. Internal documents are generated both the case

  • Event handling and jeditor

    HI, I am having a problem and tied down just because of this. I have an action listener code that is executed when button is clicked, and here what i do in that JeditorPane.setPage(URL url) callToMethod2(); Method2 some calculation and when i check t

  • My Subscription is now cancelled

    Hi All I have just received a notice to say that MY SUBSCRIPTION IS NOW CANCELLED. The only problem that I have is that I HAVE NEVER HAD A SUBSCRIPTION. Very strange. I do pay as I go to make telephone calls which when it is near a bottom amount it a

  • How to view performance in Oracle10gAS Portal

    hi to all I need your help out there. Do anyone noe how to view all the performance logs in Oracle10gAS Portal? It means in Oracle10gAS how can i see all the no. of hit counter for per page, the most popular website/portlet at the end of the day, por