Is it possible to invoke JEB method from thread?

Hello everybody!
I have problem creating EJB from the thread. Here is the part of code below:
public void email() throws Exception {
class MailThread implements Runnable {
public MailThread() {
public void run() {
try {
String jndiName "java:comp/env/ejb/PROG/Mail";
IMailHome mailHome;
IMail mail;
InitialContext context = new InitialContext();
Object objref = context.lookup(jndiName);
mailHome = (IMailHome) PortableRemoteObject.narrow(objref, IMailHome.class);
// Exception here:
// java.rmi.RemoteException: Exception Substitute; nested exception is:
// java.lang.NullPointerException mail = mailHome.create();
// business metods
// mail.method1();
} catch (Exception e) {
System.out.println("Exception:" + e);
MailThread mt = new MailThread();
Thread thread = new Thread(mt);
thread.start();
Exception:
java.rmi.RemoteException: Exception Substitute; nested exception is:
java.lang.NullPointerException
I am not able to create EJB instance from the thread. The same code works well in servlet. Am I doing something wrong?
May be there are some different approaches to implement some operations asynchronously at EJB level do not using JMS and MDB? J2EE specification prohibits to use threads inside EJB so the only way I see is to create different thread on servlet side and invoke EJB methods from it. But it seems that this doesn't work too. Could anyone help me?
Thanks in advance,
Vadim Lotarev

If the passcode will not work, the only alternative is to restore the phone as new. You cannot change the passcode from the lock screen.

Similar Messages

  • Possible to invoke a method from string

    I was just wondering if it is possible to have some sort of method that takes as its parameters a string ie: invokeStringMethod(strMethod);
    when String strMethod = "public void doSomething(){}";
    If it is possible to do something like this, could someone please lead me in the right direction, and if its not, well that kinda stinks, but thanks for the help. Thanks.

    I'm not completely sure what you're asking. One of these might be helpful:
    * Reflection, esp. java.lang.Method (obtained from java.lang.Class).
    http://java.sun.com/docs/books/tutorial/reflect/
    * Scripting, such as with beanhsell
    http://www.beanshell.org
    * An anonymos inner class: Runnable runnable = new Runnable() {
      public void run() {
        // do stuff
    };If you want the method name and parameters to be a string that's determined at runtime, look at the first two. If you want the method's implementation to occur inline, look at the third (and maybe the second, too, depending on what you're really trying to accomplish).

  • How to invoke action method from mail contained link

    Hello,
    my application needs to send mails to users that include links for the user to click on. Something like www.mysite.com/displayData.jsp&id=123. My question is now how I make JSF invoke the respective method in the backed bean to display the data with the id 123 when the user clicks on the link int the mail.
    I wonder whether there is some kind of "catch-all action" that checks whether the user is logged in and authorized whenever any JSP page is invoked. I'm a bit tired of first checking the authorization of some user before processing the remaining part od the backed bean's action method.
    Thanks for any hints,
    Oliver Plohmann

    my application needs to send mails to users that
    include links for the user to click on. Something
    like www.mysite.com/displayData.jsp&id=123. My
    question is now how I make JSF invoke the respective
    method in the backed bean to display the data with
    the id 123 when the user clicks on the link int the
    mail.I dont think there is a way to submit to an action on click of a link. Only possible solution is to invoke the method from the constructor of your Backing Bean and populate the bean fields displayed on your page.
    I wonder whether there is some kind of "catch-all
    action" that checks whether the user is logged in and
    authorized whenever any JSP page is invoked. I'm a
    bit tired of first checking the authorization of some
    user before processing the remaining part od the
    backed bean's action method. You can try out a Servlet filter for doing this.

  • Problems invoking a method from a web service

    Am using netbeans 6.1 and my problem is when i invoke a method from a web service that has a custom class as a return type.
    When I debug the client that consumes my web service, It get Stack in this line:
    com.webservice.WebServiceInfoBean result = port.getWebServiceInfo(nameSpace, serviceName, portName, wsdlURL);
    i don't get any error on the console.
        static public void function1() {
            try { // Call Web Service Operation
                com.webservice.WebServiceMonitorService service = new com.webservice.WebServiceMonitorService();
                com.webservice.WebServiceMonitor port = service.getWebServiceMonitorPort();
                // TODO initialize WS operation arguments here
                java.lang.String nameSpace = "NameSpaceHere";
                java.lang.String serviceName = "WebServicePrueba";
                java.lang.String portName = "Soap";
                java.lang.String wsdlURL = "http://localhost/Prueba/WebServicePrueba.asmx?wsdl";
                // TODO process result here
                com.webservice.WebServiceInfoBean result = port.getWebServiceInfo(nameSpace, serviceName, portName, wsdlURL); // <--- here it stack
                System.out.println("getWebServiceInfo");
                Iterator i = result.getMethods().iterator();
                while (i.hasNext()) {
                    MethodBean method = (MethodBean) i.next();
                    System.out.print("Nombre: " + method.getname());
                    System.out.print(" Returns: " + method.getreturnType());
                    Iterator j = method.getparameters().iterator();
                    while (j.hasNext()) {
                        ParameterBean parameter = (ParameterBean) j.next();
                        System.out.print(" ParameterName: " + parameter.getname());
                        System.out.print(" ParameterType: " + parameter.gettype());
                    System.out.print("\n");
                    System.out.print(method.getfirma());
                    System.out.print("\n");
                    System.out.print("\n");
            } catch (Exception ex) {
                ex.printStackTrace();
        }Web Service side
         * Web service operation
        @WebMethod(operationName = "getWebServiceInfo")
        public WebServiceInfoBean getWebServiceInfo(@WebParam(name = "nameSpace")
        String nameSpace, @WebParam(name = "portName")
        String portName, @WebParam(name = "serviceName")
        String serviceName, @WebParam(name = "wsdlURL")
        String wsdlURL) throws Throwable {
            //TODO write your implementation code here:
            webservicemonitor instance = new webservicemonitor();
            return instance.getWebServiceInfo(nameSpace, serviceName, portName, wsdlURL);
        }I have tested my internal code from the web service side and everything works fine. The problem occurs when i invoke it from a client side. probably I did not made the right serialization form my class WebServiceInfoBean? or am missing something. here it is:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package com.beans;
    import java.util.ArrayList;
    * @author Tequila_Burp
    public class WebServiceInfoBean implements java.io.Serializable {
         * Holds value of property wsdlURL.
        private String wsdlURL;
         * Getter for property wsdlURL.
         * @return Value of property wsdlURL.
        public String getwsdlURL() {
            return this.wsdlURL;
         * Setter for property wsdlURL.
         * @param wsdlURL New value of property wsdlURL.
        public void setwsdlURL(String wsdlURL) {
            this.wsdlURL = wsdlURL;
         * Holds value of property namespace.
        private String namespace;
         * Getter for property namespace.
         * @return Value of property namespace.
        public String getnamespace() {
            return this.namespace;
         * Setter for property namespace.
         * @param namespace New value of property namespace.
        public void setnamespace(String namespace) {
            this.namespace = namespace;
         * Holds value of property serviceName.
        private String serviceName;
         * Getter for property serviceName.
         * @return Value of property serviceName.
        public String getserviceName() {
            return this.serviceName;
         * Setter for property serviceName.
         * @param serviceName New value of property serviceName.
        public void setserviceName(String serviceName) {
            this.serviceName = serviceName;
         * Holds value of property wsdlURL.
        private String portName;
         * Getter for property wsdlURL.
         * @return Value of property wsdlURL.
        public String getportName() {
            return this.portName;
         * Setter for property wsdlURL.
         * @param wsdlURL New value of property wsdlURL.
        public void setportName(String portName) {
            this.portName = portName;
         * Holds value of property methods.
        private ArrayList methods = new ArrayList();
         * Getter for property methods.
         * @return Value of property methods.
        public ArrayList getmethods() {
            return this.methods;
         * Setter for property methods.
         * @param methods New value of property methods.
        public void setmethods(ArrayList methods) {
            this.methods = methods;
        public MethodBean getMethod(int i) {
            return (MethodBean)methods.get(i);
    }by the way, everything has been worked on the same PC.

    Hi Paul,
    This sound familiar, but I cannot at the moment locate a reference to
    the issue. I would encourage you to seek the help of our super support
    team [1].
    Regards,
    Bruce
    [1]
    http://support.bea.com
    [email protected]
    Paul Merrigan wrote:
    >
    I'm trying to invoke a secure 8.1 web service from a 6.1 client application and keep getting rejected with the following message:
    Security Violation: User: '<anonymous>' has insufficient permission to access EJB:
    In the 6.1 client, I've established a WebServiceProxy and set the userName and password to the proper values, but I can't seem to get past the security.
    If there something special I need to do on either the 8.1 securing side or on the 6.1 accessing side to make this work?
    Any help would be GREATLY appreciated.

  • Invoking java methods from C/C++ on the machine with different JREs

    I implemented Windows NT Service instantiating JVM and invoking several java methods. Everything works but I have an issue with running the service on the machine where multiple different versions of JRE have been installed. The service is calling java methods that require JRE 1.3 or later so I wrote the code that is setting system PATH from within the service based on the configuration stored in the external file. The problem is that the service requires jvm.dll to be in the PATH prior lunching it since this library is instantiated through the implicit linking. When I put jvm.dll in the same path as the service binary I can lunch it but JNI_CreateJavaVM fails and returns -1. This happens even if JRE 1.3 is in the system PATH prior lunching the service.
    Everything works if the system PATH contains references to JRE 1.3 and jvm.dll is removed from the service's directory.
    I am looking for an advice on what is the proper way to deal with invoking java methods from the C/C++ executable in the environment with different versions of JRE.
    Thanks, Kris.

    Here's a way I have done what you are asking about:
    What you want to do is make all of your linking happen at runtime, rather than at compile time. This way, you can edit the PATH variable before the jvm.dll gets loaded.
    Following is some code that I used to handle a dll of my own in this manner. You can decide if you want to write a "wrapper" dll, or if you find it simpler to approach the jvm.dll in this way.
    // Define pointer type for DLL entry point.
         typedef void JREPDLL_API (*EXECUTEREQUEST)(char*, Arguments&);
    // Set up path, load dll, and pass everything off to it.
    HINSTANCE javaServer = javaServer = LoadLibrary("jrepdll.dll");
    if (javaServer != NULL) {
    EXECUTEREQUEST executeRequest = (EXECUTEREQUEST)GetProcAddress(javaServer, "ExecuteRequest");
    if (executeRequest != NULL) {
    if (argc == 1)
         // Execute the request.
         executeRequest("-run", args);
    else
         // Execute the request.
         executeRequest("-console", args);
    Here's some code for how to edit the PATH:
              // Edit the PATH environment variable so that we use our private java.
    char *appendPt;
    char *newPath;
    char *path;
              char tmp[_MAX_PATH];
              // Get the current PATH variable setting.
    path = getenv("PATH");
              // Allocate space for an edited path setting.
              if (path != NULL)
                   newPath = (char*)malloc((_MAX_PATH * 2) + strlen(path));
              else
                   newPath = (char*)malloc((_MAX_PATH * 2));
              // Get upper part of path to desired directories.
              strcpy(tmp, filepath);
              appendPt = strstr(tmp, "dbin\\jreplicator");
              appendPt[0] = '\0';
    sprintf(newPath, "PATH=%sjava\\jre1.2.2\\bin;%sjava\\jre1.2.2\\bin\\classic", tmp, tmp);
    // Append the value of the existing PATH environment variable.
    // If there is anything, append it.
    if (path != NULL) {
         strcat(newPath, ";");
         strncat(newPath, path, (sizeof(newPath) - strlen(newPath) - 2));
    // Set new PATH value.
    _putenv(newPath);
              free(newPath);

  • Invoke beanshell methods from java

    Hello
    I'm learning beanshell and using it to write scripts that are ran in JDK 6.
    My question is how to invok beanshell methods from java source codes.
    My codes is:
    import javax.script.*;
    public class InvokeFunctions {
    public static void main (String[] args)throws ScriptException, NoSuchMethodException
    ScriptEngineManager sem = new ScriptEngineManager();
    ScriptEngine bshEngine = sem.getEngineByName("beanshell");
    String script = "public void sayHello()"+"{print (\"sayHello() is a method in bsh script\");}";
    bshEngine.eval(script);
    Invocable inbshEngine = (Invocable)bshEngine;
    inbshEngine.invokeFunction("sayHello");
    I defined a method "sayHello()" using beanshell, but i just can't invoke it in Java.
    I got an error msg said:
    Exception in thread "main" java.lang.IllegalAccessError: tried to access method bsh.NameSpace.getThis(Lbsh/Interpreter;)Lbsh/This; from class bsh.engine.BshScriptEngine
    Any one has any idea about it?
    Thanks

    Look at the Javadoc documentation of IllegalAccessError. It says:
    Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.
    Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.
    Maybe recompiling all your sources (make sure you delete all existing *.class files) will help?

  • Error while invoking ContactQueryPage method from contact.wsdl

    Hi All,
    Could any one provide me the java client for OnDemand webservice (contact.wsdl). I want to query ContactQueryPage operation.
    I am facing some problem while making a call. I am trying with both Axis call as well as ContactStub. but its not working in either way.
    Here is the snnipet I am using to invoke a method using ContactStub
    String endpoint = "https://secure-ausomxdsa.crmondemand.com/Services/Integration;"+jessionId;
                   ContactStub stub = new ContactStub(endpoint);
                   ContactWS_ContactQueryPage_Output queryOutput = null;     
                   ContactWS_ContactQueryPage_Input queryInput = new ContactWS_ContactQueryPage_Input();
                   ListOfContact listOfContact = new ListOfContact();
                   Contact contact = new Contact();
                   queryInput.setListOfContact(listOfContact);
                   queryInput.setUseChildAnd("Contact");
                   queryInput.setPageSize("10");
                   queryInput.setStartRowNum("1");
                   queryOutput = stub.ContactQueryPage(queryInput);
    When I run the program..I get following exception :
    org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
    Can any one help me out. Its needed urgently.
    Thanks & Regards,
    Sanjay

    Hi !
    From what I see, the only problem is the setUseChildAnd function which is waiting for a true or false argument and not a char...
    Hope this will help, feel free to ask more !
    Max

  • Invoking presentation method from a screenflow

    i am using ALBPM object presentation which shows some images one by one on pressing 'Next' button.but when all the images are shown(stored in a predefined directory), i want to set the visibility of the image component false and show a warning in a textbox, which was set invisible while initialising the presentation, by setting its visibilty true by using the setVisible method.
    So, in my screenflow, i have called the presentation by interactive component call using an instance variable of the type of the presentation object in catalog.Now, when i am calling the setVisible method in an automatic activity in my screenflow, it is giving "java.lang.RuntimeException: Cant invoke presentation methods, if it is running on server side". But setVisible is a client side method itself.
    Then, i have tried by writing a client side method inside the presentation object which calls the setVisible method and then i called it from the automatic activity in the screenflow, but it is still giving the same error.
    Plz help.
    Thanks in advance.
    Edited by pottercap at 02/28/2007 11:01 PM

    if the "show all" flag is known wen you invoke the presentation, you can set the visible flag in the initialization method of the presentation.
    hope it helps.
    MAriano Benitez
    Join us at BEAParticipate, May 6-9 2007 | Atlanta, Georgia

  • Invoking Applet methods from Javascript for Netscape 6

    Hi,
    I am trying to invoke an applet method from javascript, but it is failing with Netscape 6 browser:
    I am doing it the following way-
    function test(form)
    var i = document.myapplet.getname();
    where myapplet is the name of the applet and getname is a method within the applet. This is
    working with Ie but not with netscape 6.
    I would appreciate it if someone could tell me how should I invoke the applet method for netscape browsers.
    Thanks.
    Jay Srin.

    Not working with NS 6 - and will not i guess till they upgrade to Mozilla Version 1.0 - Live Connect is not implemented 100% correct yet - if you want you can download the 7.0 Pre Release Netscape - since its using mozilla 1.0 it should work , see :
    http://forum.java.sun.com/thread.jsp?forum=30&thread=272975

  • Invoking Java Methods from outside ODI

    Is there a good blog on how to do this, I assume a procedure is the best way?

    Bos that makes sense and seems to work, I put this into my text variable:
    SELECT
    CAST(COLLECT(to_char(trade_id)) AS oditmp.t_varchar_tab) AS trade_id
    FROM oditmp.trade_ids
    Validated and returned this when I checked the history :
    Date Value Context
    2011-07-01 08:33:01.0     oracle.sql.ARRAY@294d7bc     DEVELOPMENT
    I assume the values are loaded in here and I can modify my Java Code as below?
    In SQL Developer the same query returns:
    ODITMP.T_VARCHAR_TAB(1,2,3,4,5,6)
    -- Change to Java:
    // Declare variables
    import jar_jcmf;
    trade_ids String;
    String [] str_arr;
    jar_jcmf t = new jar_jcmf();
    int n;
    // Load string array of table values, NOT SURE ABOUT THIS STEP
    trade_ids = #PRJCT.TRADE_IDS;
    // Split String
    str_arr = trade_ids.split(",");
    // Loop over array and execute GetTrade method from JCMF Class
    for (String rec : str_arr) {
    n = Integer.parseInt(rec)
    t.getTrade(n);
    };

  • Invoke EJB methods from RMI client -- OutOfMemory error on the server

    Each time I tried to invoke a method of my session bean, on the server I have an
    error : java.lang.OutOfMemoryError
    And the client doesn't receive any answer !
    Do you have an idea ?
    (everything before seems OK - context, narrow, home.create() ...)
    Config : WL6.1 SP1 on Solaris 2.8 / client Win2000 jdk 1.3.1

    "Sabine" <[email protected]> writes:
    Each time I tried to invoke a method of my session bean, on the server I have an
    error : java.lang.OutOfMemoryError
    And the client doesn't receive any answer !
    Do you have an idea ?
    (everything before seems OK - context, narrow, home.create() ...)
    Config : WL6.1 SP1 on Solaris 2.8 / client Win2000 jdk 1.3.1Are you using RMI-IIOP? If so I suggest you try SP3.
    andy

  • Urgent - calling EJB methods from thread

    Dear all
    I am aware of EJB spec that does not permit developer managed threads within EJB components. However, I need to call EJB methods from my own thread. Hence, it there any way to to call EJB methods from developer managed thread ?? If yes, please advice me, thanks in advance and your help will be appriciated.
    Hava a nice day

    You can call EJB's from your threads. Your thread will act as the client and the call will to EJB will be same as any other client invoking EJB's. Hope I understand your question !.

  • Accesing methods from threads

    hi.
    Im trying to write a program that requires multithreading , I store each thread as an object in a vector to identify the thread because the threads are all initiated from the same class , heres the code:
    while(condition) {
    myThread thread = new myThread(); // myThread extends Thread
    vector.add(thread);
    how would i access a method from one of these threads?
    or is there a more efficient way without using vectors etc?

    what i mean by accessing methods is that there is
    only one class that extends Thread but i have create
    an instance of that class several times in the run
    method so the only way i can identifiy each class is
    by putting it in a vector but when i call
    vector.get(indexNo).methodname() the compiler spits
    it back out?I really don't know what you're saying here. If you're getting an error message from the compiler, paste it here, along with the relevant code, and an indication of which line it's complaining about.
    When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.
    And do go through that thread tutorial thoroughly. It may or may not answer your current specific question, but it will give you some fundamentals that are essential when doing multithreaded progamming.

  • Invoking main method from cmd line (deployed as web app)

    I have a application deployed as a web application (war file).
    I want to create a regular java class with main method so that main can invoked
    on a command line.
    The main method wishes to share resources (DB connection pool etc) with the rest
    of the web application.
    Is it possible ? and how to invoke the main method inside the war(not jar) ?

    Hi,
    if you deployed this to OC4J, open EM
    http://server:port/em
    and get to the Web service. You can execute it from here to see if generally this is working, or if you have a proxy problem only
    Frank

  • ADF: is it possible to call bean methods from a DataForwardAction?

    Hi,
    i have created an ADF data control from bean and I have some values bound and populated in a page. As part of the Action class i would like to execute one of the methods in the bean. Is this possible or am i taking the wrong approach?
    regards,
    Brenden

    Yes, there are a few ways of doing it, please see...
    http://www.ps-scripts.com/bb/viewtopic.php?t=3109

Maybe you are looking for

  • How can the query results include null if it's a required field on the front end?

    I executed a query that simply asked for all data points on a single table. I am trying to figure out why the query would report back as having all "Null" values in 3 of 10 columns. The information is required for the end user to enter before the sys

  • Removing (applescript) one of three identical items in InDesign file

    I have 3 boxes exactly the same and need to remove one of them. The best option identifier I have is the location which varies slightly from one file to the next. Please see the attached and LMK if there are any ideas. Thanks!

  • NAS NSS 326 Reset Issue.

    Hi peeps Have a little issue with a Cisco NAS NSS 326 Smart Storage 6 bay - with RAID 5 over 6 disks. Apparently there were some funny business with the performance with the device so someone reset the device from the button on the back. I've been as

  • Formatting output of SQLPlus

    I have... Name Town strull VK pemo KL I want Name strull Town VK Name pemo Town KL Is it possible to get this output, i.e. with a simple customizing setting in login.sql or something else? Thanks in advance... Paul

  • External procedure - configuration problem

    Hi, I am trying to learn to use external procedures with PL/SQL but I have some problems with proper configuration. I have created a *.dll library with class WriteStr containing one static method writeStr, which is supposed to write some text to file