Problem in dynamic method execution???????
Hi,
I am facing the problem in selecting the method at run time.
I have a class with methods like myMethod1,myMethod2,myMethod3,myMethod4....
In my program I am receiving a parameter. for e.g. "2"
Then I want to execute myMethod2.
I am doing it this way "myMethod"+"2"+"()". But its not working .
Canany body help me out.
Thanks in Advance
To expand on schapel.
myObject.getClass().getMethod("myMethod2", new Class[0]).invoke(myObject, new Object[0]);will invoke the method called "myMethod2" on the Object myObject. The Class[] and Object[] arrays hold the ordered parameter types and values for the method respectively. In this case, myMethod2 is assumed to have no parameters.
Primitive parameters/return values in the reflection API are replaced by their wrapper classes. As an example, if I have a method called getInt on the class MyClass that takes a float and returns an int, then you would invoke it thus:
Integer i = new Integer(12);
Method m = MyClass.class.getMethod("getInt", new Class[]{ Float.TYPE });
Float float = (Float)m.invoke(myClassInstance, new Object[]{ i });
Float f = float.floatValue();When dynamically invoking a static method, you can supply null as the instance upon which to invoke the method
Similar Messages
-
BI Transport Req Error 8 - Error in Import and Method Execution
Hi All,
I have collected the Update Rule in a Transport Request. The Update Rule has couple of lookup routine(s) for the data and key field.
When Moved the transport request to Quality the same is ending with error 8.
Error at the time of Import
R3TRROUT 3AQ..........was repaired in this system
Object R3TRROUT 3AQ.......... is in repair status. Therefore cannot be imported
Procedure: If you still want to import release the relevant repair and repart the import
Error message at Method Execution Log
Object ROUT 3AQ.... has not been imported successfully
The Object R3TRROUT 3AQ.......... has not yet been imported without error.
Import Post Processing is not performed for this InfoObject.
Note : I have tried this couple of times but the error remains same. Checked the Routines in development and quality and they are all same....Could not able to analyse what exactly is the error.
Please help. I am not able to understand how to go a head.Dear Pavan,
Iu2019m going try to help you regarding your question,
I have been a similar problem with transformation, the transport request after accept in the system target have given a similar error. I have fixed following the next step:
u2022 I activating again the source and target, if those source and target was changed it is important to transport before the update rule.
u2022 When you are sure that you have the same source and target in both systems, furthermore both have been activated, you can move on with the transport request of update rule.
I hope this suggestion can help you to answer your question,
Luis -
Question on Dynamic SQL Execution
Hi,
Our company is currently using Oracle 7 but will move to Oracle 8i soon. I am trying to execute a dynamic SQL statement in a function and it always error-out during execution. The SQL statement is NOT doing any update to a table. Its doing a select only. The function is being called during an execution of another dynamic SQL statement in a procedure. Here are examples of the code listing for the procedure and function:
CREATE OR REPLACE PROCEDURE TEST_PROC
lookup_cursor integer;
ignore integer;
VARvalue number;
begin
lookup_cursor := DBMS_SQL.open_cursor;
DBMS_SQL.PARSE( lookup_cursor,
'SELECT ' || TEST_FUNCTION || ' FROM DUAL,
DBMS_SQL.NATIVE);
DBMS_SQL.DEFINE_COLUMN( lookup_cursor, 1, VARvalue);
ignore := DBMS_SQL.EXECUTE(lookup_cursor);
loop
IF DBMS_SQL.FETCH_ROWS(lookup_cursor) > 0 THEN
DBMS_SQL.COLUMN_VALUE(lookup_cursor, 1, VARvalue);
ELSE
EXIT;
END IF;
END LOOP;
DBMS_SQL.CLOSE_CURSOR(lookup_cursor);
end TEST_PROC;
CREATE OR REPLACE PROCEDURE TEST_FUNCTION
lookup_cursor integer;
ignore integer;
VARvalue number;
VARsql_string VARCHAR2(200);
begin
lookup_cursor := DBMS_SQL.open_cursor;
VARsql_string := SOME GENERATED SQL STATEMENT;
DBMS_SQL.PARSE( lookup_cursor,
VARsql_string,
DBMS_SQL.NATIVE);
DBMS_SQL.DEFINE_COLUMN( lookup_cursor, 1, VARvalue);
ignore := DBMS_SQL.EXECUTE(lookup_cursor);
loop
IF DBMS_SQL.FETCH_ROWS(lookup_cursor) > 0 THEN
DBMS_SQL.COLUMN_VALUE(lookup_cursor, 1, VARvalue);
ELSE
EXIT;
END IF;
END LOOP;
RETURN VARvalue;
end TEST_FUNCTION;
The error I received during execution of TEST_PROC is:
ORA-06571: Function TEST_FUNCTION does not guarantee not to update database
ORA-06512: at "SYS.DBMS_SYS_SQL", line 239
ORA-06512: at "SYS.DBMS_SQL", line 32
It may seem like the example procedure doesnt need to use a dynamic SQL execution to call TEST_FUNCTION but the actual code that I extracted from does.
Does Oracle 7 always treat the dynamic SQL command set as some kind of update statement? Is that a bug? I understand that the EXECUTE IMMEDIATE command in Oracle 8i will replace the old command set found in the above examples. Will using the new EXECUTE IMMEDIATE command in Oracle 8i solve this problem?
Thank you for any help,
TonyIn Oracle 7, for a function to be called from a select statement it has to follow the 'purity rule' that it does not modify any database table or package variable.
Probably you will have to use the compiler directive PRAGMA RESTRICT_REFERENCES (WNDS,WNPS) on your TEST_FUNCTION so that it can be called within a SQL statement.
This restriction is removed in Oracle 8i onwards.
Hope this solves your problem.
Regards -
Import and Method Execution Error (8)
Hi,
I having problem in BI 7. when I transport all objects in one transport number such as
DOSTransformationDTPDSInfoPackage and transport in QA works fine
but when I move in PRD no efect in there and get this messages:
Method Execution with error (8)
I check transport layer and other setting everying is ok... please advised me what should I do
Thank in Advance
AngelineHi,
Check the correct Error log in STMS_IMPORT and then select your error req and click on Log and expand teh message and see the exact error message and corretc it and re transport it.
Don't mix all obejcts in single request.
First Transport the Package then
1. InfoObejcts.
2. Cubes, DSO's
3.DataSources from ECC Dev to ECC Qty
4. DataSource Replication in BW Qty
5. InfoSources.
6.Transformations in between DataSource and InfoSource.
7.Transformations in between InfoSource and InfoCube/DSO.
8. DTP's & InfoPackages.
9. Multiproviders/InfoSets.
10. Reports.
Thanks
Reddy -
BP_....AccountActivitiesOV.htm....application BPBT.
what could be wrong? An attempt was made to execute a dynamic method callon an initial(NULL-) object reference. The reference must refer to an object???Hi Dunamis,
Please check if below links can help you;
Error on execution of Web Interface
Help! I meet this Business Server Page (BSP) error CX_SY_REF_IS_INITIAL
Strange Error in Transformation of 2LiS_03_BF with 0IC_C03
Regards,
Kamfrk. -
Stop the method Execution.
Hi..
I have a method call to make a credit card payment.sometimes it takes so much times.If that process takes more than 10 minutes,
I want to stop that method execution.I have implemented the TimerTask to check the execution time and stop..but I don't have a idea to stop that processing method...
can anyone give me a suggetion.
Regards
AmilaHi,
You may have a look at this thread [http://forums.sun.com/thread.jspa?threadID=5347956&tstart=0]
I changed the suggested code a little to make it (hopefully) suitable for your use case. Note that the long running task communicates to its invoker via System.out.
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
public class TaskDispatcher {
private static long lengthy = 10000;
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new TaskDispatcher().createGUI();
private JTextPane textPane;
private JLabel message;
private Process process;
private Action kill = new AbstractAction("Kill") {
private static final long serialVersionUID = 1L;
this.setEnabled(false);
@Override
public void actionPerformed(ActionEvent event) {
destroy();
private Action dispatch = new AbstractAction("Dispatch") {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent event) {
dispatch();
public void createGUI() {
JFrame frame = new JFrame();
textPane = new JTextPane();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
message = new JLabel("Status", JLabel.CENTER);
JToolBar toolBar = new JToolBar();
frame.add(toolBar, BorderLayout.PAGE_START);
frame.add(new JScrollPane(textPane), BorderLayout.CENTER);
frame.add(message, BorderLayout.PAGE_END);
toolBar.add(dispatch);
toolBar.add(kill);
frame.setSize(400, 400);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
private void appendLine(String line) {
Document doc = textPane.getDocument();
try {
doc.insertString(doc.getLength(), line + "\n", null);
} catch (BadLocationException e) {
e.printStackTrace();
private void destroy() {
kill.setEnabled(false);
process.destroy();
dispatch.setEnabled(true);
private void dispatch() {
dispatch.setEnabled(false);
try {
textPane.setText("");
launch();
kill.setEnabled(true);
} catch (IOException e) {
e.printStackTrace();
dispatch.setEnabled(true);
private void handleErr(final Process process) {
new Thread(new Runnable() {
final BufferedReader errReader;
errReader = new BufferedReader(new InputStreamReader(process
.getErrorStream()));
@Override
public void run() {
try {
String line = null;
while ((line = errReader.readLine()) != null) {
System.err.println("Other JVM: " + line);
} catch (Throwable t) {
t.printStackTrace();
} finally {
try {
errReader.close();
} catch (IOException e) {
e.printStackTrace();
}).start();
private void handleOut(final Process process) {
new Thread(new Runnable() {
final BufferedReader outReader;
outReader = new BufferedReader(new InputStreamReader(process
.getInputStream()));
@Override
public void run() {
try {
String line = null;
while ((line = outReader.readLine()) != null) {
appendLine(line);
} catch (Throwable t) {
t.printStackTrace();
} finally {
try {
outReader.close();
} catch (Throwable t) {
t.printStackTrace();
}).start();
private void launch() throws IOException {
final String command;
command = "java -cp \"" + System.getProperty("java.class.path") + "\" "
+ LengthyTask.class.getCanonicalName() + " \"" + lengthy + "\"";
process = Runtime.getRuntime().exec(command);
message.setText("Process is running");
handleOut(process);
handleErr(process);
new Thread(new Runnable() {
@Override
public void run() {
try {
int rc = process.waitFor();
kill.setEnabled(false);
if (rc != 0) {
appendLine("Exit code " + rc);
dispatch.setEnabled(true);
message.setText(rc == 0 ? "Completed successfully"
: "Problem exit code: " + rc);
} catch (InterruptedException e) {
e.printStackTrace();
}).start();
}Piet -
JPanel repaint() method execution
Hi,
I vould like to know if there is a way to catch the end of repaint() method execution.
Thank you in advanceThis is my scenario ...
I am using an external tool ,for georeferencied images handling , to generate JPEG images and save them to disk.
In order to generate an image I overlap n layers provided by this tool ... each time I add a layer I need to repaint the panel and then save the content to disk.
The problem is that there is a race condition between repaint() and save() method.... in particular ... if I use larger images it takes a long time to repaint the panel and in this while it stores an incomplete image. -
I have problem with pay method
I have problem with pay method. My card declined. I change card and I have the same problem. What can i do? Why declined my card again?
Contact iTunes store support: https://ssl.apple.com/emea/support/itunes/contact.html.
-
Hi, I am having this problem:
I made a CustomItem, a TextField, now I overloaded the traverse method, so if the keycode is Canvas.UP or Canvas.DOWN then return false else return true.
The problem is that when I press the left or rigth button it also returns false and not true.
and there is another problem with traverse, before returning false or true I set a boolean and call to repaint to draw it on some way if its selected or not, the paint method is being called but it just dont draw as desired.
protected void paint(Graphics g, int ancho, int alto) {
System.out.println ("Dentro del paint, seleccionado="+seleccionado);
try {
g.drawString(label, 0, 0, Graphics.TOP|Graphics.LEFT);
if (!seleccionado) {
g.setColor(120, 120, 120);
g.drawRect(0, 4, tama�oTexto+8, 25);
if (seleccionado) {
g.setColor(255, 255, 255);
g.fillRect(1, 5, (tama�oTexto+8-1), 23);
g.setColor(0, 0, 0);
if (!seleccionado) {
g.setColor(80, 80, 80);
g.drawString(texto, 4, 7, Graphics.TOP|Graphics.LEFT);
if (seleccionado) {
int cursorX=Font.getDefaultFont().charsWidth((texto.substring(0, idLetraActual)).toCharArray(), 0, texto.substring(0, idLetraActual).length())+4;
g.drawChar('|', cursorX, 7, Graphics.TOP|Graphics.LEFT);
} catch (Exception E){
E.printStackTrace();
}the traverse method set the seleccionado variable and calls to repaint but instead of being false the paint method is drawing it as true (most of times).I have a problem with findByxxx() method.. in
Container managed bean.
i have
Collection collection =
home.findByOwnerName("fieldValue");
specified in my Client Program, where ownerName is the
cmp fieldname..
and
public Collection findByOwnerName(String ownerName)
throws RemoteException, FinderException
defined in my home interface.
i have not mentioned the findBy() method anywhere else
(Bean class). You have to describe the query in the deployment descriptor.
>
Even if i have a same "fieldValue" in the database
(Oracle), which i specified in findBy() method, iam a
result of owner Not found, which is not the case as i
have that owner name.
for the same application if i use findByPrimaryKey(),
it is working..
Can any one please post me the solution. -
Problem with Vector method addElement
I am new to Java. I am using JDK 1.3. I am writing a program that will convert a text file to a binary file that stores a Vector object. I have narrowed my problem to the method that reads the text file and creates my vector. Each element in my vector stores an integer and a string variable. The reading of the text file works find and the creation of my record works find. It seems that the storing of the record in the vector is not working. When I print the first 10 elements of the vector, it have the same record(the last record of my text file). What is wrong with the method below? I am also appending the result of running my program.
private static void readTextFile(File f) {
try {
FileReader fileIn = new FileReader(f);
BufferedReader in = new BufferedReader(fileIn);
String line;
int i;
SsnLocationRecord recordIn = new SsnLocationRecord();
int ctr = 0;
while (true) {
line = in.readLine();
if (line == null)
break;
ctr += 1;
i = line.indexOf(" ");
recordIn.putAreaNumber(Integer.parseInt(line.substring(0,i).trim()));
recordIn.putLocation(line.substring(i+1).trim());
records.addElement(recordIn);
if (ctr < 11)
System.out.println(recordIn);
in.close();
} catch (IOException e) {
System.out.println ("Error reading file");
System.exit(0);
for (int i = 0; i < 11; i++)
System.out.println((SsnLocationRecord) records.elementAt(i));
RESULTS:
C:\Training\Java>java ConvertTextFileToObjectFile data\ssn.dat
0 null
3 New Hampshire
7 Maine
9 Vermont
34 Massachusetts
39 Rhode Island
49 Connecticut
134 New York
158 New Jersey
211 Pennsylvania
680 Nevada
680 Nevada
680 Nevada
680 Nevada
680 Nevada
680 Nevada
680 Nevada
680 Nevada
680 Nevada
680 Nevada
680 Nevada
C:\Training\Java>First of all it would be better if you did a priming read and then checked line == null in the while statement instead of the way you have it.
ctr++ will also accomplish what ctr +=1 is doing.
you need to create a new instance of SsnLocationRecord for each line read. What you are doing is overlaying the objects data each time you execute the .putxxxx methods. The reference to the object is placed in the vector. The actual object is still being updated by the .putxxx methods (NOTE : THIS IS THE ANSWER TO YOUR MAIN QUESTION).
you close should be in a finally statement.
To process through all the elements of a Vector create an Enumeration and then use the nextElement() method instead of the elementAt is probably better. (Some will argue with me on this I am sure).
Also, on a catch do not call System.exit(0). This will end your JVM normally. Instead throw an Exception (Runtime or Error level if you want an abnormal end). -
Hi,
I have a problem with the method prerender. A month ago, I started to develop a web project using Sun Studio Creator and a few page beans that i used extended the Abstract Page Bean, so I overrided the prerender and customized it.
The problem is that, now i'm using eclipse and the configuration files of the project has changed and the prerender method never execute.
I want to know why it is happening. Maybe the project is "bad-configurated"?
ThanksThe code of java bean doesn't change, the only thing that has changed is the configuration files (faces-config.xml, web.xml, etc).
I put a breakpoint in the prerender method but the lifecycle doesn�t execute this method.
After serveral changes, I wrote this code in the method prerender :
int i=0;
i = 1;
And the prerender method doesn't execute.
I'm a bit lost,
thanks -
Problem with affinetransformOp method...
I have a serious problem with filter method
I Want to make a image flipping or some other filtering by using
AffineTransformOp
but it printouts an erro like this
cannot resolve symbol
op.filter (img, flipped)
(the error pointer shows ".after the op")
a code from my one of the filters
BufferedImage flipped = new BufferedImage(img.getHeight(), img.getWidth(),BufferedImage.TYPE_INT_RGB);
AffineTransform trans = new AffineTransform(0, 1, 1, 0, 0, 0);
AffineTransformOp op = new AffineTransformOp(trans, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
op.filter(img, flipped); //img is my buffered image source
I used some other ways like (img, null) but always give out error.
thanks..Did you declare "img" as BufferedImage or something else?
What is the full error message? -
Problem with WindowClosing() method
Hello everyone,
I have some problem with WindowClosing() method, in which I gave options
to quit or not. Quit is working fine but in case of Cancel, its not returning to
the frame. Can anyone help me ....Here is my code
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import java.awt.event.*;
public class TestFrame extends JPanel
public static void main(String[] args)
JFrame frame = new JFrame("Frame3");
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
int button = JOptionPane.showConfirmDialog(null,"OK to Quit","",JOptionPane.YES_NO_OPTION, -1);
if(button == 0) {
System.exit(0);
else
return;
frame.addWindowListener(l);
frame.setSize(1200,950);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}Maybe try
int button = JOptionPane.showConfirmDialog(yourframe,"OK to
Quit","",JOptionPane.YES_NO_OPTION, -1); -
Problems using GET method in JSP
Hi,
I had some problems using GET method in JSP.
I'm using Apache web server 1.3 and Tomcat 3.3.1 in windows 2000.
And I'm using language English and Korean.
When I send messages using POST method, all is good
But when I send message using GET method, English is good, but Korean is not good.
I tried to encode using
URLEncode.encode(str, "UTF-8")
and decoding it using
URLDecode.decode(request.getParameter(tag), "UTF-8")
but it didn't work.
How can I receive request including Korean using GET method in JSP?
If anyone have solutions, please let me know.
thanks.Hi,
I had some problems using GET method in JSP.
I'm using Apache web server 1.3 and Tomcat 3.3.1 in
windows 2000.
And I'm using language English and Korean.
When I send messages using POST method, all is good
But when I send message using GET method, English is
good, but Korean is not good.
I tried to encode using
URLEncode.encode(str, "UTF-8")
and decoding it using
URLDecode.decode(request.getParameter(tag), "UTF-8")
but it didn't work.
How can I receive request including Korean using GET
method in JSP?
If anyone have solutions, please let me know.
thanks.This problem appears, when one use UTF-16 encoding in JSP - am I right?
If so there are two solutions:
1) Temporary: Use "UTF-8" - or any other 8 bit encoding scheme and
encode Korean symbols with "&1234;" kind of escapes - though it
may not work
2) Absolute: get my piece of code, which I have managed to write
just a month ago resolving absolutely similar problem with UTF-16
in code using Chinese/Russian/English encodings
But I wouldn't say that it's costs 10 DDs :) - it's much more
expensive... So try 1st variant if it wouldn't help - let me know.
I'll figure :)
Paul -
Screen Resolution Problem in Session Method
Hi
I want to use session method in BDC. How to resolve screen resolution problem in Session Method?
Please give me the code or steps regarding this.
Thanks & Regards
venkateswararaoHi
U can only run the session with the option Dynpro Standard Size setted.
In this way the system should be use the same resolution for every situation.
Max
Maybe you are looking for
-
What's wrong with my div tag / site won't center....
Hi, I am re-designing a website and I cannot get it to center. I created a div tag and id it "wrapper" and created a css rule. I am sure its a simple mistake, but I cannot figure it out..... Here is the CSS rules... @charset "UTF-8"; /* CSS Documen
-
How long does it take for Apple to ship a replacement iPad 2?
I'd ordered an iPad 2 on the 27th of April and recieved it this last Friday (May 13th). It'd shipped two days ahead of it's scheduled date on the 11th but recieved when it was supposed to. Immediately after recieving my iPad 2, I'd noticed small pits
-
How to retreive data from view
hi, i have created a view with 8 fields. including reference unit for netwr field. REPORT ZVIEWTEST. data: begin of itab occurs 0, kunnr type kunnr, name1 type name1, ort01 type ort01, land1 type land1, vbeln type vbeln
-
Unwanted spacing in words in pdf document.
When selecting TouchUp Text, making corrections, and then saving the file a lot of the words become jumbled in the pdf document. Words w ill sta rt lo king like this thr ough out the doc ume nt. What would be causing this? Thanks!
-
Using JDeveloper 903, I receive the following error when attempting to run a container-managed EJB: SQL error: Io exception: The Network Adapter could not establish the connection However, the connection is fine according to the Connection wizard: cl