How to link javabean with c using jni

I am doing a program about using jni to load a c .But when I was using jni with javabean, under tomcat, it didn't work . Please show me a way.
my code�F
/////TestJNI.java
package com.jsp;
public class TestJNI{ 
private byte[] cbuff={49,48,48,48,100,0x0};
public byte getchar(int i)
return cbuff;
public native int GetRandom(byte[] pRandom,int j);
static
System.loadLibrary( "TestJNI" );
public void Execute()
int r=GetRandom(cbuff,4);
/////BeanTest.jsp
<jsp:useBean id="TestJNI" scope="session" class="com.jsp.TestJNI">
</jsp:useBean>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%=TestJNI.getchar(4)%>;
<%
TestJNI.Execute();
%>
<br>
<%=TestJNI.getchar(4)%>
</body>
</html>
//////TestJNI.cpp
//TestJNI.cpp
#include"com_jsp_TestJNI.h"
#include<stdio.h>
JNIEXPORT jint JNICALL Java_com_jsp_TestJNI_GetRandom (JNIEnv *env,  jclass,  jbyteArray  pRandom,  jint  j)   
jsize size = env->GetArrayLength((jarray)pRandom);
jbyte *arrayBody    =  (env)->GetByteArrayElements(pRandom,NULL); 
jbyte buff[5];
buff[0]=31;
buff[1]=32;
buff[2]=33;
buff[3]=34;
buff[4]=35;
env->SetByteArrayRegion(pRandom,0,5,buff); // set byte[] values
return (jint)100;
I put TestJNI.class under directory com/jsp/�Cput TestJNI.dll under classes directory�B
erro information�F
java.lang.NoClassDefFoundError
     sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     java.lang.reflect.Constructor.newInstance(Constructor.java:274)
     java.lang.Class.newInstance0(Class.java:308)
     java.lang.Class.newInstance(Class.java:261)
     java.beans.Beans.instantiate(Beans.java:204)
     java.beans.Beans.instantiate(Beans.java:48)
     org.apache.jsp.beantest_jsp._jspService(beantest_jsp.java:45)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

You can test a normal Class(not a JNI call) invoking in BeanTest.jsp
1.If there is no problem it's most likely you can't get library path set in server enviroment
(here: System.loadLibrary( "TestJNI" ); )
2.If the same exception occurs ,you should check your webapps tree structure.
please refer to the 2 links if you can read chinese
http://www.chinaitlab.com/www/news/article_show.asp?id=36677
http://www.javaresearch.org/article/showarticle.jsp?column=1&thread=4653

Similar Messages

  • How to link ODI with ESB???

    Hi,
    I need to know how to link ODI with ESB(Enterprise Service Bus)....
    should i expose ODI as a web service or is there any other way to link these two...
    please reply me asap its very urgent...
    Regards,

