Method.invoke causes IllegalArgumentException with subclass instance

Is there a way to use an instance of a subclass when using reflection to invoke a method?
Given the following code, I want to be able to use reflection to invoke the "doSomething" method within the Foo class. However, I want to use an instance of Bar as the parameter value when using reflection (since an instance of Bar is implicitly an instance of Foo; I have also tried casting the Bar instance, b, to Foo but this does not work). Doing this yields an IllegalArgumentException.
What am I missing? What am I doing wrong? What do I have to do in order to use an instance of Bar with "invoke"?
// Foo.java
package junk;
public class Foo
    private void doSomething(Foo f)
        System.out.println("Doing something with a " + f.getClass().getName());
    public static void main(String[] args)
        Foo f = new Foo();
        Bar b = new Bar();
        f.doSomething(f);   // Outputs "Doing something with a junk.Foo"
        f.doSomething(b);   // Outputs "Doing something with a junk.Bar"
        Class[] paramTypes = new Class[] { f.getClass() };
        Object[] paramValues = new Object[] { b };
        b.invokePrivateFooMethod("doSomething", paramTypes, paramValues); // Doesn't work
// Bar.java
package junk;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
public class Bar extends Foo
    public void invokePrivateFooMethod(String methodName,
                                       Class[] paramTypes,
                                       Object[] paramValues)
        try
            Foo localF = new Foo();
            Class classToUse  = localF.getClass();
            Method methodToUse = classToUse.getDeclaredMethod(methodName, paramTypes);
            methodToUse.setAccessible(true);    // override of private modifier
            methodToUse.invoke(classToUse, paramValues);
        catch (IllegalAccessException e)
            e.printStackTrace();
        catch (NoSuchMethodException e)
            e.printStackTrace();
        catch (InvocationTargetException e)
            e.printStackTrace();
}

Sorrry for the confusion. It's always the little things...
I neglected to use an instance of Foo to invoke the method.
See corrected code below:
// Bar.java
package junk;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
public class Bar extends Foo
    public void invokePrivateFooMethod(String methodName,
                                       Class[] paramTypes,
                                       Object[] paramValues)
        try
            Foo localF = new Foo();
            Class classToUse  = localF.getClass();
            Method methodToUse = classToUse.getDeclaredMethod(methodName, paramTypes);
            methodToUse.setAccessible(true);    // override of private modifier
            // NOTE:  Use localF, NOT classToUse!
            methodToUse.invoke(localF, paramValues);
        catch (IllegalAccessException e)
            e.printStackTrace();
        catch (NoSuchMethodException e)
            e.printStackTrace();
        catch (InvocationTargetException e)
            e.printStackTrace();
}

