- We may get error " java.lang.reflect.InvocationTargetException " from Crystal Report designer at the time of creating Java Bean connectivity as shown in the file screenshot below.
- Since it is very difficult to debug this error from designer due to its inadequate stack trace, we need some utility which can give us exact reason behind this error.
- Utility described in this article will give you the required tool to get more information about the error.
Reproducing the Issue
- Write a Java code to make Java Bean connectivity.
- Intentionally make such a mistake in your code which will allow your code to get compiled but will throw run time error.
- Since there is mistake in our code, at run time, when we click on JavaBean options in Crystal Designer, we can see the compilied class.
- However after clicking on that class, designer will throw some error.
- Our aim is to find out exact location of that error in our code.
- As the developer might have done some mistake in the code for JavaBean Connectivity, since error is not caught by compiler at compile time, we were successfully compiled code and made .class file.
- However crystal report engine will throw this error at run time as it will not get correct resultset from database
- In order to trace such error, we are going to use utility named as "Java Server".
- Java Server is simple executable batch file which needs to be executed. Go through Instructions.txt file in the JavaServerUtlity folder before executing this utility.
Follow following steps to run Java Server utility:
- Open the blank crystal report in which you are going to make JavaBean connectivity.
- Click Control+Alt+Delete and click on Task Manager.
- In Windows Task Manager, click on View-->Select Columns.
- Select PID(Process Identifier) option and click on ok.
- Locate crw32.exe file by clicking on Processes option and note down the PID.
- Close task manager window.
- In the services, click on View > Add/Remove Columns.
- Open the folder JavaServerUtility.
- Right click on runJS.bat and select edit option. This will open the bat file in notepad.
- Edit the line:
- Set libpath=C:\Program Files\Common Files\Business Objects\3.0\java\lib
- Give correct path where you have installed Business Objects software on your drive. The path will be up to lib folder as mentioned in the above line.
- Edit the line:
- Set iorfile=3988.ior
- Replace the number 3988 with your PID for crw32.exe which we have already noted.
- Save this changes in bat file and double click on it. You will notice command prompt in the background window.
- Make your Java Beans connectivity in designer window and go to the step where you will get error prompt.
- Once you get this error prompt, go to the location:
- C:\work\API_logs\JavaServerLogs, where you will get detailed stack trace of the cause behind this error.
- This stack trace may be descriptive enough to find out mistake in a code.
- You may also attach a remote debug session to the JavaServer, using the address specified in the runJS.bat file, in the last line. The default debug port is set to 6770 (in the line -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=6770
- JavaBean Connectivity error from Crystal report designer
Crystal Reports 2008 V1 ; SAP Crystal Reports XI ; SAP Crystal Reports XI R2