Calling EJB facades via class instantiated via reflection?

We are loading plugins via Java reflection. Anything instantiated via newInstance() does not appear to have access to the Local interface.
Right now, to get to the session bean we must use the Remote interface. This is annoying due to the performance, and seems completely unnecessary when everything is operating in one JVM.
Tests were done to print out the JNDI namespace and the local interfaces don't seem to be accessible. Any advice?

My project consists of an EJB package and WAR. I have not had any problem calling the local facades from JSP, Servlet, or web service in the EJB package.
Further, I can use XStream reflection and do local EJB calls.
It baffles me why I can't do the local calls in some classes via InitialContext lookups.
I will post test code next week.

Similar Messages

  • Call ejb from another class?

    there are some codes form someone I dont understand, can anyone help me out ?
    the class Call will run on the same VM as the CMP entity bean Subscriber. what I am not sure is the call in method f2() , i.e. s.setName() will really wirte data to databank, since the lookup was done in getScriber(), and not visible in f2()!
    Am I right ?
    public class Call {
    pubic void f1(){
    Context jndiContext = new InitialContext();
    public void f2 (){
    Subscriber s = getSubscriber(); // 1
    s.setName(); // 2
    private Subscriber getSubscriber(){
    SubscriberHome sHome = (Subscriber)jndiLookup("SubscriberEJB"); // 3
    Subscriber sb = sHome.fineByPrimaryKey(1);
    }

    call in method f2() , i.e. s.setName() will really
    wirte data to databank, since the lookup was done in
    getScriber(), and not visible in f2()!Can't say this for sure, unless I have a look into the setName() method. It doesn't seem to be taking any argument, and that's certainly not the same as setName(String name). It might be actually doing something meaningful. Better take a closer look.
    public class Call {
    pubic void f1(){
    Context jndiContext = new InitialContext();
    public void f2 (){
    Subscriber s = getSubscriber(); // 1
    s.setName(); // 2
    private Subscriber getSubscriber(){
    SubscriberHome sHome =
    (Subscriber)jndiLookup("SubscriberEJB"); // 3
    Subscriber sb = sHome.fineByPrimaryKey(1);
    }Rich.

  • Set fields of derived class in base class constructor via reflection?

    Does the Java Language Specification explicitly allow setting of fields of a derived class from within the base class' constructor via reflection? The following test case runs green, but I would really like to know if this Java code is compatible among different VM implementations.
    Many thanks for your feedback!
    Norman
    public class DerivedClassReflectionWorksInBaseClassConstructorTest extends TestCase {
    abstract static class A {
        A() {
            try {
                getClass().getDeclaredField("x").setInt(this, 42);
            } catch (Exception e) {
                throw new RuntimeException(e);
    static class B extends A {
        int x;
        B() {
        B(int x) {
            this.x = x;
    public void testThatItWorks() {
        assertEquals(42, new B().x);
        assertEquals(99, new B(99).x);
    }

    why not just put a method in the superclass that the subclasses can call to initialize the subclass member variable?In derived classes (which are plug-ins), clients can use a field annotation which provides some parameter metadata such as validators and the default value. The framework must set the default value of fields, before the class' initializer or constructors are called. If the framework would do this after derived class' initializer or constructors are called, they would be overwritten:
    Framework:
    public abstract class Operator {
        public abstract void initialize();
    }Plug-In:
    public class SomeOperator extends Operator {
        @Parameter(defaultValue="42", interval="[0,100)")
        double threshold;
        @Parameter(defaultValue="C", valueSet="A,B,C")
        String mode;
        public void setThreshold(double threshold) {this.threshold = threshold;}
        public void setMode(String mode) {this.mode = mode;}
        // called by the framework after default values have been set
        public void initialize() {
    }On the other hand, the default values and other metadata are also used to create GUIs and XML I/O for the derived operator class, without having it instantiated. So we cannot use the initial instance field values for that, because we don't have an instance.

  • Calling EJB with HTML via SERVLET

    Hi,
    I used a writen example that calls EJB from HTML via SERVLET. Example name is Bonus. The problem I have is that the HTML throw error while calling SERVLET. I dont figure out what seams to be a problem. Someone know?
    I wonder if the problem is in servlet? The EJB is fine!
    christian
    HTML CODE:(bonus.html)
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1250"/>
    <TITLE>untitled1</TITLE>
    </HEAD>
    <BODY BGCOLOR = "WHITE">
    <BLOCKQUOTE>
    <H3>Bonus Calculation</H3>
    <FORM METHOD="GET" ACTION="BonusAlias">
    <P>Enter social security Number:<P>
    <INPUT TYPE="TEXT" NAME="SOCSEC"></INPUT>
    </P>
    Enter Multiplier:
    <P>
    <INPUT TYPE="TEXT" NAME="MULTIPLIER"></INPUT>
    </P>
    <INPUT TYPE="SUBMIT" VALUE="Submit">
    <INPUT TYPE="RESET">
    </FORM>
    </BLOCKQUOTE>
    </BODY>
    </HTML>
    SERVLET CODE:(BonusServlet.java)
    package mypackage5;
    import mypackage5.Calc;
    import mypackage5.CalcHome;
    import mypackage5.impl.CalcBean;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    import java.beans.*;
    public class BonusServlet extends HttpServlet {
    CalcHome homecalc;
    public void init(ServletConfig config) throws ServletException{
    //Look up home interface
    try{
    //InitialContext ctx = new InitialContext();
    //Object objref = ctx.lookup("Calc");
    //homecalc = (CalcHome)PortableRemoteObject.narrow(objref, CalcHome.class);
    Context context = new InitialContext();
    CalcHome calcHome = (CalcHome)PortableRemoteObject.narrow(context.lookup("Calc"), CalcHome.class);
    Calc calc;
    catch (Exception NamingException) {
    NamingException.printStackTrace();
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    String socsec = null;
    int multiplier = 0;
    double calc = 0.0;
    PrintWriter out;
    response.setContentType("text/html");
    String title = "EJB Example";
    out = response.getWriter();
    out.println("<HTML><HEAD><TITLE>");
    out.println(title);
    out.println("</TITLE></HEAD><BODY>");
    try{
    Calc theCalculation;
    //Get Multiplier and Social Security Information
    String strMult = request.getParameter("MULTIPLIER");
    Integer integerMult = new Integer(strMult);
    multiplier = integerMult.intValue();
    socsec = request.getParameter("SOCSEC");
    //Calculate bonus
    double bonus = 100.00;
    theCalculation = homecalc.create();
    calc = theCalculation.calcBonus(multiplier, bonus);
    catch (Exception CreateException){
    CreateException.printStackTrace();
    //Display Data
    out.println("<H1>Bonus Calculation</H1>");
    out.println("<P>Soc Sec: " + socsec + "<P>");
    out.println("<P>Multiplier: " +
    multiplier + "<P>");
    out.println("<P>Bonus Amount: " + calc + "<P>");
    out.println("</BODY></HTML>");
    out.close();
    public void destroy() {
    System.out.println("Destroy");

    The error is that page cannot be found! When I run only the servlet it works, when I run the HTML page and enter the field throws eror that the page cannot be found!
    thanks
    Christian

  • Loading a class via reflection without knowing the full qualified path ?

    Hi there
    I d like to load a class via reflection and call the constructor of the class object. My problem is that I dont know the full qulified name e.g. org.xyz.Classname bur only the Classname.
    I tried different things but none seem to work:
         1. Class c = Class.forName("Classname");  //does not suffice, full qualified name required
    2. ClassLoader classloader = java.lang.ClassLoader.getSystemClassLoader();
             try {
               Class cl = classloader.loadClass(stripFileType(Filename));//if i do not pass the full qualified name i get a ClassNotFoundException
    3. I tried to consruct a class object with my own classloader , calling:
              Class cl = super.defineClass(null, b, 0, b.length );     b is of type byte[]This almost works. I get a class Object without knowing the full qulified path. I can transform a filename into a raw array of bytes and I get the class out of it. But there is still a problem: If there are more than on classes defined in the same textfile I get an InvocationTargetException.
    It looks like this:
    package org.eml.adaptiveUI.demo;
    import com.borland.jbcl.layout.*;
    import java.awt.*;
    import org.eml.adaptiveUI.layout.*;
    import javax.swing.*;
    import java.awt.event.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class twoButtons extends JFrame {
      SPanel sPanel1 = new SPanel();
      JButton jButton1 = new JButton();
      GridBagLayout gridBagLayout1 = new GridBagLayout();
      GridBagLayout gridBagLayout2 = new GridBagLayout();
      public twoButtons() throws HeadlessException {
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      public static void main(String args[]){
        twoButtons twob = new twoButtons();
        twob.pack();
        twob.show();
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(gridBagLayout1);
        jButton1.setText("button 1");
        jButton1.addActionListener(new TransformationDemo_jButton1_actionAdapter(this));
        this.getContentPane().add(sPanel1,  new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
                ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(57, 52, 94, 108), 35, 44));
        sPanel1.add(jButton1,  new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
                ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 41, 0, 0), 0, 0));
      void jButton1_actionPerformed(ActionEvent e) {
        System.out.println("button 1 source: " + e.getSource());
        System.out.println("d: " + e.getID());
       System.out.println("/n commmand: " + e.getActionCommand());
    class TransformationDemo_jButton1_actionAdapter implements java.awt.event.ActionListener {
      twoButtons adaptee;
      TransformationDemo_jButton1_actionAdapter(twoButtons adaptee) {
        this.adaptee = adaptee;
      public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }As you can see there is the class TransformationDemo_jButton1_actionAdapter class defined in the same classfile. The problem is now that the twoButtons constructor calls the TransfomationDemo_jButton1_actionAdapter constructor and this leads to InvocationTargetException. I dont know if this is a java bug because it should be possible.
    Can you help me?

    hi thanks at first,
    the thing you mentioned could be a problem, but I dont think it is.
    If I have the full qualified name (which I havent) then everything goes normal. I only have to load the "twoButtons" class and not the other (actionadapter class), so I dont think this is the point. In this case the twoButtons constructor constructs an object of the actionadapter class and everything goes well. The bad thing is though that I do not have the full qulified name :(
    Invocation target exception tells me (in own words): Tried to acces the constructor of the actionadapter class (which is not public) out of class reflectionTest class .
    reflectionTest is the class where the reflection stuff happens and the twoButttons class is defineClass() ed.
    The problem is, only twoButtons class has the rights to call methods from the actionadapter class, the reflection class does not. BUT: I do not call the actionadapter methods from the reflection class. I call them only from the twoButtons class.
    I hope somebody understands my problem :)

  • How to instantiate class via reflection

    Hi, I want to generically instatiate classes, but obviously Class.newInstance only works if the class has a public no args constructor. Is there any way to instantiate classes without such a constructor via reflection? It would be sufficient for me if I could use a private no args constructor.
    I already tried the following:
    Class clazz = Class.forName( "classname" );
    Constructor constructor =
    clazz.getDeclaredConstructor( new Class[] { } );
    constructor.setAccessible( true );
    object = constructor.newInstance( new Object[] {} );
    But it, too, yielded to an IllegalAccessException.

    Class clazz = Class.forName( "classname" );
    Constructor constructor =
    clazz.getDeclaredConstructor( new Class[] { } );
    constructor.setAccessible( true );
    object = constructor.newInstance( new Object[] {} );
    But it, too, yielded to an IllegalAccessException.constructor.setAccessible( true );
    is the call that generates the IllegalAccessException. Your code must be allowed to supress access checks. This is always the case if you don't have a security manager, otherwise the security manger's checkPermission method is called with an ReflectPermission("supressAccessChecks") argument.
    Either that or the getDeclaredConstructor throws the exception, in that case your code must be allowed to "check member access".
    Hope it helped,
    Daniel

  • Calling EJB from Oracle via IIOP

    I've spent the last two days trying to figure out how I can call an
    EJB from an Oracle Stored Procedure. I first looked into WLS JNDI
    (Using WLInitialContextFactory ), but my collegue recommended I look
    into IIOP because it is "less proprietary". I was able to get a WL
    example working that does a lookup on an EJB and "narrows" the IIOP
    object...so it looked promissing, but then I tried to load the JAR
    into Oracle and it said:
    "referenced name javax/rmi/PortableRemoteObject could not be found"
    So I did a quick check and it looks like this didn't come into
    existance until JDK 1.3. By all accounts, Oracle 8.1.6 supports JDK 2
    (1.2). So now I'm stuck. I've got a few examples about connecting to
    the Oracle ORB using session-iiop, but I don't know if Weblogic will
    be able to work with this. I don't know how I'd even call it because
    the URL requires an Oracle SID...so now what? I see three options.
    Please let me know which would be best (or another option that I'm
    missing)
    1. Try connecting with Weblogic "T3"
    2. Try to get the right combination of classes loaded so 1.2 can work
    like 1.3
    3. Use the Oracle IIOP (I have no examples for connecting to other
    ORBs so I have no idea how to lookup objects).
    Chris

    [email protected] (Chris Snyder) writes:
    Andy Piper <[email protected]> wrote in message news:<[email protected]>...
    [email protected] (Chris Snyder) writes:
    1. Try connecting with Weblogic "T3"It depends on what version of WLS you are using. If you are using 6.1
    then you are out-of-luck because this only support JDK 1.3.1.We are using WLS 6.1 and Oracle 8.1.6. There's got to be a way to
    connect what is essentially a 1.2 JVM to a 1.3.1 JVM. On my way home
    yesterday I was wondering if just straight RMI would work...although
    we need to encrypt the connection. I've seen several people talk
    about calling EJB's from stored procedures so it seems like there is a
    way. Any other ideas?The really gross way is HTTP. In a previous life I had a customer use
    oracle's HTTP plug-in to do this. You could probably invert the
    problem also. I.e. write CORBA objects that sit inside an Orb hosted
    in WLS and invoke on those using oracle's CORBA support. But HTTP is
    probably the way most likely to work. You probably couldn't use RMI
    over HTTP either - you would have to write a servlet that delegated to
    your beans.
    andy

  • Detecting static calls in methods via Class.forName(...)

    Hi!
    I'm trying to detect, if a method (or a contructor) of a Class object, loaded by Class.forName(...) contains a static call like System.out.println( "some text" );
    I need it to figure out if (in this case above) the class "System" is needed for running this example class.
    I don't have the source code (and don't want it anyway) to write a parser for it. I just want to extract this single information: Is there a method/contructor in the given class containing static calls by any other classes and what's the the of these classes?
    Anybody an idea?
    Thoto

    I'm trying to detect, if a method (or acontructor)
    of a Class object, loaded by Class.forName(...)
    contains a static call like System.out.println("some
    text" );BCEL should be able to do this.But I need to do that in my own program.
    System.out.println() is not a static method.That's right. If it's static or not doesn't really matter, it's just the information WHICH class is embedded into this call. It could also be a call like
    int i = Integer.MAX_VALUE.I just need (in that case) the informatation that the class "Integer" is needed to proceed that call.
    You can use javap to find this, or the BCEL library.I already did that with javap. But it's useless for me, I need it in my own program. I don't want to decompile some program. I have no illegal intentions in hacking or so. It's for my own programs, but I don't want to scan the source code.
    Unless this is homework, why would you want to know
    this information?That sounds, like you know the answer, but can't tell me, because it's the most important treasure in the world and THEY will kill you if you tell others... :-)
    No, it's not a homework and I don't want any source code from you, I'm a curious guy.

  • EJB lookup via JNDI results in java.lang.NoClassDefFoundError

    Hello,
    I have created and deployed an EJB to the WebAS (ver 6.40).  There is no problem looking up the bean via JNDI and calling its methods from a J2EE application - I successfully did this via a servlet.
    However, a JNDI lookup from a Web Dynpro application - on the same server - results in a java.lang.NoClassDefFoundError error.
    The code for the JNDI lookup is identical in either case.
    Any thoughts?

    Hello,
    I am calling ejb from .jsp use following code
    Properties props = new Properties();
    InitialContext ctx = new InitialContext();
    Object ob = ctx.lookup("java:comp/env/ejb/CalculatorBean");
    CalculatorHome home = (CalculatorHome) PortableRemoteObject.narrow(ob, CalculatorHome.class);
    calc = home.create();
    I have a error:
    java.lang.ClassNotFoundException: class com.sap.examples.calculator.beans.CalcProxy : com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at calculator, the whole lookup name is java:comp/env/ejb/CalculatorBean
    My ejb-jar.xml is:
    <display-name>
         CalculatorEjb</display-name>
         <enterprise-beans>
              <session>
                   <icon/>
                   <ejb-name>Calculator</ejb-name>
                   <home>com.sap.examples.calculator.CalculatorHome</home>
                   <remote>com.sap.examples.calculator.CalculatorRemote</remote>
                   <local-home>com.sap.examples.calculator.CalculatorLocalHome</local-home>
                   <local>com.sap.examples.calculator.CalculatorLocal</local>
                   <service-endpoint>com.sap.examples.calculator.CalculatorServiceEndpoint</service-endpoint>
                   <ejb-class>com.sap.examples.calculator.CalculatorBean</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
                   <ejb-ref>
                        <ejb-ref-name>ejb/CalculatorBean</ejb-ref-name>
                        <ejb-ref-type>Session</ejb-ref-type>
                        <home>com.sap.examples.calculator.CalculatorHome</home>
                        <remote>com.sap.examples.calculator.CalculatorRemote</remote>
                        <ejb-link>Calculator</ejb-link>
                   </ejb-ref>
                   <ejb-local-ref>
                        <description/>
                        <ejb-ref-name>ejb/CalculatorBean</ejb-ref-name>
                        <ejb-ref-type>Session</ejb-ref-type>
                        <local-home>com.sap.examples.calculator.CalculatorLocalHome</local-home>
                        <local>com.sap.examples.calculator.CalculatorLocal</local>
                        <ejb-link>Calculator</ejb-link>
                   </ejb-local-ref>
              </session>
         </enterprise-beans>
    my ejb-j2ee-engine.xml is:
    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-j2ee-engine
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ejb-j2ee-engine.xsd">
         <enterprise-beans>
              <enterprise-bean>
                   <ejb-name>Calculator</ejb-name>
                   <ejb-ref>
                        <ejb-ref-name>ejb/CalculatorBean</ejb-ref-name>
                        <jndi-name>ejb/CalculatorBean</jndi-name>
                   </ejb-ref>
                   <ejb-local-ref>
                        <ejb-ref-name>ejb/CalculatorBean</ejb-ref-name>
                        <jndi-name>ejb/CalculatorBean</jndi-name>
                   </ejb-local-ref>
              </enterprise-bean>
         </enterprise-beans>
    </ejb-j2ee-engine>

  • Generics via reflection and newInstance()

    I'm looking for a way, or a correct syntax, for 'genericizing' the
    class instantiation via Class#newInstance() method using reflection.
    The code shown below is an half-baked solution in that compiler emits
    unchecked cast warning against the cast on the 'obj' variable at the
    last part of the code.
    I think I have tried everyting conceivable for Class variable declarations
    and other part of the code but they were all futile. I lost one night
    sleep for that.
    If there are Java Generics gurus on the forum, please help!
    TIA.
    import java.util.*;
    import java.lang.reflect.*;
    public class GetMethod{
      public static void main(String[] args) {
        Object obj = null;
        Class<Hashtable> clazz = Hashtable.class;
        Class<Class> claxx = Class.class;
        try {
          Method method = claxx.getMethod("newInstance");
          obj = method.invoke(clazz);
        catch (Exception e) {
          e.printStackTrace();
        Hashtable<String,String> ht = (Hashtable<String,String>)obj;
        ht.put("foo", "bar");
        System.out.println(ht.get("foo"));
    }

    If you are preparing teaching material, then I would strongly suggest that you do not mix generics with reflection until both are very well understood.
    Using reflection to invoke reflection API methods (or any method known at compile time) as you did in your example, suggests that you do not understand enough yet.
    Because generics are a compile time mechanism and reflection is run time, many of the naive assumptions you might make just wont hold. Reflection is a mechanism for subverting the compiler, don't expect reflection and the compiler to have a harmonious relationship.
    Please remember when writing training material, that the code you use will be assumed by your students to be the best way to solve the problem it purports to solve. You need to bear this in mind when choosing code samples, not only must the sample illustrate the feature being taught, but it must be an appropriate application of that feature. If you do not choose appropriate problems to solve with your illustrative code, you will unwittingly train a generation of incompetents, whose code will be even stupider than yours.
    Bruce

  • Setting Fields value via reflection

    I'm starting from a c# code:
              internal void RefreshFromObject(object objFromUpdate)
                   if (this.GetType()==objFromUpdate.GetType())
                        PropertyInfo[] fieldsFrom = objFromUpdate.GetType().GetProperties();
                        PropertyInfo[] fieldsThis = this.GetType().GetProperties();
                        for(int idxProp=0; idxProp<fieldsFrom.Length;idxProp++)
                             if (fieldsThis[idxProp].CanWrite && fieldsFrom[idxProp].CanRead)
                                  fieldsThis[idxProp].SetValue(this, fieldsFrom[idxProp].GetValue(objFromUpdate,null),null);
                   else
                        throw new ObjectTypeNotValidException("Object type from which update current instance not valid. Use same type.");
    Now I have to translate it in Java:
    Class clazz = objFromUpdate.getClass();
    Class thisClazz = this.getClass();
    do {
         Field[] fieldsFrom = clazz.getDeclaredFields();
         Field[] fieldsThis = thisClazz.getDeclaredFields();
         try {
              fieldsThis[idxProp].set(thisClazz, fieldsFrom[idxProp].get(clazz));
         catch (IllegalAccessException iaccEx) {
              System.out.println("IllegalAccessException");
         catch (IllegalArgumentException iaccEx) {
              System.out.println("IllegalArgumentException");
    clazz = clazz.getSuperclass();
    thisClazz = thisClazz.getSuperclass();
    } while (clazz != null && clazz != Object.class);
    My problem is that I don't know if the field type is one of primitive, for which I should use the particular setters and getters.
    My questions are:
    1) is there in Java a more elegant way to set fields values via reflection?
    2) how can I know if a field i changable (equivalent to the method CanWrite of c#?
    Thanks a lot to each one that will answer me.
    Marco

    Hi georgemc,
    thanks for replying. I-m new with java forum, so I don't know if it is correct the code tags...
    Anyway... the problem is that the Field of reflected object could be both of Object types or primitive types. So I cannot use the general method "set" when changing Field's value.
    Maybe somebody else had the same problem...
    Seems in C# it is a very easy thing... not in java :(
    Marco
    Class clazz = objFromUpdate.getClass();
    Class thisClazz = this.getClass();
    do {
    Field[] fieldsFrom = clazz.getDeclaredFields();
    Field[] fieldsThis = thisClazz.getDeclaredFields();
    try {
    fieldsThis[idxProp].set(thisClazz, fieldsFrom[idxProp].get(clazz));
    catch (IllegalAccessException iaccEx) {
    System.out.println("IllegalAccessException");
    catch (IllegalArgumentException iaccEx) {
    System.out.println("IllegalArgumentException");
    clazz = clazz.getSuperclass();
    thisClazz = thisClazz.getSuperclass();
    } while (clazz != null && clazz != Object.class);

  • WDP calling EJB and passing objects of classes from Java project

    Hi.
    We have <b>Java</b> project which contains some classes common for all projects (like xxx.Version).
    We have <b>EJB</b> project which defines EJB interface using these common classes (like getVersion(String,int): xxx.Version and getCurrency(String,xxx.Version,int):xxx.Currency ).
    We have <b>Web Dynpro</b> project which calls EJB:
    1. Lookup is successful
    2. call to getVersion is successful
    3. call to getCurrency fails with <b>NoSuchMethodException</b>:
    xxx.XXXObjectImpl0.getCurrency(java.lang.String, xxx.Version, int)
         at java.lang.Class.getMethod(Class.java:986)
         at com.sap.engine.services.rmi_p4.reflect.LocalInvocationHandler.invokeInternal(LocalInvocationHandler.java:51)
         at com.sap.engine.services.rmi_p4.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:53)
         at $Proxy346.getCurrency(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)
         at $Proxy347.getCurrency(Unknown Source)
         at xxx.XXX.getCurrencyWrapper(XXXXX.java:24)
    How can I set dependencies to get this running?
    Thanks to all
           Volker

    Hi,
    Is it available in the interface you are using..
    If the answer is yes.. you might have probably forgotten to deploy the EJBs ear file after making the changes..
    Rebuild it.. and deploy the EJB s ear file again..
    It will solve the problem.. If that also does not work,it might be a problem with the cache.. restart the server..
    It should work now !
    Regards
    Bharathwaj

  • How to call Jakarta Ant via JAVA?

    Hi.
    My application has a new menu. This menu creates a build.xml Ant file.
    Now, when this menu is invoked , its action should call
    Jakarta Ant, after creating the xml file, so that the build.xml will
    do what is necessary.
    How can I do it? That is, how to call the Ant via java?
    Is there any way to use an Ant object?
    Thanks?
    Rodrigo Pimenta Carvalho.

    There is a slight problem in that
    PorjectHelper.configureProject is deprecated, but
    that is what Main calls...maybe someone else will
    complete this thread with an alternative call.The javadoc recommends using the non static method parse() instead. This is available by implementing class ProjectHelperImpl. An alternative to the code above might look like this:
            Project ant = new Project();
            ProjectHelper helper = new ProjectHelperImpl();
            ant.init();
            helper.parse(ant, new File("build.xml"));
            ant.executeTarget("clean");you might also want to add a logger so you can see the output of events generated by ant. The DefaultLogger class would be used like this. Simply add the code before you call the ant.init().
            DefaultLogger log = new DefaultLogger();
            log.setErrorPrintStream(System.err);
            log.setOutputPrintStream(System.out);
            log.setMessageOutputLevel(Project.MSG_INFO);
            ant.addBuildListener(log);

  • Java class calling ejb

    hi,
    i need to write a class file that calls an ejb. i found out that i need to include the context and also the object reference. but i still cant get it to call the ejb. does the class file need to be in the same folder as the ejbs?
    thanks

    this is my code
              Context initial = new InitialContext();
              Object obj = initial.lookup("WFBean");
              WF_RemoteHome home =     (WF_RemoteHome)PortableRemoteObject.narrow(obj,WF_RemoteHome.class);
                   WF_Remote wf = home.create();
                   int check = wf.getInfo("something");
                   if(check==0){
                        System.out.print("YES");
                   }else{
                        System.out.print("NO");
                   }however when i run it, it gives me this error
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
         java.rmi.RemoteException
         at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:188)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:172)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:119)
         at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:197)
         at com.WF_Remote_DynamicStub.getInfo(WF_Remote_DynamicStub.java)
         at watcher.extBean(watcher.java:100)
         at watcher.main(watcher.java:59)
    Caused by: java.rmi.RemoteException
         at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:234)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1280)
         at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:197)
         at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:107)
         at $Proxy552.getnfo(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)RemoteException occurred in server thread; nested exception is:
         java.rmi.RemoteException
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
         at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)how do i solve this? what i want to archieve is to be able to call the ejb which is in my local application server from my java class file so that i can make the class file run as a service.
    thanks

  • Error while calling COM routines via application prog(return code 1028533-)

    Hello Expert,
    In Interactive Demand Planning ( /SAPAPO/SDP94 ), when I'm trying to load data in a planning book , error
    'Error while calling COM routines via application program (return code 1028533-)' is encountered.
    In my selection id, i have only two locations....there is no material selection. 
    When I select the 1st location and load the data its getting loaded properly.....but when i select the 2nd location and try loading data ...the above error is coming.
    I did run /SAPAPO/TS_LCM_CONS_CHECK but the problem persist.
    Any advise to fix this issue would be much appreciated.
    Thanks.
    Tom

    Hi Tom,
    Please see if below exiting threads help you.
    COM error 40134 in Interactive Planning on SCM 5.0 Support Pack SAPKY50011
    Error for COM Routine application program (return code 40028)
    Thukral

Maybe you are looking for