Overview
This page is focused on setting up the NetBeans IDE and Glassfish to run the OpenPTK Server. These processes apply to version 2.1 (and above) of OpenPTK because of they support maven builds.
Prerequisites
Tested Versions
Product |
Version(s) |
OpenPTK |
2.1 |
NetBeans |
6.9, 7.0, 7.1 |
Glassfish |
3.0.1*, 3.1.1, 3.1.2 |
Tomcat |
6 |
Jersey |
1.12 |
Apache Commons Codec |
1.6 |
Note:
|
The server uses the Apache commons codec version 1.6. If you are deploying on Glassfish v3.0, you must replace the <glassfish>/modules/commons-codec-repackaged.jar with commons-codec-1.6.jar.
|
Overriding Jersey
Jersey is distributed with Glassfish, it needs to be overridden to use the Jersey that packaged with the jar file. The instructions below will complete the configuration required (for additional details refer to the Jersey User Guide).
Review glassfish-web.xml
To override Jersey, the OpenPTK-Server project is configured with the class loader delegation is set to false in WEB-INF/glassfish-web.xml. The provided glassfish-web.xml already has class loader delegation set to false. This file is located in the directory $OPENPTK_HOME/projects/OpenPTK/Server/web/WEB-INF. Reference the example below:
<glassfish-web-app error-url="">
<context-root>/openptk-server</context-root>
<class-loader delegate="false"/>
...
</glassfish-web-app>
Update JVM Settings
The glassfish JVM settings need to be update to include a new option:
-Dcom.sun.enterprise.overrideablejavaxpackages=javax.ws.rs,javax.ws.rs.core,javax.ws.rs.ext
- Open Netbeans, start Glassfish
- In a web browser, login to the Glassfish console (ex: http://localhost:4848/console)
- Expand Configuration
- Expand default-config
- Select JVM Settings
- Select JVM Options
- Click Add JVM Option
- Insert the above value into the new text field
- Click Save
- Expand server-config
- Select JVM Settings
- Select JVM Options
- Click Add JVM Option
- Insert the above value into the new text field
- Click Save
- Restart Glassfish
|
|
Disable Derby
The registered derby database within Glassfish needs to be disabled because it will conflict with the OpenPTK Server when it's configured to use the "embedded" (derby) Service.
Setting Glassfish Properties
- Open Netbeans
- Select the Services tab
- Expand the Servers
- Right-click the Glassfish Server
- Select Properties
- Select the Common Tab
- un-checked all the Checkboxes
- Especially:
- Enable JDBC Driver Deployment
- Start Registered Derby Server
- Select Close
- Restart Glassfish
|
|
Note:
|
Make sure that a version Derby is not already running prior to proceeding (e.g.: ps -ef |grep derby). If it is running already, stop the process. |
Open Server Project
- Select the Open Project icon
- Expand the projects folder
- Expand the OpenPTK folder
- Select the Server folder
- Check the Open Required Projects checkbox
- Click Open Projects
|
|
Open Embedded Service
- Select the Open Project icon
- Expand the ext folder
- Expand the Service folder
- Select the EmbedJDBC folder
- Check the Open Required Projects checkbox
- Click Open Projects
|
|
Set Maven Goal
- Right click the OpenPTK-Server Project
- Select Custom menu item
- Select Goals ...
- Dialog window is opened
- Set Goals to: install
- Set Profiles to: srvc-derby
- Set Remember as to: embedded
- Select OK
- The Server will be built
|
|
Run Server
- Start Glassfish
- Select the Services tab
- Expand Servers
- Right-click Glassfish Server 3.1.1
- Click Start
- Run OpenPTK Server
- Select the Projects tab
- Right-click the OpenPTK-Server Project
- Select Run
- After deployment completes
- A browser started
- The Server interface displayed
- Undeploy the application
- Expand Glassfish Server 3.1.1
- Expand Applications
- Right-click org.openptk_openptk-server_war_2.1.0-SNAPSHOT
- Select undeploy
- Stop the Glassfish Server
|
|
Note:
|
If a previous version of Derby was already running. Stop the derby process, and undeploy the server. Then follow the steps above.
|
Debug Server
- Start Glassfish in debug mode
- Select the Services tab
- Expand Servers
- Right-click Glassfish Server 3.1.1
- Click Start in Debug Mode
- Run OpenPTK Server
- Select the Projects tab
- Right-click the OpenPTK-Server Project
- Select Debug
- After deployment completes
- Debug panel is opened
- A browser started
- The Server interface displayed
- Stop the Glassfish Server
|
|
|