Similar Messages

  • Trouble invoking Axis service with multiple parameters

    Hallo Java experts,
    I have a problem with Axis 1.2RC2 (and Tomcat 5.0.19, JDK 1.5, Win XP) that might be quite simple, but I'm not so experienced and running out of ideas.
    Everything works fine as long as I use a single Parameter. But I can't invoke service methods with more parameters, independent of the parameters' (simple) types! Different exceptions are thrown, depending on the way I invoke the service. It's either ...
    - a java.lang.IllegalArgumentException (case 1)
    "Tried to invoke method public java.lang.String test.server.TestSoapBindingImpl.printLongs(long,long) with arguments java.lang.Long,null. The arguments do not match the signature."
    - or an org.xml.sax.SAXException (case 2)
    "SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize."
    Here's an example of a simple web service, that takes two longs and should return a string. In case 1 the service is invoked using a service locator in case 2 with a 'Call' object and explicitly set parameter types.
    Thanks in advance for your help!
    Dave
    service[b]
    public class TestSoapBindingImpl implements test.server.Test{
      public String printLongs(long long_1, long long_2){
        return "long_1 = " +long_1 +", long_2 = " +long_2;
    [b]case 1
    client
    public class TestClient {
      public static void main (String[] args) throws Exception {     
        TestService service = new TestServiceLocator();
        Test testProxy = service.gettest();     
        long longVal = 1L; 
        response = testProxy.printLongs(longVal, longVal);
        System.out.println(response);
    SOAP messsage
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <soapenv:Body>
          <in6 xmlns="urn:TestNS">1</in6>
          <in7 xmlns="urn:TestNS">1</in7>
       </soapenv:Body>
    </soapenv:Envelope>
    Axis' log file
    Part of the log, where only the first argument of 'printLongs' is properly converted before the exception is thrown.
    17886  org.apache.axis.utils.JavaUtils
            - Trying to convert java.lang.Long to long
    17886  org.apache.axis.i18n.ProjectResourceBundle
            - org.apache.axis.i18n.resource::handleGetObject(value00)
    17886  org.apache.axis.providers.java.RPCProvider
            -   value:  1
    17886  org.apache.axis.i18n.ProjectResourceBundle
            - org.apache.axis.i18n.resource::handleGetObject(dispatchIAE00)
    17986  org.apache.axis.providers.java.RPCProvider
            - Tried to invoke method public java.lang.String test.server.TestSoapBindingImpl.printLongs(long,long) with arguments java.lang.Long,null.  The arguments do not match the signature.
    java.lang.IllegalArgumentException
         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 org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:384)
          at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:281)
         at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:319)
         at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
         at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
         at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
         at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:450)
         at org.apache.axis.server.AxisServer.invoke(AxisServer.java:285)
         at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:653)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:301)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    case 2
    client
    public class TestClient2
      public static void main(String [] args) {
        try {
           String endpoint =
             "http://localhost:1234/axis1.2rc2/services/test";
           Service  service = new Service();
           Call     call    = (Call) service.createCall();
           call.setTargetEndpointAddress( new java.net.URL(endpoint) );
           call.setOperationName(new QName("urn:TestNS", "printLongs") );
           call.addParameter("in6",
                             org.apache.axis.Constants.XSD_LONG,
                             javax.xml.rpc.ParameterMode.IN);
           call.addParameter("in7",
                             org.apache.axis.Constants.XSD_LONG,
                             javax.xml.rpc.ParameterMode.IN);
           call.setReturnType(org.apache.axis.Constants.XSD_STRING);
           String response = (String) call.invoke( new Object[] { 1L, 1L } );
           System.out.println(response);
        } catch (Exception e) {
           System.err.println(e.toString());
    SOAP messsage
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <soapenv:Body>
          <ns1:printLongs soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:TestNS">
             <in6 href="#id0"/>
             <in7 href="#id0"/>
          </ns1:printLongs>
          <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</multiRef>
       </soapenv:Body>
    </soapenv:Envelope>
    Exception
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
    faultActor:
    faultNode:
    faultDetail:
         {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
      at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:143)
      at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1031)
      at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
      at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1140)
      at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:238)
      at org.apache.axis.message.RPCElement.getParams(RPCElement.java:386)
      at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:148)
      at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:319)
      at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
      at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
      at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
      at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:450)
      at org.apache.axis.server.AxisServer.invoke(AxisServer.java:285)
      at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:653)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
      at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:301)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      ....

    Dave, not sure if you still are looking for an answer but i hate seeing unreplied posts so i felt i needed to post something. I'm just beginning with this stuff as well so take my suggestions with a grain of salt....or a beer. Anyways, case 2 would show that you are getting your parameters through properly because the "deserialization" errror is targetted towards the soap reply. Most likely you are trying to receive back a none primitive type. :-D i.e. such as the problem that i'm having.
    hope that helps somewhat.
    graeme.

  • How to trap null return values from getters when using Method.invoke()?

    Hi,
    I am using Method.invoke() to access getters in an Object. I need to know which getters return a value and which return null. However, irrespective of the actual return value, I am always getting non-null return value when using Method.invoke().
    Unfortunately, the API documentation of Method.invoke() does not specify how it treats null return values.
    Can someone help?
    Thanks

    What do you get as a result?I think I know what the problem is.
    I tested this using following and it worked fine:
    public class TestMethodInvoke {
    public String getName() {
    return null;
    public static void main(String args[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    Object o = new TestMethodInvoke();
    Class cls = o.getClass();
    Method m = cls.getMethod("getName", (Class[]) null);
    Object result = m.invoke(o, (Object[])null);
    if (result == null) {
    System.err.println("OK: Return value was null as expected");
    else {
    System.err.println("FAILED: Return value was NOT null as expected");
    However, when I use the same technique with an EJB 3.0 Entity class, the null return value is not returned. Instead, I get a String() object. Clearly, the problem is the the EJB 3.0 implementation (Glassfish/Toplink) which is manipulating the getters.
    Regards
    Dibyendu

  • Java.lang.NoSuchMethodException Using Method.invoke(...)

    I try to use Method.invoke() to invoke a method from a class. The method
    has parameters with type JTextArea and JMyFrame, but I got the error
    messages java.lang.NoSuchMethodException . Any ideas???
    If I remove parameter "JFrame mainFrame" in start() method and it is working fine. Not sure why JMyFrame will throw this exception, as JMyFrame is derived from JFrame class
    public class MyFrame extends JFrame
         try
    ClassLoader loader
    = new MyClassLoader(Integer.parseInt("3"));
    Class c = loader.loadClass("NewMenuPackage.NewMenu");
    Class[] params = { JTextArea.class, JMyFrame.class };
         Method m = c.getMethod("start", params);
         Object obj = c.newInstance();
    m.invoke(obj,
         new Object[] {
              textArea,
              JMyFrame.this
    catch (Throwable e)
    JOptionPane.showMessageDialog(this, e);
    package NewMenuPackage;
    import javax.swing.*;
    public class NewMenu
         private static JMenuItem menuItem = new JMenuItem("New Menu");
         public static JMenuItem getJMenuItem()
              return menuItem;
         public static void start(JTextArea textArea, JFrame mainFrame)
              System.out.println("NewMenu->start()...");
    }

    Your "params" Class array has to specify the exact classes of the method, not subclasses. The line that is causing the NoSuchObjectException to be thrown is "c.getMethod("start", params);".
    You have to write your own reflection utility methods to find a method that matches on parameter subclasses.

  • Subclass instance not created during runtime

    Hi Experts,
    For an existing standard class a subclass was created and during runtime the me object reference points to the subclass name there by allowing the subclass additional/custom methods to be triggered.
    We have done service pack upgrade in the system and during runtime I find the subclass does not exist in the me object reference due to which the custom code in the subclass is not being called.
    How do I fix the above issue so that and subclass instance is created by the superclass during runtime?

    Hello Srinivas,
    I had put a breakpoint to debug in the subclass which was being invoked.
    In the new system where the service pack has been applied I have put breakpoint in the same method but the subclass method is not being called.
    The superclass method is being called. I'm sure after facing this problem(and solving it, of course) you'll have a better understanding of the 'polymorphic' behaviour of objects
    if the subclass inherits superclass the instance will be created automatically?
    NO!!!
    You must understand none of us has a crystal ball where we can gaze & find out the solution. If you want valuable responses please provide as much info as possible.
    BR,
    Suhas

  • Get error while invoking a page with "create"

    I get this error while invoking a page with "create". Also please any one tell me where is the log file is place to see the full story.
    ]] Root cause of ServletException.
    javax.el.PropertyNotFoundException: Target Unreachable, 'Comments' returned null
         at com.sun.el.parser.AstValue.getTarget(AstValue.java:88)
         at com.sun.el.parser.AstValue.isReadOnly(AstValue.java:126)
         at com.sun.el.ValueExpressionImpl.isReadOnly(ValueExpressionImpl.java:230)
         at oracle.adfinternal.view.faces.renderkit.rich.EditableValueRenderer.getReadOnly(EditableValueRenderer.java:400)
         at oracle.adfinternal.view.faces.renderkit.rich.FormElementRenderer.renderAsElement(FormElementRenderer.java:199)
         Truncated. see log file for complete stacktrace
    If i use a "create button then it does not throw error.
    Please help.

    When you are invoking your page, does your view object has an empty row where data can go and presist?
    Create a an empty row in your view object(vo.createRow()) , or use create operation from data control palette.
    You can set the log in Tools->Preferences-->Environment-->Log.
    Regards,
    Vikram

  • Invoke web service with DTO

    Hey guys,
    I am quite new in using BPEL. My first test worked fine, but know I have an issue, which I can not solve. Invoking web services with a basic return value is no problem. I could also you a dto object including some basic variables in order to invoke the web service without having problems.
    But when I have a dto object as return value, I get the following exception.
    Could someone give me a hint to fix my problem...that would be great!
    Thanks alot!
    Sven
    <messages>
    - <input>
    - <carReserveRequest>
    - <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="in0">
    - <in0 xmlns="" xmlns:def="urn:TravelBooking" xsi:type="def:CarReservationDTO" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <carType>
    Mini
    </carType>
    <customerName>
    9
    </customerName>
    <customerPhone>
    9
    </customerPhone>
    <reservationEnd>
    2030-12-12T00:00:00.000+01:00
    </reservationEnd>
    <reservationStart>
    2029-12-12T00:00:00.000+01:00
    </reservationStart>
    </in0>
    </part>
    </carReserveRequest>
    </input>
    - <fault>
    - <remoteFault xmlns="http://schemas.oracle.com/bpel/extension">
    - <part name="summary">
    <summary>
    exception on JaxRpc invoke: trailing block elements must have an id attribute
    </summary>
    </part>
    </remoteFault>
    </fault>
    </messages
    Message was edited by:
    user606281

    Here is more information. Below are the relevant sections of the web service's WSDL which I am trying to call from BPEL:
    - <wsdl:message name="getNextIDResponse">
    <wsdl:part name="part1" element="ns0:getNextIDResponse" />
    </wsdl:message>
    - <wsdl:message name="getNextIDFault">
    <wsdl:part name="part1" element="ns0:SOAPExceptionFault" />
    </wsdl:message>
    <wsdl:message name="getNextIDMessage" />
    - <wsdl:portType name="GetUniqueIDPortType">
    - <wsdl:operation name="getNextID">
    <wsdl:input message="axis2:getNextIDMessage" wsaw:Action="urn:getNextID" />
    <wsdl:output message="axis2:getNextIDResponse" />
    <wsdl:fault name="getNextIDFault" message="axis2:getNextIDFault" />
    </wsdl:operation>
    </wsdl:portType>

  • Access of undefined method/property through reference with a static type Class

    I get the following error: (it's not word for word but you get the idea)
    Error: Access of undefined method getStatus through reference with a static type Class.
    Here's what's happening in the code. I'm trying to create a User class that is instantiated at the start of my app. I want the User class to have properties like mainStatus, with helper methods like setStatus etc. Pretty simple.
    so on my HardDisk I have my flash_working folder with all my flash projects. I created my class file/package under the directory com.mypackage
    package com.mypackage
        import flash.display.*;
        public class User extends Sprite
            public var mainStatus:int;
            public function User()
                trace("User Created!");
                mainStatus = 0;
            public function setStatus(status:int):void
             mainStatus = status;
        public function getStatus():int
            return mainStatus;
    Ok, so far so good.
    now I created a new .fla file under the root of /flash_working/. The class file is in /com/mypackage/User.as
    in my .fla file I have:
    import com.mypackage.User;
    var myUser:User = new User();
    var i = User.getStatus();
    trace(i);
    That's all the code I have. Could someone please explain why it's giving me that error?
    If I try to access the public var mainStatus through user.mainStatus that gives a similar error saying:
    Error: Access of undefined property mainStatus through reference with a static type Class.
    Thanks for any help!
    jef3189

    the public getStatus() function that you created needs to be referred to through an instance of the class.
    So:
    import com.mypackage.User;
    var myUser:User = new User();
    var i = myUser.getStatus();
    trace(i);
    Also, an aside. You can create a getter/setter for status, to avoid having to do the function as such.
    package com.mypackage
        import flash.display.*;
        public class User extends Sprite
            public var mainStatus:int;
            public function get status():int
                return mainStatus;
            public function set status(value:int):void
                 mainStatus = value as int;
              public function User()
                trace("User Created!");
                mainStatus = 0;
    And then, you can call it as:
    import com.mypackage.User;
    var myUser:User = new User();
    trace(myUser.status);
    EDIT
    I just noticed that you made the variable public as well, which means you can access it without getter/setter or function.
    import com.mypackage.User;
    var myUser:User = new User();
    trace(myUser.mainStatus);

  • How does 1 ASM instance in a 10 node RAC cause all 10 ASM instance to hang

    Linux RHEL4
    11.2.0.1.0 GI
    11.2.0.1.0 RDBMS
    11.1.0.7.0 RDBMS
    10.2.0.4.4 RDBMS
    Yesterday we had one of the ASM instance on our 10-node cluster hang with a latch "ASM file allocation latch". Oracle support has stated we are hitting a bug with is fixed in the latest PSU.
    What I am trying to understand is how a latch on one ASM instance caused all 10 ASM instances to hang?
    Oracle Supports explanation still does not answer how all 10 ASM instance were affected other then the faulty code that the patch fixes. Bellow is info out of the SAR.
    Data Guard Site:
    ================
    ARC1 PID 21508 reports ORA-240 'control file enqueue held for more than 120 seconds' at Thu Oct 28 11:35:54 2010. This message means ARC1 PID 21508 was holding the enqueue past the maximum tine limit of 120 seconds.
    Next ARC0 PID 17398 reports ORA-16146: 'control file enqueue unavailable' at Thu Oct 28 11:36:52 2010. This means ARC0 PID 17398 tried to access the controlfile and it could get the lock.
    ARC1 PID 21508 is then killed at Thu Oct 28 11:49:57 2010.
    Killing enqueue blocker (pid=21508) on resource CF-00000000-00000000 by (pid=23078) by killing session 5.3
    We see that RSM has been restarted by Broker. This matches to the alert.log and messages showing RSM being restarted several time. i.e. RSM0 started with pid=84, OS id=27915
    Since this started happening around 11:14, the problem may have really started then instead of w/ the CF enqueue block.
    The primary appears to be shipping redo to the standby using asynchronous mode. Unless there was a gap, I do no know if ARC1 should have been doing any remote network I/O. Because a log switch to thread 1 sequence 5235 had just happened at 11:33am, I suspect it was a local disk I/O that was started at least. The ORA-240 is reported at 11:35, exactly 120 sec (or 2min) from this log switch. Notice also the entry to show the log thread 1 sequence 5234 was registered to the controlfile didn't happen yet.
    ASM Side:
    ============
    From the systemstate dump on ASM, multiple processes are waiting on 'ASM file allocation latch' and we are kind of stuck on stack:
    ksedsts()+461<-ksdxfstk()+32<-ksdxcb()+1782<-sspuser()+112<-0000003218E0C5B0<-kfuhInsert()+175<-kffilCreate()+601<-kfnsUFG()+3691<-kfnsBackground()+4382<-kfnDispatch()+527<-opiodr()+1149<-ttcpip()+1251<-opitsk()+1633<-opiino()+958<-opiodr()+1149<-opidrv()+570<-sou2o()+103<-opimai_real()+133<-ssthrdmain()+214<-main()+201<-__libc_start_main()+219
    This caused the hang on the ASM side and hence ASM was not responding to the database. The CF Enqueue issue on the database was a side effect of this.
    This is a direct <BUG:9232266> which is a duplicate of <BUG:8974548>

    Thanks Murali,
    I was little reluctent to open a tar since my experince says that its better to troubleshoot the issue yourself instead of spending time with the Oracle support :)
    Well, I got some more information on this : the sql for the process id of ASM instance is :
    Alter Diskgroup mount all;
    It looks like it is unable to mount the diskgroup and get hunged at that point , is it due to the new disk added to the system or do we missed something after adding the new disk.
    Also, the ASM process can not be killed from unix box while the ASM is down.
    Will appreciate your time if we can move in any directions from here ..
    Thanks ,
    Ankur

  • Problem with Subform Instances at First Opening

    Hi All,
    I have a large, complex form that has several subforms that I need to have zero instances the first time the form is opened. Most of those subforms that I set the initial instances = 0 on the Object pallet do exactly that--they behave and open with zero instances! However, I have one subform that always starts with an instance (1 instance instead of zero instances). I really don't want to work-around this, as I have done in the past when this has heppened. I want to solve it.
    I have tried
    Unwrapping the subform and the re-wrapping in a new subform
    Manually editing the <occur/> element in the XML for the subform.
    repeatedly trying different things in the Object pallet--the initial count checkbox always reverts to unchecked and the count to blank--I actually see it un-checking itself and removing the "0", right after I return to Design View from the Preview. This even happens after I have manually set the values in the XML. I double-check the Object pallet to see that my edits are reflected there (they are) and then... upon returning from Preview, it reverts and my <occur/> edit vanishes.
    I have looked for scripts that might be causing this--without any luck.
    I have encountered this sort of thing before and finally gave up and used the "presence" property as a work-around. The subforms don't always get utilized by the user and they should only exist when the user needs them. I will be exporting the XML data out of this form and exporting a lot of empty elements just presents another problem I'd like to avoid.
    Any suggestions are most welcome. I hope someone knows of a solution--I have spent way too much time on this.
    Cheers,
    Stephen

    Hi,
    Thanks kjaeggin and Bruce,
    I have the checkBoxes unchecked and the occur element is <occur min="0" max="-1"/> .
    Actually, this is the way the checkBoxes and XML have been all along and the results are what what I have previously described.
    One of my attempts to fix this was manually adding the "initial" attribute to the <occur/> element (by directly editing since it won't stick in the Object pallet)
         <occur min="0" max="-1" initial="0"/> that the edit reverts to <occur min="0" max="-1"/>.
    Also I have tried
         <occur min="0" max="1" initial="0"/> this is what I really want (max="1") and it reverts to <occur min="0" max="-1"/> as well
    And
         <occur min="0" max="1"/> reverts to <occur min="0" max="-1"/>
    The documentation for scripting the "initial" property of an object says:
         "This property should be used only for printed and static forms."
    This doesn't make sense to me because static forms don't have repeating containers, so why would you need/use it?
    Finally, to rule out that there is a script or property within mySubform causing this, I have set the presence property for all the subforms contained within mySubform to Inactive (Exclude from form processing) leaving only a single static object to be rendered if there is an instance of mySubform. (Bruce, I am not sure you have this on LCD 9. It is in ADEP Designer 10 and is supported by the target version). The result is the same--I see the first static object GrandParent.Parent.mySubform.staticObject but when I add a GrandParent I see GrandParent.Parent.nothingElse -- the added GrandParent doesn't have a mySubform. So it only misbehaves when the form is first opened, not when a GrandParent is added.
    I have removed global bindings from the few objects in mySubform that have them--no change. I have commented out the 1 script in mySubform that runs at form:ready--no change. I am going to look at scripts outside mySubform that get values from objects within mySubform, to see if somehow that is where the answer is. I would think that scripts would impact new instances of GrandParent, as well. I've looked at all other form:ready scripts and none interacts with or get values from mySubform.
    I think I may just have to settle for a work-around. Sure would like to know whats going on here, though.
    Thanks,
    Stephen

  • Problem with Subform Instances at Form Opening

    Hi All,
    I have a fairly large complex form that has several subforms that I want to have zero instances the first time it is opened. Most of those subforms that I set the initial instances = 0 on the Object pallet do exactly that--they behave! However, I have one subform in particular that no matter what I do, it always starts with an instance. I really don't want to work-around this, as I have done in the past when this happens. I want to solve it.
    I have tried
    Unwrapping and the re-wrapping in a subform
    Edited the <occur/> element in the XML for the subform.
    repeatedly trying different combinations of min count, max and initial count values in the Object pallet--the initial count checkbox always reverts to unchecked and the count to blank--I actually see it un-checking itself and removing the "0", right after I return to Design View from the Preview. This even happens after I have manually set the values in the XML, double-checked the Object pallet to see that my edits are reflected there (they are) and then... upon returning from Preview, it reverts and my <occur/> edit vanishes.
    I have searched for some offending script that might be causing this--but there is nothing that fires automatically tied to the instances of the subform. There are initialize, formReady and calculate scripts on objects in the subform, but nothing tied directly related to the instances of the subfom?
    I have encountered this sort of thing before and used the "presence" property as a work-around. I will be exporting the XML data out of this form and I don't want a bunch of empty elements to deal with.
    Any suggestions (besides "have you considered being a gardener?") are most welcome. I hope someone knows of a solution--I have spent way too much time on this.
    Cheers,
    Stephen

    Hi All,
    I have a fairly large complex form that has several subforms that I want to have zero instances the first time it is opened. Most of those subforms that I set the initial instances = 0 on the Object pallet do exactly that--they behave! However, I have one subform in particular that no matter what I do, it always starts with an instance. I really don't want to work-around this, as I have done in the past when this happens. I want to solve it.
    I have tried
    Unwrapping and the re-wrapping in a subform
    Edited the <occur/> element in the XML for the subform.
    repeatedly trying different combinations of min count, max and initial count values in the Object pallet--the initial count checkbox always reverts to unchecked and the count to blank--I actually see it un-checking itself and removing the "0", right after I return to Design View from the Preview. This even happens after I have manually set the values in the XML, double-checked the Object pallet to see that my edits are reflected there (they are) and then... upon returning from Preview, it reverts and my <occur/> edit vanishes.
    I have searched for some offending script that might be causing this--but there is nothing that fires automatically tied to the instances of the subform. There are initialize, formReady and calculate scripts on objects in the subform, but nothing tied directly related to the instances of the subfom?
    I have encountered this sort of thing before and used the "presence" property as a work-around. I will be exporting the XML data out of this form and I don't want a bunch of empty elements to deal with.
    Any suggestions (besides "have you considered being a gardener?") are most welcome. I hope someone knows of a solution--I have spent way too much time on this.
    Cheers,
    Stephen

  • Method.invoke

    Hi,
    I'm trying to dynamically load various classes at runtime but have encountered a problem with the Method.invoke() method.
    Class c = Class.forName( "car" );
    Method m = c.getDeclaredMethod("Execute", new Class [] { String.class } );
    object res = m.invoke( Object obj, Object[] arg); // here is the problemI do not know what parameters to set inside Method.invoke(). Looking for some advice here. All the classes that I want to load implement an interface;
    interface loadplugin
       boolean Execute(String str);
    }Any suggestions?

    Hi,
    You put the parameters the Method needs to the Object [] -
    This is a call you know:
    loadplugin myLoadPlugin = new LoadpluginImplementingClass();
    boolean result = myLoadplugin.Execute("Hallo World");The corrsponding call to the Method object is:
    Boolean result = (Boolean)m.invoke(myLoadpugin, new Object[]{"Hallo World"}); The Method object only can hanlde Object types. For any standard data type (int, boolean, double, etc.) the corresponding Wrappers have to be used. So the return in case of the Method-Object call is Boolean, not boolean.
    I hope this helps,
    Lars.

  • BPEL to invoke Webservice secured with HTTP Basic authentication

    Hi All,
    Iam trying to call a Synchronous BPEL porcess from BPEL by passing HTTP basic authentication.I have done below steps to achieve this.
    1) Created Target Synchronous process ex : B
    2) Created Source Syncronous Process ex : A
    Iam trying to call B(Target) from A(source).
    3) Open Composite.xml of A(Source)
    4) Right Click on External Refernce B(Target) parter link and click Configure WS policies
    5) Under Security tab attach oracle/wss_username_token_client_policy
    6) Login to em/console
    7) Right click on A(Source) Composite and click Service/Refence Properties>>B(Target)
    8) Enter username and password under HTTP Basic Authentication.
    9)Test from em.console(when we are testing under security tab I have checked None radio button)
    So this is the Error message which is throwing.
    ==================================
    The selected operation process could not be invoked.
    An exception occured while invoking the webservice operation. Please see logs for more details.
    oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: SOAP must understand error:{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security, {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security.
    java.lang.Exception: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: SOAP must understand error:{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security, {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security. at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:570) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:381) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:298) 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:597) at com.sun.el.parser.AstValue.invoke(AstValue.java:157) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283) at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53) at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1245) at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:87) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:298) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:91) at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:87) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:87) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:298) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:91) at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:81) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:673) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:273) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:165) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420) at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:54) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157) at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.help.web.rich.OHWFilter.doFilter(Unknown Source) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.emSDK.license.LicenseFilter.doFilter(LicenseFilter.java:101) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.emas.fwk.MASConnectionFilter.doFilter(MASConnectionFilter.java:41) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:159) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.AuditServletFilter.doFilter(AuditServletFilter.java:179) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.EMRepLoginFilter.doFilter(EMRepLoginFilter.java:203) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.core.app.perf.PerfFilter.doFilter(PerfFilter.java:141) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.ContextInitFilter.doFilter(ContextInitFilter.java:527) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) Caused by: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: SOAP must understand error:{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security, {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security. at oracle.sysman.emas.model.wsmgt.PortName.invokeOperation(PortName.java:712) at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:564) ... 68 more Caused by: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: SOAP must understand error:{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security, {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security. at oracle.sysman.emSDK.webservices.wsdlapi.dispatch.DispatchUtil.invoke(DispatchUtil.java:260) at oracle.sysman.emSDK.webservices.wsdlparser.OperationInfoImpl.invokeWithDispatch(OperationInfoImpl.java:843) at oracle.sysman.emas.model.wsmgt.PortName.invokeOperation(PortName.java:664) ... 69 more Caused by: javax.xml.ws.soap.SOAPFaultException: SOAP must understand error:{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security, {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security. at oracle.j2ee.ws.client.jaxws.DispatchImpl.throwJAXWSSoapFaultException(DispatchImpl.java:874) at oracle.j2ee.ws.client.jaxws.DispatchImpl.invoke(DispatchImpl.java:707) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.synchronousInvocationWithRetry(OracleDispatchImpl.java:226) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.invoke(OracleDispatchImpl.java:97) at oracle.sysman.emSDK.webservices.wsdlapi.dispatch.DispatchUtil.invoke(DispatchUtil.java:256) ... 71 more
    =======================================
    Please let me know if Iam missing any steps.
    Thanks
    SSV

    Followed this post.......
    This is avery good question
    in 11g i have taken out the steps from my document which i created for one our customer
    go to composite
    Right click on the external reference service and select “Configure WS policies” :done
    Under the security tab, click add button and select “oracle/ wss_username_token_client_policy :done
    6. Now Open the property Inspector window and click the add button under “Binding properties” tab. :done
    7. Include the “oracle.webservices.auth.username--> :done
    value-->password :done
    8. Include the “oracle.webservices.auth.password”-->name :done
    value-->password :done
    Thanks
    SSV

  • Using Reflection - Method.invoke()

    Hi all,
    Facing a problem in using the Reflection API. Can anyone tell me how to use the invoke, which is available with Method. Problem statement. - I want to create a method. And then invoke that method using method1. invoke. But this can take only the following arguments - (Object, Object [ ] ). I cant figure out why I need to pass on an object ? and an array of objects ?

    If you read the docs for Method.invoke, you'll see that the first argument is the object on which you wish to invoke the method, and the second argument is the parameters (with primitives wrapped appropriately).
    foo.bar("abc", 123);
    // becomes
    meth.invoke(foo, new Object[] {"abc", new Integer(123) }); (if I haven't screwed up the syntax of the array initialization)
    http://java.sun.com/docs/books/tutorial/reflect/

  • Method.invoke() thread save ?

    Hi to you all,
    Is the method invoke on the Object Method in the java.lang.reflect package threadsafe ?
    Greetz-tbone

    I'have created a with a college a ReflectionMap where getter and setter maps to the javabean properties
    using reflection at creation time the map cache the methods of the underlaying object
    now we want to use it i a multiple thread context
    where more than one thread can access the map a time
    if the implementation of Method is threadsafe then we do not need synchronisation else
    we must synchronize our map.
    and sinds that synchronisation is a performence bottleneck i would like to live it out.
    Tbone

Maybe you are looking for