Smart Client Backend Debugging
Weblogic 9.x Development
Q:
I am using weblogic 9.x. My problem is when I make any changed and compile my class i have restart the server to get the new class.
-
Is there any way where classes can be reloaded without restarting server?
-
Is there other way to register new xbean instead of put it in CrmServiceNames file ?
Thank you.
Refresh Classes Using Weblogic Hot Swap
During backend XBean class:
- Set a break point in your code.
- Run the application in debug mode.
- Make sure to set your server side project output directory to the WEB-INF\classes directory
- Edit your code and save your class.
The debug hot swap facility should replace the old class with your newly compiled code and set the current break point at the beginning of the edited class.
There is no need to re-start the apploication server (Weblogic).
Please try and share with us the result.
CustomServiceNames
The CustomServiceNames.lst is an xml file which contains list of the Custom bean names.
Use the UifServiceNameGen tool (located at ClfyWebInf.jar) to refresh (re-generate) the list in CustomServiceNames.lst (XBean, Worker Bean or SearchFilterBaseWB).
A re-generated CustomServiceNames.lst should be located in your WEB-INF\classes directory (ClfyAgent.ear\ClfyAgent.war\WEB-INF\classes\CustomServiceNames.lst).
1. Make sure to set your server side project output directory to the WEB-INF\classes directory.
2. Make sure to have ClfyWebInf.jar in the classpath.
Once re-generated, all newly added custom classes should be visible in your Smart Client Designer.
Yuval
Using Remote Java Application
Q:
In fact, I built 2 projects. First for Smart Client Form, the second for backend.
So that I don’t know how to run the application in debug mode because I always running in smart client form
Any suggestion would be appreciated
A:
When you run front end application (Smart Client forms), it calls the your backend code (XBeans).
Using two seperate projects, one for front end (Smart Client forms) and second for
backend is correct. You simply need to create a new Debug Remote Java Application for your backend project.
1. Create a remote java application entry
In Smart Client Designer (Eclipse),
– Select ‘Debug…’
– Right click ‘Remote Java Application’
– Select ‘New’ to create a new Remote Java Application Entry.
2. In the Remote Java Application dialog, set the following:
– An entry name,
– Your backend project, host (if weblogic runs on your machine – set it to ‘localhost’)
– Your weblogic ‘debug’ port (look at setDomainEnv.cmd script for the line ‘set DEBUG_PORT=nnnn’). The default port is 8453
3. Activate (run) the remote java application.
– When run, the backend application will wait for your front end to call it.
– Now run the front-end application. Once one of your front end forms triggers a ‘Submit’ action, it invokes your backend XBean.
– A relevant break point in your invoked XBean (backend code) should now be caught (‘hooked-up’).
From that point try to change your backend code ande see what happens.
Yuval
Hi Yuval,
I tried as you said above, it seem worked good when I only modify function content of XBean, but when i tried to change the structure of XBean class (eg, add new method) I got this exception:
Java HotSpot(TM) ClientVM [localhost:8453] (may be out of synch) was unable to replace the running code with the code in the workspace.
Reason:
“Hot code replace failed – Add method not implemented”
Possible reasons I found in google:
1. Check carefully what JRE you are using in your debug session.
2. Check you are deploying classes compiled with the debug attribute set (make sure you set the “debug=true” in the StartWebLogic script).
3. Did you switch “Project->Build Automatically” off? Hot code replacement works (only?) if automatic build is switched on…
If the above does not help, set your XBean structure and re-start the application server (Weblogic). You will still be able to edit your code within the code structure previously defined without having to restart your application server.
Hi Yuval,
Thank for you response!
I think I already completed all of three configurations above, but let me check it more carefully and will give you the detail status.
Hi Yuval,
When investigated this issue more deeply, I found something very interesting!
Assume I have 2 project: TestBackEnd and TestClientDesigner
– TestBackEnd project had a XBean, name TestXBean having code snipet:
…
protected void executeImpl(BoContext arg0) {
System.out.println(“executeImpl – 1st”);
}
…
– TestClient project had a form that using TestXBean called: TestXBeanForm
I. These are my detail configurations:
1. Add debug option to startWeblogic.cmd:
set JAVA_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8453,suspend=n %JAVA_OPTIONS%
2. Setting output classes of TestBackEnd project point to C:\AmdocsCRM751\ClfyAgent\ClfyAgent.war\WEB-INF\classes
3. Configure Debug Remove Java Application for TestBackEnd project:
Run -> Debug …: create new Remote Java Application (name: TestBackEndRemoteDebug) with following parameters:
Project: TestBackEnd
Connection Type : Standard (Socket Attach)
Host : localhost
Port : 8453
Allow Termination of remote VM : unchecked
II. This is my scenario to make sure above configuration works good:
1) Start Weblogic on local machine
2) Open eclipse, and run TestBackEndRemoteDebug by: go to Run -> Degbug.. -> TestBackEndRemoteDebug
3) Run TestXBeanForm that using TestXBean
4) Go to weblogic console, and I saw the result:
… executeImpl – 1st …
5) Exit TestXBeanForm form
6) Open TestXBean class, change “1st” -> “2nd” and Save (Automatic build)
7) Run TestXBeanForm again and see the welogic console, I saw:
… executeImpl – 2st …
=> My configuration seem valid!
III. This is my scenario to make it die:
1) Start Weblogic on local machine
2) Open eclipse, and run TestBackEndRemoteDebug by: go to Run -> Degbug.. -> TestBackEndRemoteDebug
3) Run TestXBeanForm that using TestXBean
4) Go to weblogic console, and I saw the result:
“… executeImpl – 1st” => It seem good!
5) Exit TestXBeanForm form
6) Open TestXBean class, modify to:
…
protected void executeImpl(BoContext arg0) {
System.out.println(“executeImpl – 2st”);
newMethod();
}
private void newMethod() {
System.out.println(“new Method – 1st”);
}
…
7) Run TestXBeanForm again and see the welogic console, I saw:
“.. executeImpl – 1st”
=> this result is wrong!!!.
8) Now: I re-run debug remote java app in step 2, an error dialog appear with following message:
“Failed to connect to remote VM. Connection refused.”
Note that, the weblogic server was still working fine. But hotswap don’t effect anymore!
– The error: ““Hot code replace failed – Add method not implemented”” appear if you don’t do step #5 (Modify TestXBean when TestXBeanForm was still running)
I alreay tried with create new XBean (TestXBean_1.java), and create new form using it. And the hot swap seem working good (don’t need restart weblogic server to load class new XBean class).
Hmn, it seem work good with modify content of class (not class’s structure) and create new class, doesn’t work with modify structure of an XBean!
This situation was quite weird. So could you have any suggestion for this problem ?
Hi GipXy,
This will require too much time to investigate.
I am sure your current settings allow reducing server restarts to minimum.
Please keep us updated should you have more findings.
Yuval
Hi Yuval,
Ok, so the first question: is my hot swap configuration right ?
I. These are my detail configurations:
1. Add debug option to startWeblogic.cmd:
set JAVA_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8453,suspend=n %JAVA_OPTIONS%
2. Setting output classes of TestBackEnd project point to C:\AmdocsCRM751\ClfyAgent\ClfyAgent.war\WEB-INF\classes
3. Configure Debug Remove Java Application for TestBackEnd project:
Run -> Debug …: create new Remote Java Application (name: TestBackEndRemoteDebug) with following parameters:
Project: TestBackEnd
Connection Type : Standard (Socket Attach)
Host : localhost
Port : 8453
Allow Termination of remote VM : unchecked
Regards,
The parameters provided in your comment look OK.
ok, So after many tries, I quite sure that:
Hotwap only allows you to modify content of class (not class’s structure), create new class and doesn’t allow you to modify structure of a class (XBean)!
From the error message itself (‘Hot code replace failed – Add method not implemented’) I guess that there should be an ‘Add Method’. The question is why the environment does not support it.
There might be a defect in the environment (Weblogic 9.2) or in your environment configuration.
Since you already tried your configuration, I believe there is a defect in Weblogic 9.2 SP1.
yes, this is one of known issue of WLS 9.2 SP1
http://download.oracle.com/docs/cd/E13222_01/wls/docs92/issues/known_resolved.html
& there is a work-around too.
Please share with us the work around.
Thanks, I think so!
Hi Yuval,
I have one question cum problem,my smart client is getting freez after 30 min if work exclusive on cases.
Could you please provide some insight on this issue and how i can resolve this.
Check what happens if your client is opened for 30 minutes WITHOUT working on cases.
If it does not freez, but ask you to re-login (which is OK) then I suspect while working with Cases the client’s runs out of memory.
Please check.
If your client runs out of memory, you need to check the reason for this fault;
You might have customizations that are ‘rsponsible’ for this faults.