Listening for more than one event
I've been following some online tutorials and am now doing my own program. I have a simple gui that uses radio buttons and a standard JButton, I am trying to write an if statement that does something if one of the Radiobuttons is selected and the JButton is pressed, here is the code I have tried:
if(e.getSource() == makeTest && e.getSource() == wTest)
buttonPanel2.setBackground(Color.green);
}e is my ActionEvent, makeTest is the JButton and wTest is the radiobutton. This if statement worked fine if it was just testing to see whether makeTest was pressed, so I'm guessing I might have to use another Actionevent to compare a second button? If someone could give me some pointers on this I would much appreciate it.
If you think some more you will see that it's impossible for e.getSource() to equals 2 different components...
You should check only if the source is the JButton and then check if the radio button is selected using radioButton.isSelected()
Similar Messages
-
Can a Method listen to more than one event in ABAP OO ?
Hi,
is it possible to prepare/register a handler method for e.g two events of two different classes ?
Or can a method generally listen to only one event ?
It seems that the syntax allows only one event ?
methods event_handler for event my_event of my_class.
Thanks for help in advance
OlafAn event can refer to more than one object but you have to instantiate the objects
for example I have 2 grids and want to handle events depending on which grid
the user is selecting / requesting actions on. (I've just posted the relevant bits coded here as data extraction etc you can code normally).
FORM instantiate_grid
* Create Grid container
* Instantiate Grid class
* Instantiate Event Handler class
* Display the Grid
USING grid_container TYPE REF TO cl_gui_custom_container
class_object TYPE REF TO cl_gui_alv_grid
container_name TYPE scrfname.
* create the container
CREATE OBJECT grid_container
EXPORTING container_name = container_name.
* Create the ALV grid object using
* container just created
CREATE OBJECT class_object
EXPORTING
i_parent = grid_container.
* Exclude the SUM function from the GRID toolbar
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
APPEND ls_exclude TO lt_exclude.
* Instantiate our handler class
* lcl_event_handler
CALL METHOD class_object->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CREATE OBJECT g_handler.
SET HANDLER g_handler->handle_double_click FOR class_object.
SET HANDLER g_handler->handle_hotspot_click FOR class_object.
SET HANDLER g_handler->handle_toolbar FOR class_object.
SET HANDLER g_handler->handle_user_command FOR class_object.
SET HANDLER g_handler->handle_data_changed FOR class_object.
SET HANDLER g_handler->handle_data_changed_finished FOR class_object.
ENDFORM. "instantiate_grid
MODULE status_0100 OUTPUT.
IF grid_container IS INITIAL.
PERFORM instantiate_grid
USING grid_container
grid1
'CCONTAINER1'.
* Grid title Primary Grid
struct_grid_lset-grid_title = 'Delimit Old org Units - Selection'.
struct_grid_lset-edit = 'X'.
struct_grid_lset-sel_mode = 'D'.
PERFORM display_grid
USING
grid1
<dyn_table>
it_fldcat.
ENDIF.
SET PF-STATUS '001'.
SET TITLEBAR '000' WITH 'Delimit Old Org Units'.
ENDMODULE. "status_0100 OUTPUT
* PAI module
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'CANC'.
LEAVE PROGRAM.
WHEN 'RETURN'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. "user_command_0100 INPUT
MODULE status_0200 OUTPUT.
IF grid_container1 IS INITIAL.
PERFORM instantiate_grid
USING grid_container1
grid2
'CCONTAINER2'.
* Grid title secondary grid
struct_grid_lset-grid_title = 'Delimited Objects'.
struct_grid_lset-edit = ' '.
PERFORM display_grid
USING
grid2
<dyn_table1>
it_fldcat1.
SET PF-STATUS '001'.
SET TITLEBAR '000' WITH 'Org Units Delimited'.
endif.
ENDMODULE. "status_0200 OUTPUT
In your local event handling class use the variable SENDER to determine which grid / object triggered the event
for example
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
**Hot spot Handler
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
**Double Click Handler
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column es_row_no
sender,
** Toolbar handler.
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive
sender,
* button press
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm
sender,
* data changed
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
*data changed finished
handle_data_changed_finished
FOR EVENT data_changed OF cl_gui_alv_grid,
download_to_excel.
ENDCLASS. "lcl_event_handler DEFINITION
* Implementation methods for lcl_event_handler
CLASS lcl_event_handler IMPLEMENTATION.
*Handle Hotspot Click
* When a "hotspotted"cell is double clicked
* Hotspot indicatore needs to be set in
* the field catalog.
* Not required for this application.
METHOD handle_hotspot_click .
PERFORM mouse_click
USING e_row_id
e_column_id.
CALL METHOD grid1->get_current_cell
IMPORTING
e_row = ls_row
e_value = ls_value
e_col = ls_col
es_row_id = ls_row_id
es_col_id = ls_col_id
es_row_no = es_row_no.
CALL METHOD grid1->refresh_table_display.
CALL METHOD grid1->set_current_cell_via_id
EXPORTING
is_column_id = e_column_id
is_row_no = es_row_no.
ENDMETHOD. "lcl_event_handler
*Handle Double Click
METHOD handle_double_click.
CASE sender.
WHEN grid1.
* returns cell double clicked FROM GRID 1
* Ignore any event from GRID 2
PERFORM double_click
USING e_row
e_column.
ENDCASE.
ENDMETHOD. "handle_double_click
* Add our buttons to standard toolbar
METHOD handle_toolbar.
CASE sender.
* Only add functionality to PRIMARY GRID (GRID 1)
WHEN grid1.
* append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
* Delimit Org
CLEAR ls_toolbar.
MOVE 'PROC' TO ls_toolbar-function.
MOVE icon_railway TO ls_toolbar-icon.
MOVE 'DELIMIT' TO ls_toolbar-quickinfo.
MOVE 'DELIMIT ORG UNIT' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
* Select All Rows
MOVE 'SELE' TO ls_toolbar-function.
MOVE icon_select_all TO ls_toolbar-icon.
MOVE 'ALL CELLS' TO ls_toolbar-quickinfo.
MOVE 'ALL CELLS' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
* Deselect all Rows.
MOVE 'DSEL' TO ls_toolbar-function.
MOVE icon_deselect_all TO ls_toolbar-icon.
MOVE 'DESELECT ALL' TO ls_toolbar-quickinfo.
MOVE 'DESELECT ALL' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDCASE.
move 0 to ls_toolbar-butn_type.
move 'EXCEL' to ls_toolbar-function.
move space to ls_toolbar-disabled.
move icon_xxl to ls_toolbar-icon.
move 'Excel' to ls_toolbar-quickinfo.
move 'EXCEL' to ls_toolbar-text.
append ls_toolbar to e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
* Entered when a user presses a Grid toolbar
* standard toolbar functions processed
* normally
g_sender = sender.
CASE e_ucomm.
WHEN 'PROC'. "Process selected data
PERFORM get_selected_rows.
WHEN 'SELE'.
PERFORM select_all_rows.
WHEN 'DSEL'.
PERFORM deselect_all_rows.
WHEN 'EXCEL'.
call method me->download_to_excel.
WHEN OTHERS.
ENDCASE.
ENDMETHOD. "handle_user_command
METHOD handle_data_changed.
* only entered on data change Not req for ths app.
PERFORM data_changed USING er_data_changed.
ENDMETHOD. "data_changed
METHOD handle_data_changed_finished.
* only entered on data change finished Not req for ths app.
PERFORM data_changed_finished.
ENDMETHOD. "data_changed_finished
* Interactive download to excel
method download_to_excel.
field-symbols:
<qs0> type standard table,
<qs1> type standard table.
data: G_OUTTAB1 type ref to data,
g_fldcat1 type ref to data,
LS_LAYOUT type KKBLO_LAYOUT,
LT_FIELDCAT type KKBLO_T_FIELDCAT,
LT_FIELDCAT_WA type KKBLO_FIELDCAT,
L_TABNAME type SLIS_TABNAME.
case g_sender.
when grid1.
get reference of <dyn_table> into g_outtab1.
get reference of it_fldcat into g_fldcat1.
when grid2.
get reference of <dyn_table1> into g_outtab1.
get reference of it_fldcat1 into g_fldcat1.
endcase.
assign g_outtab1->* to <qs0>.
assign g_fldcat1->* to <qs1>.
call function 'LVC_TRANSFER_TO_KKBLO'
exporting
it_fieldcat_lvc = <qs1>
* is_layout_lvc = m_cl_variant->ms_layout
is_tech_complete = ' '
importing
es_layout_kkblo = ls_layout
et_fieldcat_kkblo = lt_fieldcat.
loop at lt_fieldcat into lt_fieldcat_wa.
clear lt_fieldcat_wa-tech_complete.
if lt_fieldcat_wa-tabname is initial.
lt_fieldcat_wa-tabname = '1'.
modify lt_fieldcat from lt_fieldcat_wa.
endif.
l_tabname = lt_fieldcat_wa-tabname.
endloop.
call function 'ALV_XXL_CALL'
exporting
i_tabname = l_tabname
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_title = sy-title
tables
it_outtab = <qs0>
exceptions
fatal_error = 1
no_display_possible = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endmethod.
ENDCLASS. "lcl_event_handler IMPLEMENTATION
The sender instance is a variable such as g_sender type ref to cl_gui_alv_grid. "Sender instance.
The above example is for OO ALV grids but should work for other interactive cases where a User presses a key or does a mouse action.
Cheers
jimbo -
Keeping a simple server open/listening for more than one connection
Can someone please help me with a problem I am having. I'm running a server that accepts requests and processes data from a client. This program works FINE for one connection but as soon as I send the info to the server the connection closes and I have to manually restart the server to receive another connection from a client. I want to be able to keep the server open and accept multiple requests from the client without having to restart the server.java. I've looked in the forum and found some useful stuff but I still get this same error:
Address in use: JVM_Bind
Error during serialization
Press any key to continue...
I have included the code to my server.java file below. Like I said, it works perfectly for one connection but then closes down. Can anyone tell me where I need to add the code to make it stay open or if I even can. Seems unlogical that it wouldn't be able to. I'm just at a dead end on how to do it. Thanks in advance.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
public class Server extends JApplet{
* Create the serversocket and use its stream to receive serialized objects
public void init(){
ServerSocket ser = null;
Date d = null;
try {
ser = new ServerSocket(8020,10);
* This will wait for a connection to be made to this socket.
Socket soc = ser.accept();
InputStream o = soc.getInputStream();
ObjectInput s = new ObjectInputStream(o);
String str = (String) s.readObject();
d = (Date) s.readObject();
final String nametop = soc.getInetAddress().getHostName();
name n = new name(nametop,str);
n.name = soc.getInetAddress().getHostName();
JOptionPane.showMessageDialog(null,"There is a problem at station " + n.name + ".\n\nProblem:\n" + n.problem + "." ,"Problem",JOptionPane.ERROR_MESSAGE);
System.out.println(d);
System.out.println(n.name);
System.out.println(n.problem);
s.close();
catch (Exception e) {
System.out.println(e.getMessage());
System.out.println("Error during serialization");
System.exit(1);
}//end of server
// Create a main method
public static void main( String args[] )
//String name = soc.getInetAddress().getHostName();
// create a window in which applet will execute
JFrame appWindow = new JFrame("Problem Report");
// create an instance of the applet
Server app = new Server();
// set the window size
appWindow.setSize( 400, 400 );
// add applet to window
appWindow.getContentPane().add( app );
// Simulate the normal startup sequence for an applet
app.init();
app.start();
appWindow.show(); //calls paint()
// add window close event handler
appWindow.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
System.exit( 0 );
}//end of main
}Hi! I suggest you to use different thread to realize a server functionality.
First one server.java that has a main method and create at least two threads. One thread listens to the incoming connection request and stores the locally generated socket object into an static vector. The second thread will always look into this static vector. If there are sockets object in the vector, the second thread will take it out and process the connection request. These two threads should always be alive. The first thread lives in a endless loop while listening to the incoming connection request. The second thread is either waiting on the static vector or processing incoming connection request.
If the expected incoming connection request will be too many for only one thread to process, you can create more threads in server.java at the beginning and they will all swith between two status: looking in the static vector or processing incoming connection request!
Hope this will be help for you! -
Can I have a photo in more than one event?
I understand that it is normally not possible to have one photo in more than one event at a time.
I am quite careful about arranging my photos into events logically, but find in my library tere are several events called [Date] Photo Stream, which I've not delivberately created. It appears that in many cases the photos these Photo stream events contain are also in other events.
Can anyone tell me what is going on here? Can I safely delete the Photostream events and their contents?To have a photo in more than one Event it must be duplicated and the duplicate added to the other Event. A photo can be in multiple albums, books, slideshows without having to duplicate the photo as those use pointers to the original photo.
At the beginning of each month new photos in the Shoto Stream are imported into an Event with the month and year as the Event name. All photos taken that month are added to that Event. That's because the iPhoto/Photo Stream preferences are set to auto import photos taken by your mobile devices:
Events are basically buckets of photos based on the date taken and how you've setup iPhoto's preferences for importing photos:
Merging Events can change the location in the resulting event among the other events due to the variety of dates of the photos.
OT -
Help me to search on calendar for more than one year
I desparately need to be able to search on calendar for more than one year., which was taken away on the new operating system. I have kept personal memories of my husband on there in the notes sections on days when we did things. ( I have also kept all kinds of personal notes, like doctor records or conversations, in the notes of events/dates.) it is a huge loss for me not to be able to search my calendar for more than one year. Is there any way I can do this?
Jens,
It appears that in the past few days you have not received a response to your
posting. That concerns us, and has triggered this automated reply.
Has your problem been resolved? If not, you might try one of the following options:
- Visit http://support.novell.com and search the knowledgebase and/or check all
the other self support options and support programs available.
- You could also try posting your message again. Make sure it is posted in the
correct newsgroup. (http://forums.novell.com)
Be sure to read the forum FAQ about what to expect in the way of responses:
http://forums.novell.com/faq.php
If this is a reply to a duplicate posting, please ignore and accept our apologies
and rest assured we will issue a stern reprimand to our posting bot.
Good luck!
Your Novell Product Support Forums Team
http://forums.novell.com/ -
Setting color codes for more than one photo at a time
Is there any way to set color codes for more than one photo at a time?
Hi John,
I will look at keywords. My issue is speed. Right now I am culling and editing an event shoot that spanned a week with 35 separate events and more than 5000 images. So I use the fastest most convenient method I can and it still takes a long time to have a completed and final shoot. On this shoot I will end up with a final set of around 1500 images. Right now I am finishing processing a show that will hang in the Deutsches Amerikanish Zentrum in Stuttgart.
As I am sure you are aware by now, having seen enough of my inane questions that over the last two years or since Lightroom version 1.xx if I could not figure out how to do something I skipped it. So many things in Lightroom are buried and unless you have a mind like a steel trap (and think that some of you guys in the forum do) locating how to do something is not obvious.
For example, I only learned (in the last hour) that I could assign colors as a group of selections by using Shift + number. I found this in a side head in Martin Evenings Lightroom book. I still do not know how to find a way to display the color filter "selection" set in Library mode. Is there a way?
To top it off, Stuttgart Media University asked me if I would add a Lightroom module to my schedule this year. Now I have a compelling reason to learn all those missing pieces that I have created workarounds for. Hence the number of posts you have been seeing from me over the past few of weeks.
I tell my class that there are no such things as stupid questions, only questions. Now I am practicing what I have been preaching for the last gazillion years. Guys like you have been great.
My workflow is
1. I first separate all images by event. I do that at the time of import.
2. I do a fast pass rejecting all the obviously bad images
3. I do a second pass grouping the images by sub-group (speeches, people talking, performances, etc.) This is where I run out of selection methods and your key-wording could work but it would probably take too much time to establish a keyword set for a single event. Where I have more than five subgroups I set up different collection sets with one collection for each sub group. However I would like to keep a single event in one collection.
4. I then select the images to be used by color code.
5. Next I process the final images (crop develop etc) by collection.
6. Last I output the set according to client requirement.
If you have a better workflow, I am all ears.
By the way, what is your photo specialty and where are you located?
Jim -
I am trying to copy more or less 30G from my MacbookPro to an external hard drive and it is stuck in the "preparing to copy" step. But that for more than one hour. What should I do to make it faster? Thanks a lot in advance!
Thanks Shootist007, by blockd files I mean files that I have changed to blocked and when I tried to move then for the first time, I had to unblock again. I am trying to backup my pictures, my songs and other files like word documents and excel tables. First I put all of them as blocked, what caused the first problems on trying to move them. Then, I've unchecked the block option and if I try to move one by one, there is no problem. The issue is to move all together, because it gets stuck in the preparing to copy files step. Anyway, if I cannot do all by once, I'll do it one by one, event though that was not suposed to happen if we are talking about technology, right? Anyway, I thank you again for trying to help me!
-
Creating SQL-Loader script for more than one table at a time
Hi,
I am using OMWB 2.0.2.0.0 with Oracle 8.1.7 and Sybase 11.9.
It looks like I can create SQL-Loader scripts for all the tables
or for one table at a time. If I want to create SQL-Loader
scripts for 5-6 tables, I have to either create script for all
the tables and then delete the unwanted tables or create the
scripts for one table at a time and then merge them.
Is there a simple way to create migration scripts for more than
one but not all tables at a time?
Thanks,
Prashant RaneNo there is no multi-select for creating SQL-Loader scripts.
You can either create them separately or create them all and
then discard the one you do not need. -
Perform VENDOR EVALUATION for MORE THAN ONE VENDORS at a time
Hello all,
Please guide for any process where i can perform Vendor Evaluation for MORE THAN ONE vendors AT A TIME.
At my location there are around thousand vendors, which are to be evaluated, and difficult to perform the evaluation process one-by-one.
(ME61/ME62/ME63)
Detailed replies with various possibilities would be highly appreciated.
Thanks & Regards,
Joy GhoshThe vendor evaluation for some thousand vendors at the same time has already been in SAP long before they developed LSMW. The purpose of LSMW is to load data from a legacy system, of course you can (mis-)use it for a lot other things.
But you should not always use LSMW if you are to lazy to go thru the SAP standard menu to find a transaction like ME6G
There you define a job that runs RM06LBAT report.
You first have to define a selection variant for this report. this can be done in SE38 by entering the report name, select variant, clicking display, then entering a name for the variant and clicking Create. -
Setting Equalizer for more than one song at a time
Is there any way to set the equalizer setting for more than one song at a time. For example, if I have a classical music album with 10 songs, can I set the equalizer for "classical" for all 10 songs at once? It's a pain to have to do it for each one individually. I tried using the "shift" key, but to no avail.
Thanks,
Joe The Authorhighlight all the songs you want then right click and go to get info. in the options tab at the top there is an equalizer preset option.
-
Master_detail for more than one record at a time
Hi,
How can i display master_detail records for more than one records at a time, for example, i have two tables A and B , A has username and role and B has username and profile. here i wanted to display 10 users at a time on my 6i form with username, role and profile.
i have created a master-detail relation ship with these tables when i'm executing F8 on blcok A , it displays 10 records on BlockA but, only one at a time on block B, how can i display all corresponding records on block B at a time.
Thanks for your help.BcjThanks Roberts, that was realy informative due to some doubts i would like to confirm my requirements , i have two blocks A and B and each master record has only one detail record. but i wanted to display at least 10 master_detail relationships(records) on the form at a time, i would like to know is it possible to do without creating any table or view for example,
data in table A,
username role
AAA R1
BBB R2
CCC R3
data in table B,
username profile
AAA P1
BBB P2
CCC P3
i wanted to display it on form like below,
username role profile
AAA R1 P1
BBB R2 P2
CCC R3 P3
Also would like to know that how can i select data from dba_users, any restriction is there on forms 6i, i can select it on sqlplus.
Thanks Again, Bcj -
Can we use same program ID for more than one RFC scenarios
Hi experts,
I am working on a RFC to FILE scenario. I have created one TCP/IP connection in SM59 with a program ID. Can we use this program ID for more than one scenario. I have written code as below
data: iquote type standard table of ZIQMD initial size 0,
IPRODUCT type standard table of ZPMS initial size 0,
wa_quote type ZIQMD,
wa_PRODUCT type ZPMS.
CALL FUNCTION 'Z_CBT_RFC_QUOTEMASTER'
TABLES
I_QUOTE = iquote .
CALL FUNCTION 'Z_CBT_RFC_QUOTEMASTER' in background task DESTINATION
'ID4'
TABLES
I_QUOTE = iquote .
COMMIT WORK.
CALL FUNCTION 'Z_CBT_RFC_PRODUCTMASTER'
TABLES
IPRODUCT = IPRODUCT .
CALL FUNCTION 'Z_CBT_RFC_PRODUCTMASTER' in background task DESTINATION
'ID4'
TABLES
IPRODUCT = IPRODUCT .
COMMIT WORK.
when i am executing the code like this. i am able to send the data to 'Z_CBT_RFC_QUOTEMASTER' , but iam not getting data for 'Z_CBT_RFC_PRODUCTMASTER' interface. ID4 is the connection that i have created in SM59. with program ID as ABCD.
Can i use the same connection for all interfaces.Please help in this, if we can use same connection for all interfaces. then how to make changes in XI.
Thanks in advance.
Thanks & Regards,
Poorna.Just tried this and I can confirm that my earlier understanding was correct!
One of my colleagues confused me out and the conclusion is,
1. You need a separate TCP IP Connection for every interface with a Unique program ID.
Regards
Bhavesh -
How can i use the same front panel graph in more than one events in an event structure?
i want to display the signals from my sensorDAQ in a graph.but i have more than one event in the event structure to acquire the signal and display it in the graph.the first event is to acquire the threshold signals and its displayed in the graph as a feedback.after the first event is executed, i will call the second event,where the further signals are acuired and compared with the threshold signals from the event 1.my question is how can i use the same front panel control in more than two events in the event structure?please answer me i'm stuck.
Solved!
Go to Solution.Hi,
I have attached here an example of doing the same using shift registers and local variables. Take a look. Shift register is always a better option than local variables.
Regards,
Nitzz
(Give kudos to good answers, Mark it as a solution if your problem is Solved)
Attachments:
Graph and shift registers.vi 12 KB
graph and local variables.vi 12 KB -
Fwd'ing to security newsgroup
-------- Original Message --------
Subject: Client accessing MBeanHome for more than one domain receives
SecurityException
Date: 4 Mar 2004 07:27:33 -0800
From: Dinesh Bhat <[email protected]>
Reply-To: Dinesh Bhat <[email protected]>
Organization: BEA NEWS SITE
Newsgroups: weblogic.developer.interest.management
Hi,
When a client accesses MBeans of more than one domains (Weblogic 8.1)
that have
different passwords, it receives a SecurityException. This occurs when
the MBeanHome
for each domain is looked up at initialization and reused for each
request ( to
access MBeans ). The security exception does not occur if the MBeanHome
for each
domain is looked up for each request. On initial review, this behavoir
seems inconsistent.
Looking up the MBeanHome for each request may introduce a significant
overhead.
I am not sure if concurrent lookups would also cause the same problem.
I have read on another post that we can work around this problem by
establishing
a trust relationship between the servers, but this may not be feasible
when one
is monitoring a lot of servers and the overhead of configuration may be
an issue.
I have attached code that can reproduce the problem.
Please advise on the correct approach.
Thanks
Dinesh Bhat
Panacya Inc.
import java.util.ArrayList;
import java.util.Set;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Hashtable;
import javax.management.MBeanServer;
import javax.naming.Context;
import weblogic.jndi.Environment;
import weblogic.management.MBeanHome;
* This class reproduces the Security Exception that is caused when a client tries to access
* MBeans of more than one domain with different weblogic passwords. Here is the stacktrace of the
* exception
* java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[weblogic, Administrators]
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:138)
at weblogic.management.internal.AdminMBeanHomeImpl_811_WLStub.getDomainName(Unknown Source)
at WLSecurityTest.getWeblogicInfo(WLSecurityTest.java:140)
at WLSecurityTest.runTest(WLSecurityTest.java:75)
at WLSecurityTest.<init>(WLSecurityTest.java:66)
at WLSecurityTest.main(WLSecurityTest.java:51)
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.intellij.rt.execution.application.AppMain.main(Unknown Source)
Caused by: java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[weblogic, Administrators]
at weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:682)
at weblogic.rjvm.MsgAbbrevInputStream.getSubject(MsgAbbrevInputStream.java:181)
at weblogic.rmi.internal.BasicServerRef.acceptRequest(BasicServerRef.java:814)
at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:299)
at weblogic.rjvm.RJVMImpl.dispatchRequest(RJVMImpl.java:920)
at weblogic.rjvm.RJVMImpl.dispatch(RJVMImpl.java:841)
at weblogic.rjvm.ConnectionManagerServer.handleRJVM(ConnectionManagerServer.java:222)
at weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:794)
at weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:570)
at weblogic.socket.NTSocketMuxer.processSockets(NTSocketMuxer.java:105)
at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:32)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
* Note: the exception is caused only when the MBeanHome for each domain is cached and used for subsequent
* transactions. The exception does not occur if the MBeanHome for each domain is looked up for each transaction. This
* would significant overhead in practice. Also the transactions across the various domains occurs serially, hence
* the effect of concurrent lookups has to be tested.
* Usage:
* This class has been tested with weblogic 8.1
* The class needs weblogic.jar in its classpath
* One can specify the weblogic details as System properties. The properties need to be specified in
* the following format:
* wls.host.n, wls.userId.n, wls.password.n where n is the weblogix instance number. Also specify
* the boolean system property reconnect.each.iteration to toggle between reconnecting or not reconnecting
* for each iteration. When not reconnecting for each iteration, the MBeanHome is reused and the Security Exception
* occurs.
* Following is the example of system properties
* -Dwls.host.0=localhost:7001 -Dwls.userId.0=weblogic -Dwls.password.0=weblogic
* -Dwls.host.1=localhost:7011 -Dwls.userId.1=weblogic -Dwls.password.1=weblogic1
* -Dwls.host.2=localhost:7021 -Dwls.userId.2=weblogic -Dwls.password.2=weblogic2
* -Dreconnect.each.iteration=false
public class WLSecurityTest
ArrayList wlsDetailsList = new ArrayList();
HashMap connectionMap = new HashMap();
public static void main(String[] args)
try
WLSecurityTest wlSecurityTest = new WLSecurityTest();
catch (Exception e)
e.printStackTrace();
* Constructor
* @throws Exception
public WLSecurityTest() throws Exception
int noOfTries = 10;
getWLSDetails();
for( int i=0; i <= noOfTries; i++)
runTest();
* Runs the test
private void runTest()
for (int i = 0; i < wlsDetailsList.size(); i++)
WLSDetails wlsDetails = (WLSDetails) wlsDetailsList.get(i);
getWeblogicInfo(wlsDetails);
* Get Weblogic details from System properties
* @throws Exception
private void getWLSDetails() throws Exception
wlsDetailsList = new ArrayList();
String hostKeyTmpl = "wls.host";
String userIdKeyTmpl = "wls.userId";
String passwordKeyTmpl = "wls.password";
boolean done = false;
for (int i = 0; !done; i++)
WLSDetails wlsDetails = new WLSDetails();
String hostKey = hostKeyTmpl + "." + Integer.toString(i);
String userIdKey = userIdKeyTmpl + "." + Integer.toString(i);
String passwordKey = passwordKeyTmpl + "." + Integer.toString(i);
wlsDetails.hostName = System.getProperty(hostKey);
done = (wlsDetails.hostName == null) || (wlsDetails.hostName.length() == 0);
if (!done)
wlsDetails.userId = System.getProperty(userIdKey);
wlsDetails.password = System.getProperty(passwordKey);
connect(wlsDetails);
wlsDetailsList.add(wlsDetails);
* Lookup the MBeanHome for the specified weblogic server
* @param wlsDetails
* @throws Exception
public synchronized void connect(WLSecurityTest.WLSDetails wlsDetails) throws Exception
Context ctx = null;
MBeanHome mbHomeLocal = null;
try
Environment env = new Environment();
env.setProviderUrl("t3://" + wlsDetails.hostName);
env.setSecurityPrincipal(wlsDetails.userId);
env.setSecurityCredentials(wlsDetails.password);
Hashtable hashtable = env.getProperties();
System.out.println(hashtable.toString());
ctx = env.getInitialContext();
wlsDetails._mBeanHome = (MBeanHome) ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
catch (Exception e)
e.printStackTrace();
* Gets weblogic information using MBeans
* @param wlsDetails
public synchronized void getWeblogicInfo(WLSDetails wlsDetails)
try
boolean reconnectEachIteration =
Boolean.getBoolean("reconnect.each.iteration");
if( (reconnectEachIteration) || ((wlsDetails._mBeanHome == null) && (!reconnectEachIteration) ))
connect(wlsDetails);
MBeanHome mbHomeLocal = wlsDetails._mBeanHome;
String domainName = mbHomeLocal.getDomainName();
Set allMBeans = mbHomeLocal.getAllMBeans();
System.out.println("Size: " + allMBeans.size());
Set clusterMBeans = mbHomeLocal.getMBeansByType("Cluster", domainName);
System.out.println(clusterMBeans);
MBeanServer mBeanServer = mbHomeLocal.getMBeanServer();
catch (Exception ex)
ex.printStackTrace();
* Class that holds weblogic server details
class WLSDetails
String hostName = "";
String userId = "";
String password = "";
MBeanHome _mBeanHome = null;If Server version is 61.
Make user "system" password of all weblogic servers same.
If Server version above 61(70,81)
In the Security Advanced Settings un check generated credential and specify a common credentail for all the weblogic servers(domains). -
How do people register for more than one person on a form?
We had a lot of complaints last year from organizations who sent several employees to our training. It took a long time for them to process these one at a time. How do people register for more than one person on a form?
Hi thearcca,
This entirely depends on the form you create, you can add multiple choice button and ask for the no. of employees the organization wants to register.
Also, you can add corresponding text field for the names.
Thanks,
Vikrantt Singh
Maybe you are looking for
-
Getting Logon Failed error connecting to SAP R/3 with Crystal
I have Crystal Reports 2008 and also the SAP Integration Kit installed on my desktop. I've imported the transports into my DEV and QAS systems and am trying to connect directly to R/3 from Crystal using the SAP Table, Cluster or Function choice. I r
-
EHP 7 Upgrade - Position 99999999 isn't in table T528B
We recently upgraded to ECC 6 EHP 7 and noticed that we can no longer create personnel records. We don't use HCM for anything other than creating our sales reps as personnel numbers. In our non-upgraded system we're able to create a personnel # witho
-
Please share UCS interview questions and answers
Please share UCS interview questions and answers
-
Address Book Groups - Distribution List problems
Recently upgraded to 10.6 and now on 10.6.3 - 2 Problems which are probably related: 1 - I cannot save changes to an edited Distribution List- I select the desired email address (ie it's in bold) and then click OK. When I go back to edit the list the
-
Numbers for iPad (iOS 5): formula entry problem
Whenever I attempt to work with a formula-cell in Numbers, the large, on-screen number-pad pops-up, overlapping the text-entry bar. I undersand that the normal opperation is for the num-pad to "push" the text-entry bar upwards, so that the text-entry