Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EGL Development Tools » Tutorial - Access a database(Error in java code generated)
Tutorial - Access a database [message #788509] Wed, 01 February 2012 22:29 Go to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
Hello,

I am new to EGL and am trying the tutorials. I have gotten to the lesson "Access a database with EGL RichUI" and completed through lesson 8. I am getting an error reported as the following:

Failure: An exception occurred during a service call. Service:services.SQLService, Function:services.SQLService
Detail 1:
Detail 2:
Detail 3: java.lang.NoClassDefFoundError:paymentRec

In the Problems window I can see that there are many errors in the SQLService.java code and it all points to a description of "paymentRec cannot be resolved to a type".

Can anyone explain how to fix this issue? Otherwise I can't go any further.

Thanks
Re: Tutorial - Access a database [message #788513 is a reply to message #788509] Wed, 01 February 2012 22:38 Go to previous messageGo to next message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
Hi Bernard,

Welcome!

It sounds like the record named paymentRec has not been generated to Java. First I would open up the .egl file containing the paymentRec definition, and see if there are any red error markers that talk about generation failing. If you don't see that, you can right-click this .egl file from the Project Explorer and select Properties. From this dialog select EGL Compiler, and make sure it has the Java Generator enabled (you can enable this generator at the project or package level if you don't want to enable it for specific files).

-Justin
Re: Tutorial - Access a database [message #788568 is a reply to message #788509] Thu, 02 February 2012 00:29 Go to previous messageGo to next message
fahua jin is currently offline fahua jinFriend
Messages: 58
Registered: July 2011
Member
Hi Bernard,

Which project do you put the paymentRec.egl? The record definitions in this tutorial should be put into project PaymentShared (refer to the Lesson 3), and that project configured with Java & JavaScript generator. It should not have the part resolve issue if put the record definitions to PaymentShared project.

Rocky
Re: Tutorial - Access a database [message #789004 is a reply to message #788568] Thu, 02 February 2012 13:45 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
Thank you both for your reply, unfortunately everything is correct based on what you have stated. There are no errors in the source (red x), the paymentRec.egl in within the PaymentShared/EGLSource/records folder, and the EGL Compiler is set for both Java & JavaScript Generator.
Re: Tutorial - Access a database [message #789011 is a reply to message #789004] Thu, 02 February 2012 13:57 Go to previous messageGo to next message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
Does the file paymentRec.java exist? And if it does, is PaymentShared on the Java build path of the project containing SQLService.java?

-Justin
Re: Tutorial - Access a database [message #789052 is a reply to message #789011] Thu, 02 February 2012 14:50 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
Yes, paymentRec.java does exist and it is under the /PaymentShared/generatedJava/records/paymentRec.java path. I am not sure what you mean by "build path".

However within this paymentRec.java file there are warning errors. They are below. The errors are the same within the PAYMENT.java file.

Description Resource Path Location Type
Type safety: The return type EAny for ezeUnbox() from the type EAny needs unchecked conversion to conform to T from the type EAny PAYMENT.java /PaymentShared/generatedJava/records line 17 Java Problem
Description Resource Path Location Type
Type safety: The return type paymentRec for ezeNewValue(Object...) from the type paymentRec needs unchecked conversion to conform to T from the type AnyValue paymentRec.java /PaymentShared/generatedJava/records line 59 Java Problem
Re: Tutorial - Access a database [message #789099 is a reply to message #789052] Thu, 02 February 2012 15:54 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
I checked the PaymentService project and within the Properties I do see PaymentShared selected in the EGL Build Path select.
Re: Tutorial - Access a database [message #789108 is a reply to message #789099] Thu, 02 February 2012 16:00 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
I also found within the Properties of the PaymentService project the Java Build Path settings. I added PaymentShared to this and now I have no errors in the java files. I still have the 4 warnings reported above. This did NOT resolve the initial problem so I still get the following:

Failure: An exception occurred during a service call. Service:services.SQLService, Function:services.SQLService
Detail 1:
Detail 2:
Detail 3: java.lang.NoClassDefFoundError:paymentRec
Re: Tutorial - Access a database [message #789117 is a reply to message #789108] Thu, 02 February 2012 16:15 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
One thing I noticed, while copying in the code for the SQLService.egl, is I couldn't see any SQL statement when using Ctrl+1 on the "get" statement in getAllPayments(), whereas I could see the SQL statements in addPayment, editPayment, and deletePayment.
Re: Tutorial - Access a database [message #789311 is a reply to message #789117] Thu, 02 February 2012 21:03 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
Anybody have any solutions to this? Otherwise I'm dead in the water trying to use this tool and it's just another one that doesn't provide any business value.
Re: Tutorial - Access a database [message #789318 is a reply to message #789311] Thu, 02 February 2012 21:16 Go to previous messageGo to next message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
Okay, so it sounds like your compilation problems are resolved, but you're still getting the error. At first glance it appears that the Java debugger was not able to update with the new .class file. If this is the case, then if you go to the Debug view in the Debug perspective and terminate the process for the EDT Test Server for project PaymentClient then it will start up a new instance of the server on the next service invocation. If this turns out to fix the problem then I'm going to investigate why the .class file wasn't picked up automatically, but hopefully this will in the meantime let you continue the tutorial.

-Justin
Re: Tutorial - Access a database [message #789345 is a reply to message #789318] Thu, 02 February 2012 22:10 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
Thank you Justin. I restarted Eclipse and it did get further, something must have been still running.

Now on to my second dilemma. Since I want to ultimately connect to an iSeries database I used that as my database instead of Derby, in this tutorial. Sorry, trying to do too much at once but I need to shorten my learning time as much as possible. Anyway, I am now getting a new error I it might be related to the jt400.jar not being deployed into the service, not sure. I was successful in adding my iSeries database connection into the Resource bindings of PaymentService.egldd and the Test Connection worked fine. Is there something else I am missing? Here is my new error:

Failure: An exception occurred during a service call. Service:services.SQLService, Function:services.SQLService
Detail 1:
Detail 2:
Detail 3: No suitable driver found for jdbc:as400:TSFCDEV;prompt=false: [sqlstate:08001][sqlcode:0]
Re: Tutorial - Access a database [message #789372 is a reply to message #789345] Thu, 02 February 2012 22:56 Go to previous messageGo to next message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
That sounds just like https://bugs.eclipse.org/bugs/show_bug.cgi?id=365359

This bug is fixed in the 0.8 Milestone 1 build, which you can install by adding the following update site: http://download.eclipse.org/edt/milestones/1.0/

I think there was a workaround to remove the default schema from the connection you defined in the workspace, and then manually put myDataSource.setCurrentSchema("schemaName"); in your code after the resource binding has been retrieved. But this is only needed if you don't want to update to 0.8M1.

-Justin
Re: Tutorial - Access a database [message #789442 is a reply to message #789117] Fri, 03 February 2012 01:23 Go to previous messageGo to next message
fahua jin is currently offline fahua jinFriend
Messages: 58
Registered: July 2011
Member
Bernard Harris wrote on Thu, 02 February 2012 11:15
One thing I noticed, while copying in the code for the SQLService.egl, is I couldn't see any SQL statement when using Ctrl+1 on the "get" statement in getAllPayments(), whereas I could see the SQL statements in addPayment, editPayment, and deletePayment.


Hi Bernard,

Hope you can finally get the tutorial run successfully, and feel free to ask here if having any problems.

For your problem of Ctrl + 1 cannot generate the SQL statements, we have a bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=369021) opened for this, and it will be resolved soon.

Rocky
Re: Tutorial - Access a database [message #789844 is a reply to message #789442] Fri, 03 February 2012 13:34 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
Okay, I updated to the latest version using the milestones folder. I then clicked on preview but I am now getting a different error and it appears it has something to do with the java code generated. Here is the display error:

Failure: An exception occurred during a service call. Service:services.SQLService, Function:services.SQLService
Detail 1:
Detail 2:
Detail 3: java.lang.reflect.GenericSignatureFormatError

In the errors window I also have 32 errors and they are as follows:

Description Resource Path Location Type
The annotation @FunctionParameter must define the attribute jsonInfo SQLService.java /PaymentService/generatedJava/services line 39 Java Problem
Description Resource Path Location Type
The attribute asOptions is undefined for the annotation type FunctionParameter SQLService.java /PaymentService/generatedJava/services line 39 Java Problem
Description Resource Path Location Type
The attribute name is undefined for the annotation type FunctionParameter SQLService.java /PaymentService/generatedJava/services line 39 Java Problem



Re: Tutorial - Access a database [message #789854 is a reply to message #789844] Fri, 03 February 2012 13:50 Go to previous messageGo to next message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
I don't work on the Java code that's generated for services, but my first thought is that the code needs to be regenerated due to changes in the runtime (once we hit a 1.0 release then these types of breaking changes should stop). Try a "Project > Clean" (from the main toolbar) on your workspace. If that doesn't clear up the compile errors in the Java code I'll see if I can reproduce this on my machine.

-Justin
Re: Tutorial - Access a database [message #789877 is a reply to message #789854] Fri, 03 February 2012 14:26 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
Got it! Thanks for the help!

Once I performed the "Project > Clean" it appeared to toast my handler. I then restarted Eclipse and it showed properly in the design tab, so I clicked on the Preview tab and no errors. I then clicked the Sample button and the data was created and displayed. Now I can continue connecting the other buttons.

Thanks again. This tool has great potential, if you can keep us isolated from the complexity of java and all of it's pieces, otherwise it's just too much for a business developer doing rapid application development.
Re: Tutorial - Access a database [message #789884 is a reply to message #789877] Fri, 03 February 2012 14:33 Go to previous messageGo to next message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
Excellent!

As for hiding the complexities of Java (or anything else, for that matter), I encourage you to open bugzilla enhancements or post suggestions to the forum. The best way for us to simplify development is to know exactly which parts people are having the most trouble with.

-Justin
Re: Tutorial - Access a database [message #789897 is a reply to message #789884] Fri, 03 February 2012 14:52 Go to previous messageGo to next message
Bernard Harris is currently offline Bernard HarrisFriend
Messages: 11
Registered: February 2012
Location: Medford, Wisconsin
Junior Member
I will let you know, if I see areas where it's just too complex to figure out Smile

I have developed extensively in Visual Studio and that tool works well for rapid application development/change/deployment, but would like to see tools that are more "generic". Tools that allow us to develop for whatever front end the industry throws at us. Again, your tool has potential because this tutorial database app has the basic functions used within all maintenance/inquiry apps.

Now to get to a point where I can test performance Wink

Bernie
Re: Tutorial - Access a database [message #804030 is a reply to message #789897] Wed, 22 February 2012 05:27 Go to previous messageGo to next message
Doctor Hung is currently offline Doctor HungFriend
Messages: 7
Registered: February 2012
Junior Member
Hi

We also get the following error. But I cannot fix it after viewing the above thread. Which is the key point to fix this issue ?

Failure: An exception occurred during a service call. Service:services.SQLService, Function:services.SQLService
Detail 1:
Detail 2:
Detail 3: java.lang.NoClassDefFoundError:paymentRec
Re: Tutorial - Access a database [message #804037 is a reply to message #804030] Wed, 22 February 2012 05:42 Go to previous messageGo to next message
Doctor Hung is currently offline Doctor HungFriend
Messages: 7
Registered: February 2012
Junior Member
When I try the project->clean, after restart eclipse, I get the following error.

IWN.HtmlGen.9990.e 0/0 Generation Failed
Generation completed for handler handlers.PaymentFileMaintenance with 2 errors and 0 warnings.

--------------------------------------------------------------------------------

Generation Error
IWN.HtmlGen.9998.e 0/0 Exception occurred: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
IWN.HtmlGen.9999.e 0/0 Stack Trace: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

The problem is still there.

The SQLService.java has the following error:

Description Resource Path Location Type
The import records cannot be resolved SQLService.java /PaymentService/generatedJava/services line 9 Java Problem
The method ezeNew(Class<? extends paymentRec>) from the type EList refers to the missing type paymentRec SQLService.java /PaymentService/generatedJava/services line 76 Java Problem
The method ezeNew(Class<? extends paymentRec>) from the type EList refers to the missing type paymentRec SQLService.java /PaymentService/generatedJava/services line 87 Java Problem
The method ezeNew(Class<? extends paymentRec>) from the type EList refers to the missing type paymentRec SQLService.java /PaymentService/generatedJava/services line 180 Java Problem
The method getAllPayments() from the type SQLService refers to the missing type paymentRec SQLService.java /PaymentService/generatedJava/services line 253 Java Problem

Re: Tutorial - Access a database [message #805379 is a reply to message #804037] Thu, 23 February 2012 17:39 Go to previous messageGo to next message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
Right-click the PaymentService project and select "Properties". Then click on "Java Build Path", and then click the "Projects" tab. Add the project containing paymentRec.java if it's not already in the list. This should clear up the compilation error for SQLService.java.

Hope this helps.

-Justin
Re: Tutorial - Access a database [message #826094 is a reply to message #805379] Wed, 21 March 2012 16:47 Go to previous messageGo to next message
Doctor Hung is currently offline Doctor HungFriend
Messages: 7
Registered: February 2012
Junior Member
This problem is fixed. But when we deploy to Tomcat6, another problem occurs. It shows the following error message.
Failure: An error occurred while loading the services.SQLService service.
Detail 1:
Detail 2:
Detail 3: java.lang.NullPointerException
Re: Tutorial - Access a database [message #826514 is a reply to message #826094] Thu, 22 March 2012 06:48 Go to previous messageGo to next message
Doctor Hung is currently offline Doctor HungFriend
Messages: 7
Registered: February 2012
Junior Member
After upgrade to the 0.8 latest version. The problem is fixed but a new problem occurs.

It complains with the following error.

IWN.VAL.6653.e 56/56 PaymentFileMaintenance - CellFormatter[] and formatCategory[] are not compatible types in the
expression formatters = [formatCategory]. At line 56 in file \PaymentClient\EGLSource\handlers\PaymentFileMaintenance.egl
Re: Tutorial - Access a database [message #826986 is a reply to message #826514] Thu, 22 March 2012 18:56 Go to previous messageGo to next message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
Can you try doing a Project > Clean to see if the error goes away? If it doesn't, can you post the relevant source code?

-Justin
Re: Tutorial - Access a database [message #836539 is a reply to message #826986] Wed, 04 April 2012 15:55 Go to previous messageGo to next message
Doctor Hung is currently offline Doctor HungFriend
Messages: 7
Registered: February 2012
Junior Member
We mask that part to continue the learning.
Some programmer gets the following error message.

Could not render UI
CRRUI3664E
[CRRUI2094E] There are EGL function calls leading to this error:

handlers/PaymentFileMaintenance.egl() at line 294
handlers/PaymentFileMaintenance.egl() at line 284

Exception thrown and not caught
PaymentClient/handlers/PaymentFileMaintenance.html?contextKey=10:21
[CRRUI2095E] Could not find the EGL function calls leading to this error.

Below is my source. And actually, I can deploy this project to Tomcat 6 before this error occurs.

function start()
readFromTable(); // this is line 284
end

function cellClicked(myGrid DataGrid in)
selectedPayment = allPayments_ui.getSelection()[1] as paymentRec;
selectedPayment_form.publish();
selectedPayment_category_comboBox.value = PaymentLib.getCategoryDesc(selectedPayment.category);
end

function readFromTable()
call SQLService.getAllPayments() using new HttpProxy returning to updateAll onException serviceExceptionHandler; // this is line 294
end
Re: Tutorial - Access a database [message #836575 is a reply to message #836539] Wed, 04 April 2012 16:48 Go to previous messageGo to next message
Doctor Hung is currently offline Doctor HungFriend
Messages: 7
Registered: February 2012
Junior Member
Hi!

After changing the line as following, the problem fixed. But I don't know why some programmer pass the compilation even without putting the interface name there.
call SQLService.getAllPayments() using new HttpProxy("services.SQLService") returning to updateAll onException serviceExceptionHandler;

Back to the formatter error. The source is as following. What is wrong with formatters = [ formatCategory ] ? This has no problem when we use version 0.7

columns =[
new DataGridColumn{name = "category", displayName = "Type",
width = 90, formatters = [ formatCategory ]},
new DataGridColumn{name = "description", displayName = "Description",
width = 120},
new DataGridColumn{name = "amount", displayName = "Amount due",
width = 90, alignment = DataGridLib.ALIGN_RIGHT}
],
Re: Tutorial - Access a database [message #836625 is a reply to message #836575] Wed, 04 April 2012 18:04 Go to previous messageGo to next message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
As you've observed, when using an interface in the call statement you must supply the implementation name (this is not required if referencing the service part directly). It's valid syntax to leave the implementation name out, therefore you do not get a validation error, and instead get a runtime error. An example as to why it can't be a validation error would be you have defined your own type of IHTTP that does not have such a requirement. It would be like getting a validation error because you are assigning a string field to an integer field, and the string field contains non-numeric data; this is valid syntax and would only fail at runtime.

As for the formatter error, this is due to a change we made I think in 0.8 M3 where the string type is now a reference type instead of a value type, meaning its default parameter modifier has changed from INOUT to IN. The CellFormatter delegate defines the parameters to be of type INOUT, therefore you must change your function signature to: function formatCategory(class string inout, value string inout, rowData any in)

Right now the tutorial has it use the default modifier, which is no longer INOUT, and thus doesn't match the definition of CellFormatter.

I've updated the tutorial for this change so that it's once again without error. Let me know if you have any other questions!

-Justin
Re: Tutorial - Access a database [message #836627 is a reply to message #836575] Wed, 04 April 2012 18:06 Go to previous messageGo to next message
Brian Svihovec is currently offline Brian SvihovecFriend
Messages: 55
Registered: July 2009
Member
Hi.

Regarding the format errors, can you list what version of the widget projects you are using in EDT .8?

Due to changes in the compiler that require a '?' modifier on function parameters that accept a null value, most of the format function delegates had to be updated. I am guessing that you will need to add a '?' to the parameters in your implementation of the format functions.

-Brian
Re: Tutorial - Access a database [message #836863 is a reply to message #836625] Thu, 05 April 2012 01:26 Go to previous messageGo to next message
Doctor Hung is currently offline Doctor HungFriend
Messages: 7
Registered: February 2012
Junior Member
Dear Justin,

The problem is fixed after changing to use inout. Thanks a lot.
Any suggestion to us for the next step after learning this tutorial.

Re: Tutorial - Access a database [message #837613 is a reply to message #836863] Thu, 05 April 2012 22:31 Go to previous message
Justin Spadea is currently offline Justin SpadeaFriend
Messages: 66
Registered: July 2009
Member
Excellent! As a next step I would try to come up with a small application idea that uses similar concepts as the tutorial, to see if you're able to accomplish the task without being told what to do, and then from there you could add more and more complexity to the user interface and/or service logic to become more familiar with the tools and language. Feel free to post any questions that might arise from this!

-Justin
Previous Topic:Dedicated service changes
Next Topic:Follow EDT on Twitter
Goto Forum:
  


Current Time: Thu Nov 07 22:42:35 GMT 2024

Powered by FUDForum. Page generated in 0.05859 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top