Problem calling a method in a servlet witch returns remote ejb

Hi, I have a problem combining servlets ands ejbs, I expose my problem :
What I have :
1 . I have a User table into a SGBD with two attributes login and pass.
2 . I have a UserBean linked to User table with a remote interface
3 . I have a stateless UserSessionBean with a remote interface
4 . I have a UserServlet linked to a jsp page which allows me to add users
5 . I use Jboss
What is working ?
1 - I have a method newUser implemented in my UserSessionBean :
public class UserSessionBean implements SessionBean {
  private SessionContext sessionContext;
  private UserRemoteHome userRemoteHome;
  public void ejbCreate() throws CreateException {
  // Initialize UserRemoteHome
  // Method to add a new user
  public UserRemote newUser(String login, String password) {
        UserRemote newUser = null;
        try {
            newUser = userRemoteHome.create(login, password);
        } catch (RemoteException ex) {
            System.err.println("Error: " + ex);
        } catch (CreateException ex) {
            System.err.println("Error: " + ex);
        return newUser;
}2 - When I test this method with a simple client it works perfectly :
public class TestEJB {
    public static void main(String[] args) {
        Context initialCtx;
        try {
            // Create JNDI context
            // Context initialization
            // Narrow UserSessionHome
            // Create UserSession
            UserSession session = sessionHome.create();
            // Test create
            UserRemote newUser = session.newUser("pierre", "hemici");
            if (newUser != null) {
                System.out.println(newUser.printMe());
        } catch (Exception e) {
            System.err.println("Error: " + e);
            e.printStackTrace();
Result : I got the newUser printed on STDOUT and I check in the User table (in the SGBD) if the new user has been created.
What I want ?
I want to call the newUser method from the UserServlet and use the RemoteUser returned by the method.
What I do ?
The jsp :
1 - I have a jsp page where a get information about the new user to create
2 - I put the login parameter and the password parameter into the request
3 - I call the UserServlet when the button "add" is pressed on the jsp page.
The Servlet :
1 - I have a method doInsert which call the newUser method :
public class UserServlet extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html";
    // EJB Context
    InitialContext ejbCtx;
    // Session bean
    UserSession userSession;
    public void init() throws ServletException {
        try {
            // Open JNDI context (the same as TestClient context)
            // Get UserSession Home
            // Create UserSession
            userSession = userSessionHome.create();
        } catch (NamingException ex) {
            System.out.println("Error: " + ex);
        } catch (RemoteException ex) {
            System.out.println("Error: " + ex);
        } catch (CreateException ex) {
            System.out.println("Error: " + ex);
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws
            ServletException, IOException {
     * Does insertion of the new user in the database.
    public void doInsert(HttpServletRequest req, HttpServletResponse resp) throws
            ServletException, IOException {
        try {
            // Get parameters to create the newUser
            String login = req.getParameter("login");
            String password = req.getParameter("password");
           // Create the newUser
            System.out.println("Calling newUser before");
            UserRemote user = userSession.newUser(login, password);
            System.out.println("Calling newUser after");
        } catch (Exception e) {
    // Clean up resources
    public void destroy() {
Result :
When I run my jsp page and click on the "add" button, I got the message "Calling newUser before" printed in STDOUT and the error message :
ERROR [[userservlet]] Servlet.service() for servlet userservlet threw exception
javax.servlet.ServletException: loader constraints violated when linking javax/ejb/Handle class
     at noumea.user.UserServlet.service(UserServlet.java:112)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
     at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
     at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
     at java.lang.Thread.run(Thread.java:534)
Constat :
I checked into my SGBD and the new user has been created.
The error appears only when the method return Remote ejbs, if I return simples objects (Strings, int..) it works.
What can I do to resolve this problem ?
Thank you.

"Why do you want to servlet to gain access to another EJB through the stateless session bean. Why cant the servlet call it directly ?"
Because I want to access to the informations included in the entity bean UserBean (which is remote).
You said that it is a bad design, but how can I access to my UserBean ejbs from the session bean if I don't do that ?
For example I want a List of all users to be seen in a jsp page :
1 - I call the method getUserList which returnsan ArrayList of UserRemote.
2 - I iterate over the ArrayList to get the users parameters to be seen.
As the other example (newUser), when I do
ArrayList users = (ArrayList) userSession.getUserList(); with the simple client it works, but in the servlet I got the same error.
But, if I call directly the findAll method (as you'are saying) in the servlet
ArrayList users = (ArrayList) userRemoteHome.findAll(); it works...
I think that if my servlet calls directly entity ejbs, I don't need UserSession bean anymore. Is that right ?
I precise that my design is this :
jsp -> servlet -> session bean -> entity bean -> sgbd
Is that a bad design ? Do I need the session bean anymore ?
Thank you.

Similar Messages

  • Is it possible to call a method in a servlet from  a java script ?

    I need to do a dynamic html page . In the page i select some things and then these things must communicate whit a servlet because the servlet will do some DB querys and update the same webpage.
    So is it possible to actually call a method of a servlet from a java script? i want to do something that looks like this page:
    http://www.hebdo.net/v5/search/search.asp?rubno=4000&cregion=1011&sid=69DHOTQ30307151
    So when u select something in the first list the secodn list automaticly updates.
    thank you very much

    You can
    1. load all the options when loading the page and
    set second selection options when user selected
    the first; or
    2. reload the page when user select first selection
    by 'onChange' event; or
    3. using iframe so you only need to reload part of
    the page.

  • Calling a method from another servlet? very beginner

    I am going to try to explain what I want to do so just be patient please.
    I want to call a method in a seperate servlet to connect and release my connection pool - How do I do this?
    This is what I have been trying... help
    dbPOOL.class
    package DATABASE;
    import javax.naming.*;
    import javax.sql.*;
    import java.sql.*;
    import java.util.*;
    public class dbPOOL {
      Connection con;
      private boolean conFree = true;
      private String dbName = "java:comp/env/jdbc/connectDB";
      public dbPOOL() throws Exception {
           try  {              
                    InitialContext ic = new InitialContext();
                    DataSource ds = (DataSource) ic.lookup(dbName);
                    con =  ds.getConnection();    
         } catch (Exception ex) { throw new Exception("Couldn't open connection to database: " + ex.getMessage());
      public void remove () {
             try {
                 con.close();
            } catch (SQLException ex) { System.out.println(ex.getMessage());}
      protected synchronized Connection getConnection() {
             while (conFree == false) {
                     try {
                             wait();
                     } catch (InterruptedException e) {
                  conFree = false;
                  notify();
                  return con;
        protected synchronized void releaseConnection() {
            while (conFree == true) {
                     try {
                        wait();
                     } catch (InterruptedException e) {
                  conFree = true;
                  notify();
    }and my worker servlet connTest
    package DATABASE;
    import javax.naming.*;
    import javax.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    public class connTest extends HttpServlet {  
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, SQLException, IOException {
             try {
                    String selectStatement = "select * " + "from mt.Evendale_Web_Groups";
                    getConnection();
                    PreparedStatement prepStmt = con.prepareStatement(selectStatement);
                    ResultSet rs = prepStmt.executeQuery();
                    while (rs.next()) {
                       groupList gl = new groupList(rs.getString(1), rs.getString(2), rs.getString(3));
                    prepStmt.close();
            } catch (SQLException ex) { throw Exception(ex.getMessage());}
                releaseConnection();
    }When I try to compile the connTest servlet - I keep getting cannot find symbols errors on the methods. How do I fix this?

    Which errors exactly?
    Try something like this:
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    dbPOOL db = null;     
    try {               
    String selectStatement = "select * " + "from mt.Evendale_Web_Groups";
    db = new dbPOOL();        
    Connection con = db.getConnection();               
    PreparedStatement prepStmt = con.prepareStatement(selectStatement);               
    ResultSet rs = prepStmt.executeQuery();               
    while (rs.next()) {                                    
       // process your rs                      
    prepStmt.close();           
    } catch (Exception ex) {
    } finally {
        if (db != null)
             db.releaseConnection();             
    }Simply change the package name to something else. But don't forget to import your dbPOOL class since it is now located in a diff package. Also be aware of coding standards when naming your classes and packages.

  • How to call a method in the servlet from an applet

    I want to get the data for the applet from the servlet.
    How to call a method that exits in the servlet from the applet? I want to use http protocol to do this.
    Any suggestions? Please help.
    thanks

    Now that Web Services is around, I'd look at possibly implement a Web Service call in your applet, which can then be given back any object(s) on return. Set up your server side to handle Web Service calls. In this way, you can break the applet out into an application should you want to (with very little work) and it will still function the same

  • Problems calling a method from a different class

    Like many programmers, I'm having a go at making my own chat room. All has been going well so far, however I am having trouble calling the method which connects the client to the server, from the method which actually starts the server.
    The method for starting the server:
    public static void serverStart () throws IOException {
            new Thread () {
            public void run() {
                try {
                    ServerSocket serverSock = new ServerSocket (client.serverPort);
                while (true) {
                    Socket serverClient = serverSock.accept ();
                    ChatHandler handler = new ChatHandler(serverClient);
                    handler.start ();
                } catch (IOException ex) {     
                    connectTo.handleIOException(ex);     
            }.start();
            try {
                connectTo.start();
            } catch (IOException ex) {
                connectTo.handleIOException(ex);
        }The part of interest is the "connectTo.start()" line, as this is the one which calls a method in the class connectToMethod which tells the client to connect to this newly started server. Now for the client connection code:
    public synchronized void start () throws IOException {
          if (listener == null) {
              Socket socket = new Socket (client.serverAddr, client.serverPort);
              try {
                  dataIn = new DataInputStream
                          (new BufferedInputStream (socket.getInputStream ()));
                  dataOut = new DataOutputStream
                          (new BufferedOutputStream (socket.getOutputStream ()));
              } catch (IOException ex) {
              socket.close ();
              throw ex;
          listener = new Thread (this);
          listener.start ();
      }Now when the server starts, it should automatically start the connection method "start()" and connect to itself. However I am getting a NullPointerException error at the line "connectTo.start();" from the server code. The server and connection client actually work separately, just not when I try to connect from the server itself. I have tried a few ways of getting around this problem, all without success. If anyone could give some input on what might be wrong, or a possible way to fix it, I'd be very grateful.

    Sorry, connectTo comes from:
    connectToMethod connectTo = new
    connectToMethod();
    That doesn't necessarily mean this variable reference is the same one as in the code where the NullPointerException was thrown though.
    Or the exception was thrown inside the start() method. The runtime isn't lying to you. You have a null reference (pointer) where it says you do.

  • Problem calling a method which takes a parameter from a table

    Hi guys,
    I'm very new to jsf and hope you can help me out.
    On my page i'm generating a list, which is working fine. now i want to add some commandLinks to the list entries. on click, i want to execute a bean method, which takes a parameter from the list, generates a picture and displays it on my page.
    here's a piece of code thats already working:
    <rich:dataTable var="data" value="#{pathwayBean.orgList}">
    <rich:columnGroup>     
            <rich:column>     
               <h:outputText value="#{data.name}" />
         </rich:column>
    </rich:columnGroup>
    </rich:dataTable>now, i want to replace the outputText with a commandLink, and execute a method with {data.id} as parameter. Unfortunately, the commandLink property "action" can only call bean methods with no parameter, or is that wrong?
    Thanks in advance,
    Alex

    use actionlistener.
    here a typical code that works fine for me:
    (JSF 1.2)
    //Java
    private Integer selectedItemId=null;
         public void selectItem(ActionEvent event) {
              // Find the UIParameter component by expression
              UIParameter component = (UIParameter) event.getComponent().findComponent("itemId");
              // parse the value of the UIParameter component
              try {
                   selectedItemId = Integer.parseInt(component.getValue().toString());
                   // find itemBean here using selectedItemId
              } catch (Exception e) {
                   logger.error(e, e);
              logger.info(" +++ selectedItemId =" + selectedItemId);
         public String viewItem() {
                 //create view beans here
                 return "itemView";//return appropriate view.
    //JSF
    <h:column>
                             <h:commandLink     id="View"
                                                 action="#{itemListBean.viewItem}"
                                                       actionListener="#{itemListBean.selectItem}">
                                  <h:outputText value="select"/>
                                  <f:param id="itemId" name="itemId" value="#{itemBean.id}"/>
                             </h:commandLink>
                     </h:column>

  • Problem calling Java method from JavaScript in JSP / ADF

    Hi all,
    In my JavaScript onMouseUp() function, I need to call a method on my Java backing bean. How is this done? Info on the web indicates a static Java method can be called by simply "package.class.staticMethod(...)". but when I put the statement
    "jsf.backing.GlobalRetriever.createBasemap(affectedLayer);"
    I get an error message "jsf is undefined".
    The functionality I'm trying to get is: I have a custom slider control and based on its value, I want to call oracle map viewer specifying a map extent of the (current extent / slider value) to do a zoom in/out. In addition, the slider uses a onMouseMove() function to change the size of the image display so it looks like a dynamic zoom in/out.
    Please assist or let me know if I can provide some additional information. Thanks in advance.
    Jim Greetham

    No. The Java and Javascript in a Faces application are really working in two different universes.
    Java is running on the server. It generates HTML (and sometimes even Javascript) and sends that to the client machine. That's where all your backing beans are.
    Javascript runs directly in the browser. There's no way anything on the server can have access to anything you define in Javascript, unless you explicitly send that information back to the server, either via standard form submission (which only works when someone presses a "Submit" button) or via an Ajax-type call. So otherwise, nothing you define in Javascript will ever be available to a backing bean.

  • Changing an object by calling a method in another class that returns nothin

    How can a method like for example Arrays.sort(Object[] a) work? The method has a return statement void, so how come the array passed into the method "magically" end up as being sorted when we look at it in another class after having called this method?

    jverd wrote:
    sunfun99 wrote:
    Since references really are more like addresses, jverd's adress-on-pieces-of-paper analogy is the best, but certainly not because the addresses on the pieces of paper are copies of the address (they aren't). We may just be splitting ever finer semantic hairs here, but how is it not a copy of the address?It is a finely split hair - and ultimately just a difference of language use, I think.
    We scribble on pieces of paper and thereby have at least two things to deal with: the scribble, and the location. It is unfortunate, but in English both things are referred to as "the address". The scribble has qualities like "red", "legible" etc, the location has qualities like "distant", "next door to the president": so they do seem to be different things.
    We use "address" for both: "I can't read this address" vs "Go to this address". Children make jokes based on the ambiguity: "How do you spell it."
    But then there's a third thing: the denotation of the location by the scribble. (denotation here == reference/pointing-at/leash/stick etc). It really does seem to be a third thing. (With apologies to Jean Buridan) consider a person who has lat/long coordinates explained to them for the first time and is handed a piece of paper with coordinates on it. They are asked "Do you know who lives here?" and they answer "Yes, I know the person at this address!". Most would say the statement is false - even if it turns out they were handed their own address. Their assertion of knowledge is an assertion about the denotation of the location by the coordinates, not about the location itself.
    So what is copied by a scribe or a photocopy machine when it copies an address? Clearly it's the scribble, not the location. The scribble is duplicated, the location is not. But what about the denotation of the location by the scribble? Not withstanding the above example (and especially in contexts where knowledge and similar concepts are not involved), you could say that the denotation of the location by the scribble is a value. In other words you could hold that two denotations of some location are not just equal but identical iff they denote the same location. (You could, but you needn't.) It is in this sense that the pieces of paper bear, not copies of the address, but the same address.
    (Exactly the same applies to "pointers" ie signposts. If you have two "north pole" signs (1) The are different signs (2) They point to the same place (3) They are two signs bearing one and the same reference.)
    Edited by: pbrockway2 on Mar 15, 2009 12:49 PM

  • Problems calling a method in another class

    I have the following method in a class called recordCalls -
    public static void objectCreated(String type, String name)
            System.out.println("An object of type " + type + " called " + name + " has been created.");
    //       addObjectToPanel(type, name);  
        }I am attempting to call addObjectToPanel(type, name) which is a method inside a class called test.
    I do not want to create an instance of test an call it like test.addObjectToPanel(type, name)
    Is there any other way of doing this.
    Thanks.

    You either have to make the method static, and call
    test.addObjectToPanel or you have to create an
    instance of test and invoke the method on that
    instance.
    I don't know what that class is supposed to do, so I
    don't know which is more appropriate.
    You should name your classes starting with capital
    letters, and Test is a very undescriptive (and hence
    bad) name for that class.I will be chaning the names of everything when the class works.
    Test contains the UI for my program.
    When I run test then my UI is runing, once I run addObjectToPanel from the record calls class it should put images into my UI,
    the problem is that each time the method is run it open up a different UI and adds an image to it instead of just adding the images to the window which is already open.

  • Problem calling applet method using IE

    I've searched through the forum and can't seem to find anything that can help me fix this. I'm trying to call an applet's method using Javascript. This is working fine under Netscape, but not IE. Everything I've read seems to indicate that I'm doing this right, but I'm getting "Object doesn't support this property or method" when I try to call the applet method from IE.
    In this example method, I'm trying to call the applet's countChars method, which should return the length of the string you pass into it. Works under Netscape 6.2, but not IE 6.0
    Here's my applet code:
    import java.lang.String;
    public class test extends java.applet.Applet {
    public static int countChars(String s) {
    return s.length();
    And my HTML
    <HTML>
    <HEAD>
    <script language="Javascript">
    function refreshApplet()
    /*     i = document.forms.myForm.TestApplet.countChars();
         document.forms.myForm.output.value=i; */
         document.forms.myForm.output.value=document.applets["TestApplet"].countChars(document.forms.myForm.input.value);
    </script>
    </HEAD>
    <BODY>
    <APPLET CODE = "test.class" WIDTH = 400 HEIGHT = 400 ALIGN = middle NAME = "TestApplet" scriptable="true">
    </APPLET>
    <br>
    <form name="myForm">
    <input type="text" name="input">
    <input type="button" value="click me" onClick="refreshApplet();">
    <hr>
    <input type="text" name="output">
    </form>
    </BODY>
    </HTML>
    Thanks in advance!
    Craig Drabik
    Sr. Programmer/Analyst
    University at Buffalo

    I have very similar problem, my applet works OK using Netscape (6.2 and 7.0), but with IE 6.0 It only works with windows XP;
    The reported error is "Object doesn't support this property or method"
    Can someone please help me to solve this problem.
    Cheers
    Horus
    This is my code:
    - I call the applet using javaScript and input the method setData with two strings.
    function graphic()
         var dataZenith;
         var dataManual;
         initVariables();
         dataZenith = graphicZENith(); //Call other Javascript functions
         dataManual = graphicManual(); //Call other Javascript functions
         document.AppletOne.setData(dataZenith,dataManual);
    I run the applet with this HTML code:
    <applet NAME="AppletOne" code="Appl.class" width="450" height="450"
    MAYSCRIPT></applet>
    //Applet code/////////////
    import java.awt.*;
    import java.awt.geom.*;
    import java.applet.*;
    import java.util.*;
    public class Appl extends Applet {
         private int [] myArray1 = new int [156];     
         private int [] myArray2 = new int [156];
         private boolean flag = false;
         // maxDataYAxesNumber es usado para dividir el eje de las Y
    public void init()
              setFont(new Font("SansSerif", Font.BOLD, 12));
              setBackground (Color.white);
              setSize(getSize());     
    // Get data and put in an array
    public void setData(String data1, String data2)
              final String DELIMITER = ",";
              final StringTokenizer theTokens1 =
                   new StringTokenizer(data1, DELIMITER);     
              final StringTokenizer theTokens2 =
                   new StringTokenizer(data2, DELIMITER);
              try
                        String dataX = data1;
                        for (int i = 0; i < 156; i++)
                        myArray1[i] = Integer.parseInt(theTokens1.nextToken().trim());
                        myArray2[i] = Integer.parseInt(theTokens2.nextToken().trim());
              catch (NumberFormatException e) {};
              flag = true; //I get the data OK
              repaint();
    public void paint (Graphics g){
    Graphics2D g2d = (Graphics2D)g;
    setData(data1, data2) ;
    if (flag == true)
                   //Call other functions to process the graphic
    else g2d.drawString(" Sorry I can get Data", 100,80);          

  • Problem calling java method from c

    Hi ,
    I'm trying to call a java method from a C program. it gives no error during compilation as well as building the application. but when i tried to create the JVM by running my application it pops up the message "The application failed to start because jvm.dll was not found. Re-installing the application may fix the problem." I tried out setting all the environment variables to include the jvm.dll(PATH set to c:\j2sdk1.4.2_05\bin;c:\j2sdk1.4.2_05\jre\bin). Still got the same message. Then i re-installed java platform once more. Even now i get the same error. I have more than one jvm.dll at locations jre\bin\client and server, oracle has some jvm.dll . Will that be a problem? if so can i remove those? which of them should be removed and how?
    The code i'm using is
    #include <stdio.h>
    #include <jni.h>
    #include <windows.h>
    //#pragma comment (lib,"C:\\j2sdk1.4.2_05\\lib\\jvm.lib")
    JavaVM jvm; / Pointer to a Java VM */
    JNIEnv env; / Pointer to native method interface */
    JDK1_1InitArgs vm_args; /* JDK 1.1 VM initialization requirements */
    int verbose = 1; /* Debugging flag */
    FARPROC JNU_FindCreateJavaVM(char *vmlibpath)
    HINSTANCE hVM = LoadLibrary("jre\\bin\\server\\jvm.dll");
    if (hVM == NULL)
    return NULL;
    return GetProcAddress(hVM, "JNI_CreateJavaVM");
    void main(int argc, char **argv )
    JavaVM jvm = (JavaVM )0;
    JNIEnv env = (JNIEnv )0;
    JavaVMInitArgs vm_args;
    jclass cls;
    jmethodID mid;
    jint res;
    FARPROC pfnCreateVM;
    JavaVMOption options[4];
    // jint (__stdcall pfnCreateVM)(JavaVM *pvm, void **penv, void *args) = NULL;
    options[0].optionString = "-Djava.compiler=NONE"; /* disable JIT */
    options[1].optionString = "-Djava.class.path=c:/j2sdk1.4.2_05/jre/lib/rt.jar"; /* user classes */
    options[2].optionString = "-Djava.library.path=lib"; /* set native library path */
    options[3].optionString = "-verbose:jni"; /* print JNI-related messages */
    /* Setup the environment */
    vm_args.version = JNI_VERSION_1_4;
    vm_args.options = options;
    vm_args.nOptions = 4;
    vm_args.ignoreUnrecognized = 1;
    JNI_GetDefaultJavaVMInitArgs ( &vm_args );
    pfnCreateVM = JNU_FindCreateJavaVM("jre\\bin\\server\\jvm.dll");
    res = (*pfnCreateVM)(&jvm,(void **) &env, &vm_args );
    // res = JNI_CreateJavaVM(&jvm,(void **) &env, &vm_args );
    /* Find the class we want to load */
    cls = (*env)->FindClass( env, "InstantiatedFromC" );
    if ( verbose )
    printf ( "Class: %x" , cls );
    /*jvm->DestroyJavaVM( );*/
    Could anyone help me solve this problem as early as possible, bcoz i'm in an urge to complete the project.
    Thanks in advance.
    Usha.

    You either have to add to the system path of where is your jvm.dll is located or explicitly link to jvm.dll call GetProcAddress to obtain the address of an exported function in the DLL.

  • Re: problem calling a method from another class

    This line here:
    app.computeDiscount(ord,tentativeBill);... You are not capturing the returned amount.
    double d = app.computeDiscount(ord,tentativeBill);

    what kind of problem r u facing?
    plz highlight the code where u r facing the problem

  • How to call a specific method in a servlet from another servlet

    Hi peeps, this post is kinda linked to my other thread but more direct !!
    I need to call a method from another servlet and retrieve info/objects from that method and manipulate them in the originating servlet .... how can I do it ?
    Assume the originating servlet is called Control and the servlet/method I want to access is DAO/login.
    I can create an object of the DAO class, say newDAO, and access the login method by newDAO.login(username, password). Then how do I get the returned info from the DAO ??
    Can I use the RequestDispatcher to INCLUDE the call to the DAO class method "login" ???
    Cheers
    Kevin

    Thanks for the reply.
    So if I have a method in my DAO class called login() and I want to call it from my control servlet, what would the syntax be ?
    getrequestdispatcher.include(newDAO.login())
    where newDAO is an instance of the class DAO, would that be correct ?? I'd simply pass the request object as a parameter in the login method and to retrieve the results of login() the requestdispatcher.include method will return whatever I set as an attribute to the request object, do I have that right ?!!!!
    Kevin

  • EJB 3.1 @Asynchronous and calling other methods from within

    Hey all,
    I am helping a friend set up a test framework, and I've turned him on to using JEE6 for the task. I am decently familiar with entity beans, session beans, and such. One of the new features is @Asynchronous, allowing a method to be ran on a separate thread. The test framework generally needs to spawn potentially 1000's of threads to simulate multiple users at once. Originally I was doing this using the Executor classes, but I've since learned that for some reason, spawning your own threads within a JEE container is "not allowed" or bad to do. I honestly don't quite know why this is.. from what I've read the main concern is that the container maintains threads and your own threads could mess up the container somehow. I can only guess that this might be possible if your threads use the container services in some way.. but if anyone could enlighten me on the details as to why this is bad, that would be great.
    None the less, EJB 3.1 adds the async capability and I am now looking to use this. From my servlet I use @EJB to access the session bean, and call an async method. My servlet returns right away as it should. From the async method I do some work and using an entity bean store results, so I don't need to return a Future object. In fact, my ejb then makes an HttpClient call to another servlet to notify it that the result is ready.
    My main question though, is if it's ok to call other methods from the async method that are not declared @Asynchronous. I presume it is ok, as the @Asynchronous just enables the container to spawn a thread to execute that method in. But I can't dig up any limitations on the code within an async method.. whether or not it has restrictions on the container services, is there anything wrong with using HttpClient to make a request from the method.. and making calls to helper methods within the bean that are not async.
    Thanks.

    851827 wrote:
    Hey all,.. from what I've read the main concern is that the container maintains threads and your own threads could mess up the container somehow. I can only guess that this might be possible if your threads use the container services in some way.. but if anyone could enlighten me on the details as to why this is bad, that would be great.
    Yes since the EE spec delegated thread management to conatiners, the container might assume that some info is available in the thread context that you may not have made available to your threads.
    Also threading is a technical implementation detail and the drive with the EE spec is that you should concentrate on business requirements and let the container do the plumbing part.
    If you were managing your own threads spawned from EJBs, you'd have to be managing your EJBs' lifecycle as well. This would just add to more plumbing code by the developer and typically requires writting platform specific routines which the containers already do anyway.
    >
    None the less, EJB 3.1 adds the async capability and I am now looking to use this. From my servlet I use @EJB to access the session bean, and call an async method. My servlet returns right away as it should. From the async method I do some work and using an entity bean store results, so I don't need to return a Future object. In fact, my ejb then makes an HttpClient call to another servlet to notify it that the result is ready.
    My main question though, is if it's ok to call other methods from the async method that are not declared @Asynchronous. I presume it is ok, as the @Asynchronous just enables the container to spawn a thread to execute that method in. But I can't dig up any limitations on the code within an async method.. whether or not it has restrictions on the container services, is there anything wrong with using HttpClient to make a request from the method.. and making calls to helper methods within the bean that are not async.
    Thanks.If you want to be asynchronous without caring about a return value then just use MDBs.
    The async methods have no restrictions on container services and there is nothing wrong with calling other non async methods. Once the async method is reached those annotations don't matter anyway (unless if you call thhose methods from a new reference of the EJB that you look up) as they only make sense in a client context.
    Why do you need to make the call to the servlet from the EJB? Makes it difficult to know who is the client here. Better use the Future objects and let the initial caller delegate to the other client components as needed.

  • Add a column and I can't call a method

    I'm trying to make a small portal app with IBM RAD 6.0 but I'm having a wierd problem calling a method in my page code. Any help would be great.
    Here's the cod I'm using, I've got a bunch of system.outs in it to help me track down what's happening as well as some commented code of some things I'm trying. Any why here goes:
    I start a data table in the jsp like this
    <h:dataTable value="#{pc_MaintainBasisFormView.memberBasisComponents}" var="results"
                             border="0" cellpadding="2" cellspacing="0"
                             columnClasses="columnClass1" headerClass="headerClass"
                             footerClass="footerClass" rowClasses="rowClass1"
                             styleClass="dataTable" id="table1">
    later I build these two columns
    <h:column id="startdatecolumn">
                                  <f:facet name="header">
                                       <h:outputText styleClass="outputText" value="Start Date" id="startdateheader" />
                                  </f:facet>
                                  <h:inputText styleClass="inputText" id="startdate" value="#{results.effectiveDates.effectiveStartDate}"></h:inputText>
                             </h:column>
                             <h:column id="column7">
                                  <f:facet name="header">
                                       <h:outputText styleClass="outputText" value="Remove" id="remove"></h:outputText>
                                  </f:facet>
                                  <h:commandLink styleClass="commandLink" id="removelink" action="#{pc_MaintainBasisFormView.removeBasisComponent}">
                                  <h:outputText id="text6" styleClass="outputText" value=">>"></h:outputText>
                                       <f:param name="krusty" value="#{results.id}"></f:param>
                                  </h:commandLink>
                             </h:column>
    so column startdate calls does this "results.effectiveDates.effectiveStartDate"
    so results has this method
    public EffectiveDates getEffectiveDates() {
              System.out.println("in getEffectiveDates " + effectiveDates);
              //effectiveDates = (effectiveDates == null) ? new EffectiveDates():effectiveDates;
              return effectiveDates;
    and EffectiveDates has this method
    public String getEffectiveStartDate() {
              System.out.println("in getEffectiveStartDate " + effectiveStartDate);
              effectiveStartDate = (effectiveStartDate == null) ? new Date() :effectiveStartDate;
              return "dfgdfG";
    (it's supposed to return a date but I've set it to a string just to try to get it working)
    and that all works fine.
    Now the second column calls "pc_MaintainBasisFormView.removeBasisComponent" with a parameter <f:param name="krusty" value="#{results.id}">
    and removeBasisComponent is defined as
         public String removeBasisComponent() {
              System.out.println("in removeBasisComponent");
              String id = getPortletRequest().getParameter("krusty");
              System.out.println("in krusty " + id);
              return "removeBasisComponent";
    so whats the probelm? When I click the link in the second column, the method that it is tied to is never called. BUT, when I don't have the first column, the link works as I expect it to.
    can anyone point me in the right direction to solve this problem?
    Thanks in advance
    JohnL

    Hi Ruhi
    I hope this answer doesn't come too late, for some reason the forum does not let me in w/ my username & password, and won't allow me to follow the "Forgot password" procedures.
    Anyway:
    I don't have the code but I'll try to explain the problem using the info I posted originally.
    my problems start here:
    <h:inputText styleClass="inputText" id="startdate" value="#{results.effectiveDates.effectiveStartDate}"></h:inputText>
    It generates an input box with the value results.effectiveDates.effectiveStartDate. What I didn't know was that when I tried to submit the form from the link the application was silently failing. By silently I mean there was no error in the log, nothing, not a clue as to what the problem was.
    The problem turned out to be pretty simple. When the form is generated with results.effectiveDates.effectiveStartDate
    it was essentially running results.getEffectiveDates().getEffectiveStartDate() which, from my example, returned a string. That's great, no problem.
    When the form is submitted it was trying to call results.getEffectiveDates().setEffectiveStartDate(), where the method setEffectiveStartDate must take a String argument, setEffectiveStartDate(String EffectiveDate). Remember that in my example I was returning a string to the from...so I needed to accept a string as an argument to the set method.
    I hope this helps.

Maybe you are looking for

  • Moving voice memos from iPhone to pc

    I have tried looking but it seems the only "how-to" is based on old versions of iTunes, not ver 12.1.1.4 Can anyone assist with this?

  • Need to calculate Balance from GL line items 0FIGL_O02 similar to 0FIGL_O10

    Hi We are using 0FI_GL_4 & 0FI_GL_10 datasources. Recently we realised that In FAGLFLEXT table, the cost center value is not always getting populated as a result of which we do not get cost centers in 0FIGL_O10 DSO which has all the GL balances in it

  • Firefox randomly not displaying images on MS Skydrive

    I can load .jpg files to MS Skydrive, no problem. Thumbnails are fine. If I select an individual image, some display OK, some display nothing. Same if I scroll through to that image, or run slideshow. If I right click and "show original" the original

  • FLAC support in flash?

    Hello, I'm currently involved in building a web-based flash application where people can record speech, and then send it to a server for storage. To keep the file size down i'm using mp3, but the sound needs to be analyzed and the mp3 encoding destro

  • Disk Utility not creating Mac bootable CDs

    Hi I have a 2006 Mac Mini with a SuperDrive running Snow Leopard (10.6). I downloaded a Linux ISO and burnt it to a blank CD using Disk Utility (dropped the ISO on the Disk Utility window, then clicked Burn). The CD burnt and verified with no problem