These are step-by-step instructions that describe how you can set up an environment for the Scalable Enterprise Applications course.
DERBY
, donât write derby
.glassfish5
folder, donât choose the glassfish-5.0
one.zip
files: unzip them into a separate directory.
.exe
files.Component to download | Notes | More notes |
---|---|---|
Java Development Kit 1.8 | Not JRE only. | Any newer version (e.g. JDK 11) is incompatible with the described toolset currently. |
Run the Eclipse Installer, install the Java EE Developers IDE | Make sure you get the âEEâ edition. | Alternatively, download and extract the zip file. |
EclipseLink Installer | This is the persistence provider. | |
GlassFish 5.0 - Full Platform | Not needed for JPA exercises. | |
Lombok | Run the downloaded .jar file. |
In the installer, donât rely on autodetection: select your Eclipse directory manually. |
bin distribution of Derby |
Get the topmost .zip file. |
workspaceSEA
. Use this workspace only for this course.
FileâSwitch Workspace
.Eclipse menu to choose | What | Notes | More notes |
---|---|---|---|
HelpâEclipse Marketplace |
AnyEdit Tools | ||
HelpâInstall new software |
GlassFish Tools | http://download.eclipse.org/glassfish-tools/1.0.0/repository |
Donât install from Eclipse Marketplace. |
WindowâPreferencesâJavaâBuild PathâClasspath Variables
.
WindowâPreferences
, type a part of what you search for (e.g. variables
) to filter options quickly.Ctrl-3
) can be even faster.Click New...
to add the following variables.
Variable name | Type | Set it to this content | Notes | More notes |
---|---|---|---|---|
DERBY |
folder | your extracted db-derby-10.14.2.0-bin folder |
Not the bin folder inside. |
|
ECLIPSELINK |
folder | your extracted eclipselink folder |
Not the bin folder inside. |
|
GLASSFISH |
folder | your extracted glassfish5 folder |
Not the bin folder inside. |
|
LOMBOK |
file | your lombok.jar file |
||
PERS |
file | the file jlib/jpa/javax.persistence_VSN.vVSN.jar under eclipselink |
Not the file with source in its name. |
VSN is a version number |
If the Markers
tab shows Unbound classpath variable
problems, open the related projectâs properties, then Java Build PathâLibraries
. There, all items with variables should show the resolved full paths. If some of them are missing, fix the variableâs contents.
FileâImport
, select Existing Projects into Workspace
.
Finish
.FileâImportâWorking Sets
. Select enterprise-applications-working-sets.wst
(the only file in the workspace folder, below the directories) in your workspace folder, then click Finish
.FileâNewâOther...âServer
, choose GlassFish
.
GlassFish location
, choose the glassfish
folder under glassfish5
.Java location
is not automatically filled, enter your JDK folder there.
GlassFish SEA
.
WindowâPreferencesâServerâRuntime Environments
.4848
.servlet-jpa
example, in ResourcesâJDBCâJDBC Resources
, add the resource pool jdbc/books
.
jdbc/books__pm
and jdbc/books__nontx
.
pm
stands for âpersistence managedâ, and nontx
for ânon-transactionalâ.JMS-Queue
example, in ResourcesâJMS ResourcesâDestination Resources
, add a new message queue named jms/ExampleQueue
with the physical destination name ExampleQueue
.WindowâShow viewâData Source Explorer
. The Data Source Explorer
tab opens.Database Connections
, and select New...
Derby
, then click Next
.New Driver Definition
)Derby Client JDBC Driver, 10.2
.
JAR List
tab.derbyclient.jar
, then on Edit JAR/Zip...
db\lib\derbyclient.jar
under your JDK folder.OK
to exit "Edit Driver Definition"
Drivers
dropdown contains a "Derby Client JDBC Driver"
Test Connection
.Ping succeeded!
Finish
.Database Connections
tab to check the actual contents of the database when you run the examples.workspaceSEA
to open as your default workspace.Task List
and Outline
tabs, as they wonât be needed.Package Explorer
. There, select Filters
, and tick Libraries from external
and Libraries in project
.Save and Launch
dialog window appears. In it, tick Always save resources before launching
.Package Explorer
tab to the left side, then close Project Explorer
.Servers
tab to the right of Console
so that both are visible.JavaâCode StyleâFormatterâEditâIndentationâAlign items in columns
, tick all, then save to a new profile name.JavaâEditorâSave Actions
, enable Organize imports
.
Configure
, tick Code OrganizingâCorrect indentation
.Configure
, tick Unnecessary CodeâRemove unused imports
.Configure
, tick Unnecessary CodeâRemove redundant ...
.JavaâEditorâTyping
, tick Semicolons
.WindowâPreferencesâJavaâAppearanceâType Filters
, add the following.
java.lang.Object
java.awt.*
com.sun.*
*.internal.*
WindowâPreferencesâJavaâAppearanceâType Filters
, tick Hide discouraged references
.GeneralâWorkspace
, tick Refresh using native hooks or polling
.In most of the examples, we use JPA, which is configured to try to connect to a running Derby instance. The following steps help you start a Derby instance. You need to do this again every time you start working with the examples.
cmd
), then execute the following commands.
DERBY
with the path to Derby (your db-derby-10.14.2.0-bin
folder).cd %USERPROFILE%
mkdir derbytmp
cd derbytmp
set "DERBY_OPTS=-Duser.language=en -Dderby.drda.debug=true"
"DERBY\bin\startNetworkServer.bat"
Apache Derby Network Server started and ready to accept connections on port 1527
. If you donât, there is something wrong.Notes:
Program Files
, it is definitely not good.derbytmp
folder once youâre done running Derby.DERBY_OPTS
line helps avoid a problem that seems to appear if your operating system uses a display language other than English.You can create a web application in Eclipse in the following way.
Dynamic Web Project
.Project Explorer
, and choose Java EE ToolsâGenerate Deployment Descriptor Stub
. This generates a web.xml
file in WebContent/WEB-INF
.GlassFish Console
: in your browser, go to the URL http://localhost:4848
.Create New JDBC Resource
.
jdbc/YOURPERSISTENCEUNIT
.jdbc/YOURPERSISTENCEUNIT__pm
and jdbc/YOURPERSISTENCEUNIT__nontx
.
JPA Contentâpersistence.xmlâSourceâjta-data-source
in your project.META-INF/persistence.xml
.@WebMethod
s etc.
Unfortunately, the GlassFish admin console sometimes fails spectacularly when you try creating a resource with it. Here is another approach.
$GLASSFISH/bin/asadmin start-domain
in a console.
$GLASSFISH/bin/asadmin create-jdbc-resource --connectionpoolid=DerbyPool RESOURCENAME
RESOURCENAME
can be jdbc/books
(or, for older GlassFish versions, jdbc/books__pm
and jdbc/books__nontx
).You can create a basic EJB following these steps. You will need to create four projects.
@Stateless
and @Remote
similar to the example.Deployment Assembly
, add both the interface project and the EJB project to it.Start in
is empty. If it is, enter Eclipseâs path here.port number 1527
, it is most probably about Derby not running.
JDBC
or JPA
in their names will try to connect to a running Derby instance. Run Derby from the command line.set "DERBY_OPTS=-Duser.language=en -Dderby.drda.debug=true"
before you call startNetworkServer
.Details
button.Serializable
.Refresh
the project from its context menu.WindowâPreferencesâJavaâInstalled JREs
whether you have a JDK selected. If youâve got a JRE instead, add your JDK, and make it default.Java Build PathâLibraries
.WindowâShow ViewâMarkers
), and have a look at the error message.
Close Unrelated Projects
in the projectâs context menu to see just the relevant messages.Publishing to GlassFish ... has encountered a problem
with the details cannot Deploy [your-application-name] deploy is failing=Application with name [your-application-name] is not deployed
.Servers
tab in Eclipse, select the application, and press Del
.NullPointerException
). You can use the GlassFish Admin Console to remove the stuck application.$GLASSFISH\glassfish\domains\domain1\logs\server.log
Invalid ejb jar ... it contains zero ejb
even though you do have at least one in your EJB descriptor.Clean
in GlassFishâs context menu.ProjectâClean...
in Eclipse.ProjectâClean...
afterwards.FileâSwitch Workspace
), and do all setup steps from the beginning.