    I'm also interested on this.
    I don't know very much about ODI, but could point the following:
    1 - Your datasource could be exposed as a web service, as you suggested, and be exposed for ESB to consume.
    2 - ESB can connect to your data source (not ODI, but the datasource the ODI act on) using a DBAdapter.
    3 - ESB can send a JMS message that can be consumed by an ODI JMS based datasource (I'm not sure)
    4 - ODI can have a Web Service based datasource that points to a web service exposed by ESB.
    When I see ODI Topology Manager, I can identify these options.
    Denis

  • How to:  Linking Material with Assortment and Plant

    What are the ways to link 0MATERIAL with assortments and 0PLANT?
    Right now I have:  0RT_WRSZ, which links the Plant with the assortment
    How do I link that with 0MATERIAL using the WLK1 table?
    Thanks,
    Chris

    Try 0RT_WLK1

  • How to link asset with purchase order and PO Item.

    Hello,
           I have to generate a report which contains columns
    Asset No , po no(ebeln) ,PO Item(ebelp),Material no etc
    My query is how to link asset with purchase order and      PO Item.
    I am selecting asset and po no. from anla  but how to get
    po item no(ebelp)?
    po line item is important in this report because every line item has differrent asset and material no.
    i tried to match asset no in mseg table but i am not getting asset no in mseg .
    how should i proceed ?

    Thanks Thomas & Srimanta for the quick response.
    When I checked EKKN table by entering PO there is no asset no. in anln1 field.
    Also I would like to add that, In me23n for a PO, account assignment category we are entering 'F' for internal order settlement.
    Where can i find the link between asset and po no(ebeln) and po item(ebelp)?
    Regards,
    Rachel
    Edited by: Rachel on Aug 11, 2008 7:23 AM

  • How Achieve timedseries calculations with out using AGO And ToDate function

    Hi,,
    1)
    How Achieve timedseries calculations with out using AGO And ToDate functionion
    this question asking in interview ..is it possible..?
    if yes please response as soon as possible..
    2) i have 2 cloumns Product and value...
    client requirement is they need ranks based on Value ..in dashboard .using dashboard prompt..edit box...if user enter any number (ex :5 ) report should show top 5 ranks if he enter 20 should be top 20 ranks..
    how to achive this ?
    thanks,
    raj

    Consider yor first question:
    1. Yes, we can create timeseries measures without using AGO and TODATE
    1. Create ALIAS of fact tabe in the physical layer
    2. Join the Time id from the ALIAS fact table with the YAGO_MONTH_ID column from your time dimension table (For calculating Year Ago variants) similarly join with MAGO_MONTH_ID column for Month Ago measures.
    3.Pull the ALIAS tables as an additional Logical table source in the Lgical layer
    4.Keep the mapping of the columns from the ALIAS table as its is
    5. For e.g If you pick Revenue from the Year Ago Alias table it will give you the "Prior Year Revenue"
    See if this helps you

  • How can I scan with mavericks using Epsom printer

    How can I scan with mavericks using Epsom printer

    Some users have had success using Image Capture in the Applications folder - although it doesn't seem to work for everybody. Worth a try.

  • How to link a native library that jni method needs in Linux?

    I'm trying to convert a simple driver using JNI to java in Linux. The driver uses native methods (written in C) that are implemented in a static library eth.a, so I don't have a source code for these methods. Everything works fine when pure C-code program is used, however when I'm trying to use java-program where native methods (which naturally need these driver-functions in eth.a) I got a following error:
    LibPath= /usr/kahvi/ioapi/
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/kahvi/ioapi/libEthDriver.so: /usr/kahvi/ioapi/libEthDriver.so: undefined symbol: DDI_DevOpenNode
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1354)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1278)
    at java.lang.Runtime.loadLibrary0(Runtime.java:466)
    at java.lang.System.loadLibrary(System.java:771)
    at EthernetDriver.<clinit>(EthernetDriver.java:89)
    DDI_DevOpenNode is the first method that program uses from eth.a -library.
    I have tried several different linking option such as:
    gcc -o libEthDriver.so -DLINUX -DETH_UNIX -shared -Wl,-soname,libEthDriver.so -I/usr/jdk1.2.2/include -I/usr/jdk1.2.2/include/linux/ -I/usr/kahvi/ioapi/inc/ EthernetDriver.c -static -lc
    eth.a is located in /inc directory and LD_LOAD_LIBRARY is used properly.
    If I include eth.a directly to compilation options (which I'm not sure how to do), the error message is following:
    LibPath= /usr/kahvi/ioapi/
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/kahvi/ioapi/libEthDriver.so: eth.a: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1354)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1278)
    at java.lang.Runtime.loadLibrary0(Runtime.java:466)
    at java.lang.System.loadLibrary(System.java:771)
    at EthernetDriver.<clinit>(EthernetDriver.java:89)
    So the basic problem is quite simple, how to implement a JNI-method that uses a functions implemented in another library?
    Any help is very much appreciated, because I have tried to solve this a few days and I don't have clues how to move on.
    -ML

    What people are trying to point out is that you can't use that static library to resolve native methods. Native methods resolve to shared libraries. So you need to write a shared library that links with the static library and wraps the functions you want to export from the shared library. Check your compiler/linker documentation on how to build a shared library. (IIRC, something like -shared for gcc).
    God bless,
    -Toby Reyelts
    Check out the free, open-source JNI toolkit, Jace - http://jace.reyelts.com/jace

  • How to instantiate a java object (using JNI)?(n'more)

    hey bschauwe, thanks for your last post, you were guessing but your 4th guess was right on the money of how id like to do it.
    "4. An alternative way to return data to java from C is to instantiate a java object (using JNI), then use JNI to call that object's setters, then return the object at the end of the C routine."
    I know now how to get the object's setters, I am just unsure how to instantiate a java object from the native C code using JNI. Also you said to returnt he object at the end of the c routine, that is just a good ol' return statement right? no other functions to release memory or anything are needed? So basically it would be something like:
    JNIEXPORT jobject retObj JNICALL Java_AbfaRegion_getJSourceData
      (JNIEnv *env, jobject thisObj)
            //instantiate the java object on retObj????
            //call setters with values from the c structures...
            //return retObj??? no other memory releasing needed?
    }Thanks again for all your help,
    Shane

    K sounds straight forward enough, the index in my book had nothing on <init> and I wasnt aware of the NewObject call. So my final (well for demonstration purposes) code should look something like:
    JNIEXPORT jobject retObj JNICALL Java_AbfaRegion_getJSourceData
      (JNIEnv *env, jobject thisObj)
         jclass clazz;
         jclass clazzTemp;
         jmethodID mid;
         jint val;
         jobject tempObj;
            //first instanciate the object
         clazz = (*env)->GetObjectClass(env, retObj);
         mid  = (*env)->GetMethodID(env, clazz, "<init>", "()V");     
            //Get Object
         tempObj = (*env)->NewObject(env, clazz, mid);
            //get Class reference to instantiated class
         clazzTemp = (*env)->GetObjectClass(env, tempObj);
            //Start calling setters to set the object up.
         mid = (*env)->GetMethodID(env, clazzTemp, "SetHeight", "(I)V");
         (*env)->CallVoidMethod(env,tempObj, mid, struct->myHeight);
            //set more members ...
            //return the object back to java with its members filled out.
            //before returning do I need to call (*env)->DeleteLocalRef(tempObj); ??
            return tempObj;
    }So is this how i do it for a function that is nativly defined as:
    public native JSources getJSourceData();?
    if this is right, then im cooking, and cannot thank you enough!
    -Shane

  • How to link bindvariable with ViewAccessor to make it ADF Input with LOV

    I have create a view object by sql query in which i have two bind variables. I want to create a search form by these two bind variables as search criteria so i drag "Execute with Params" operation from Viewobject Data Control to a jspx page as a ADF Search Form. Now i want to create these two parameters as a ADF Input LOV so i changed control type in view Object for these two bind variables but i am not able to fine how to attach viewaccessor with it for data source. Kindly help me.

    Hi,
    in this case - if th ebind variables are not based on an attribute that has a LOV defined - you replace the components in the input form. To do this, remove the input text field and drag the attribute (the argument) onto the form again. Choose select one choice to create a drop down and then map it to the VO that providesthe values. Note that this doesn't create a LOV binding so you use lists for this.
    Frank

  • How to link event with program?

    My program z_report_idoc is called in background job using event ‘OM20000013’ created in SM62.
    Code uses FM: CALL FUNCTION ‘BP_EVENT_RAISE’
    But i dont know how it is linked to program.
    Can anyone have idea how to link program and where i can view this linkage.
    Regards,
    Gurmukh

    1. Go to transaction SWELS and swich on the event.
    2. Then go to vd01 and create customer.
    3. Go to transaction SWELS and swich off the event.
    4. Go to transaction SWEL. it will displays the events regarding your process.

  • How to set JavaBean in JSP using JavaScript function

    Hello,
    When a user clicks on an item, I want to execute a JavaScript function. Within that function, I want to set specific JavaBeans (<jsp:setProperty... />) within my JSP page.
    Can anyone tell me how to do this or where I can find examples on how to set JavaBeans in a JSP page using JavaScript?
    Thanks.
    Pat

    try this:
    your.jsp
    <html>
    <SCRIPT>function buttonClick()
    {document.compform.submit();}
    </SCRIPT>
    <body>
    <form name=compform method=post action='your.jsp'>
    <%
    //write your code which you want to execute once the button is submitted
    String submit;
    submit=request.getParameter("mysubmit");
    if ((submit != null) && (! submit.equals("")))
    %>
    <input type=hidden name=mysubmit value="submit">
    <input type=button value=add onclick='buttonClick()'>
    </form></body></html>

  • How to link Product_guid with frg_guid.

    Hi Guys,
            Can someone pls tell me how to relate or link  the product_guid with the settype table field FRG_GUID.
    how the link is made in CRM.
    Regards,
    Vamsi

    Hello Vamsi,
    Check table COMM_PR_FRG_REL.
    Regards,
    Frédéric

  • How to link iCal with Outlook for Mac 2011?

    Hello Apple people.
    Just got my MacBook Pro (Late 2011) and am trying to enable Outlook to link with iCal so I can get meeting alerts on my iPhone 4.  I prefer using Outlook for email and calendar usage.  I've linked it with iCal, but can't get information to transfer between the two.  Any thoughts?
    Mota_D

    Greetings,
    Before doing any troubleshooting I would recommend backing up your data (http://support.apple.com/kb/HT1553).  Calendars and contacts tend to be important to people and are complex in nature which increases the chances of mishaps.
    Make sure you have installed all software updates from Apple by going to Apple > Software Update.
    Make sure you have installed all software updates for your Microsoft software (Open Outlook and then go to Help > Check for Updates).
    Restart your computer (Apple Menu > Restart).
    The first thing I would suggest is following all steps in this article: http://support.microsoft.com/kb/2452489.
    Once this is complete you should see the calendars you have added to Outlook when you click the "Calendars" button in iCal under the "On My Mac" section.
    If the calendars do not show up reset Sync Services: http://support.apple.com/kb/TS1627.
    Hope that helps.

  • How to Integrate XI with Peoplesoft using iWay Adapter

    hi Friends,
            This is Sreeni. I want to use iWay adapter for integrate Peoplesoft with XI.
    can you please help me in this way.

    Hi,
    There is a series of blogs that address this same area. Please look into them. they should surely help,
    /people/yomeshp.sharma/blog/2006/06/01/integrating-jdedwards-system-with-xi-using-iway-adapter-part--i - Part I
    /people/yomeshp.sharma/blog/2006/06/01/integrating-jdedwards-system-with-xi-using-iway-adapter-part--ii - Part II
    /people/yomeshp.sharma/blog/2006/05/31/integrating-jdedwards-system-with-xi-using-iway-adapter-part--iii - Part III
    Regards
    Bhavesh

  • How to link oracle with xml

    i want to know the coding to link oracle with xml.tq.

    You're going to need to expand a little on this question, since I'm not quite sure what you mean by "link". What kind of problem are you trying to solve, so we can help... Thanks.
    If you're just starting out with Oracle and XML, a book like Building Oracle XML Applications or the Oracle XML Handbook might be the right place to start, in addition to our own online documentation at http://download.oracle.com/otndoc/oracle9i/901_doc/index.htm

Maybe you are looking for

  • Sending Date parameter  from the form to Report

    Dear Friend Hi everybody, I am sending the date parameter to my report through a form ,and my date format in the form and in the report as follow : DD/MM/YYYY but when I enter the date as 18/1/2004 the system pass this value as follow : 18-JAN-04 but

  • Thinkpad X1 Mouse Issues with USB 3.0 Dock and WIndows 8.1

    I have a new X1 (3444-CUU) that I recently upgraded to Windows 8.1. When I connected to the Thinkpad USB 3.0 Dock, there was an automatic updated of the firmware on the docking station. Everything seems to be working except issues with my Keyboard an

  • Calling a module pool program screen to an executable program

    Hi gurus, I have created a executable program to use selection-screen and want to see my output in module pool program where I have designed table control according to my requirement. How can I call the module-pool program screen from an executable p

  • Problem in receipt stock & Issue stock

    Dear All, I have some problem in inventory cube 0IC_C03. when we execute query for total stock ,total Receipt stock &Total issue stock, we found that total stock is matching with MB5B but issue stock & receipt stock is not matching. Then I added mate

  • Too many nodes in each states

    I'm trying to use JavaFX Composer in Netbeans 6.9 to make a blogging client that is both an editing software and a feed reader. The problem is that I want to be able to switch between different phases/screens, such as one for reading feeds and one fo