Wiki source code of Getting Started with Direct to Java Client (D2JC)
Last modified by Lazy Lazarus on 2025/03/28 11:42
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | This tutorial will get you started with Direct to Java Client, also known as D2JC, by simply creating a new project in WOLips and adding an EOModel, then launching it. The first few steps involve downloading and installing the D2JC WOLips Project Template. These steps shouln't be required for much longer. | ||
2 | |||
3 | ==== Create a Project Templates directory ==== | ||
4 | |||
5 | [[image:Create_a_Project_Templates_directory.png]] | ||
6 | You need to create a "Project Templates" directory in ~~/Library/Application Support/WOLips/ | ||
7 | |||
8 | ==== Download the D2JC Project Template ==== | ||
9 | |||
10 | [[image:Download_the_D2JC_Project_Template.png]] | ||
11 | You can add new project templates to WOLips in addition to the built-in ones it ships with. | ||
12 | |||
13 | Go to [[WOLips Project Templates>>doc:WOL.Home.WOLips.WOLips Project Templates.WebHome]] and download the D2JC Project Template. | ||
14 | |||
15 | ==== Save the Project Template ==== | ||
16 | |||
17 | [[image:Save_the_Project_Template.png]] | ||
18 | Save the template .zip file in the Project Templates directory, then unzip it. | ||
19 | |||
20 | ==== New Project from Template ==== | ||
21 | |||
22 | [[image:New_Project_from_Template.png]] | ||
23 | Start Eclipse and Select File -> New -> Other... -> WOLips -> WOProject From Template | ||
24 | |||
25 | ==== Select the template ==== | ||
26 | |||
27 | [[image:Select_the_template.png]] | ||
28 | Select Direct To Java Client WebStart Project from the list of Templates | ||
29 | |||
30 | ==== Define Packages ==== | ||
31 | |||
32 | [[image:Define_Packages.png]] | ||
33 | Define the Java Packages for your project. One of the key concepts to understand with a Java Client appication is that there can be both client-side and server-side classes for each of your Entities. The incremental and Ant builders for the client-side classes specifically lookes for classes with "client" in their package name to determine if they should be part of the client-side classes, so make sure your Client-Side EOF Class Package includes "client" in it at some point. | ||
34 | |||
35 | ==== Name your Project ==== | ||
36 | |||
37 | [[image:Name_your_Project.png]] | ||
38 | Give it a name just like you would with any other WebObjects Application. Just click Finished here instead of "Next" as we will add your EOModel to the project later. | ||
39 | |||
40 | ==== Launch the Application ==== | ||
41 | |||
42 | [[image:Launch_the_Application.png]] | ||
43 | Launch the Application just like any other WebObjects application. | ||
44 | |||
45 | ==== Select the Application class ==== | ||
46 | |||
47 | [[image:Select_the_Application_class.png]] | ||
48 | Select the Application class that is in your Base Package. | ||
49 | |||
50 | ==== Possible problem: Can't connect to localhost/127.0.0.1 ==== | ||
51 | |||
52 | When using Mac OS X 10.15 Catalina and OpenJDK 11 you may find the WebObjects server may not be reached by the Java Client via localhost (127.0.0.1) even though accessing the WebObjects server application via web browser works well. | ||
53 | |||
54 | You will experience client network/socket exceptions like "host down" or "connection refused" when you call the client execution script via terminal. | ||
55 | |||
56 | [[image:change_wo-host.png]] | ||
57 | |||
58 | Solve this by changing the launch parameter ##-WOHost## to a local IP of the machine like ##192.168.0.112##. | ||
59 | |||
60 | ==== Missing EOModel Error ==== | ||
61 | |||
62 | [[image:Missing_EOModel_Error.png]] | ||
63 | The application will launch like a Web Client WebObjects application, but instead of opening a Web browser and displaying the contents of the Main component, A D2JC application will call the client-side launch script that will automatically launch the Clent-Side application. Since we did not add an EOModel File to our project, WebObjects can't automatically create a Swing UI based on it, so we get this error instead. | ||
64 | |||
65 | ==== Quit the Java Client Application ==== | ||
66 | |||
67 | [[image:Quit_the_Java_Client_Application.png]] | ||
68 | You will see that the Java Client application is a regular application with it's own menu bar and default options. You can quit the Java Client application by iether selecting Quit from the application menu, or by using the standard keyboard shortcut. | ||
69 | |||
70 | ==== Quit the Server-Side Application ==== | ||
71 | |||
72 | [[image:Quit_the_Server-Side_Application.png]] | ||
73 | You notice that in Eclipse, the server-side appication is still running. When you quit the client side application, the server simply discarded any Objects associated with that instance of client-side application including Sessions, EditingContexts and EOs. You should now stop the server-side application. | ||
74 | |||
75 | ==== Add an EOModel File ==== | ||
76 | |||
77 | [[image:media_1246391006977.png]] | ||
78 | Drop an EOModel into the project's Resources directory. | ||
79 | |||
80 | ==== Set WOLips to generate required files ==== | ||
81 | |||
82 | [[image:media_1246384681240.png]] | ||
83 | In order for the EOAssistant to be able to modify the user.d2wmodel file in your project root, WOLips must write out both the PB.project and .xcodeproj files when it builds. Without these checked, the EOAssistant will modify the user.d2wmodel file in your project's build directory, which will get erased any time you clean your project. | ||
84 | |||
85 | This is a work-around due to a bug in WebObject's EOAssistant. A Radar has been logged (7020811). | ||
86 | |||
87 | ==== Fix broken Swing bindings ==== | ||
88 | |||
89 | Using a recent JDK (> 11 LTS) will break UI bindings because of then applied Java security constraints. | ||
90 | |||
91 | To turn off these constraints even for the autostarted Java Client Application modify the responsible script at ##/Library/Application Support/Apple/Developer Tools/WebObjects Support/UnixLaunchClient.sh##. | ||
92 | |||
93 | Look for line 227 setting the JVM options, add this option: | ||
94 | |||
95 | {{code language="sh"}} | ||
96 | DEFAULT_JVM_OPTIONS="--add-exports java.base/sun.security.action=ALL-UNNAMED" | ||
97 | {{/code}} | ||
98 | |||
99 | Rebuild the Java Client. |