Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA/GlassFishV3 Web Tutorial"

m (EclipseLink JPA Deployed on GlassFish 3 using Eclipse WTP)
m (References)
 
(34 intermediate revisions by the same user not shown)
Line 1: Line 1:
=EclipseLink JPA Deployed on GlassFish 3 using Eclipse WTP=
+
=EclipseLink JPA Deployed on GlassFish 3 using Eclipse 3.5=
 
+
* '''This Tutorial is back on as part of [http://bugs.eclipse.org/333336 333336] and [http://bugs.eclipse.org/322288 322288]'''
 +
*If you are using Glassfish 3 as your EE container then you likely are using Netbeans as your IDE - see the page on using [http://wiki.eclipse.org/EclipseLink/Examples/JPA/IDE/NetBeans#EclipseLink_library Netbeans with EclipseLink tutorial] as well.
 +
<!--* '''<font color="orange">This tutorial's progress is on hold, it needs to be finished and significantly expanded - vote for EclipseLink bug# ''[http://bugs.eclipse.org/308477 308477]'' if you would like this work to be fast tracked and/or raised in the queue.</font>'''-->
 +
<!--[[Image:Oracle_buys_sun_20091017.jpg]]-->
 
''[[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|Please refer to the GlassFish V2 page for generic EclipseLink on GlassFish Issues.]]
 
''[[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|Please refer to the GlassFish V2 page for generic EclipseLink on GlassFish Issues.]]
 +
<font color="red">--old content start--</font>
 +
If you want to get a small web application running quickly on the GlassFish V3 application server using the Eclipse IDE, follow the instructions in this tutorial.
  
If you want to get a small web application running quickly on GlassFish - the services provided by the '''Web Tools Project''' pluggin in the '''Eclipse IDE''' can take care of the deployment details and set the server into debug mode for you.
+
This basic example details how to use Eclipse to run/debug a minimum J2EE 5/6 web application servlet using [http://www.eclipselink.org EclipseLink JPA] as the persistence provider.  The goal of this example is to detail the minimum steps needed to run EclipseLink inside GlassFish V3 using the Eclipse IDE - at this point no presentation/controller layer such as JSF, Spring or Struts will be used beyond a basic HttpServlet so we can concentrate on the the integration layer JPA setup.
 
+
This basic example details how to use Eclipse to run/debug a minimum J2EE web application servlet using EclipseLink JPA as the persistence provider.  The goal of this example is to detail the minimum steps needed to run EclipseLink inside GlassFish using the Eclipse IDE - at this point no presentation/controller layer such as JSF, Spring or Struts will be used beyond a basic HttpServlet so we can concentrate on the the integration layer JPA setup.
+
  
 
The [http://wiki.eclipse.org/Dali DALI] project was used to generate Entities from a schema with sequences already populated.
 
The [http://wiki.eclipse.org/Dali DALI] project was used to generate Entities from a schema with sequences already populated.
 +
 +
==Tutorial Source==
 +
<!--The EAR, EJB and WEB Eclipse project source for this EclipseLink WebLogic tutorial is available online at the following locations.  These 3 projects must be imported along with the jpa core eclipselink project.
 +
 +
*Checkout the following 3 projects together from $trunk/examples.
 +
**''org.eclipse.persistence.example.jpa.server.glassfish.enterpriseEAR''
 +
**''org.eclipse.persistence.example.jpa.server.glassfish.enterpriseEJB''
 +
**''org.eclipse.persistence.example.jpa.server.glassfish.enterpriseWeb''
 +
 +
* EclipseLink source via SVN committer access
 +
svn+ssh://user@eclipse/svnroot/rt/org.eclipse.persistence/trunk
 +
 +
* EclipseLink source via SVN anonymous access
 +
svn://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk
 +
 +
The following link will put you at the root of the SVN tree using the online version of subclipse.
 +
 +
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.glassfish.enterpriseEAR
 +
 +
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.glassfish.enterpriseEJB
 +
 +
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.glassfish.enterpriseWeb
 +
-->
 +
And the DDL generation J2SE JPA application used to populate the database schema.
 +
 +
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.common.ddlgen
  
 
==Development Environment==
 
==Development Environment==
'''Software:''' [http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/R/eclipse-jee-ganymede-win32.zip Eclipse IDE for Java EE 3.4 Ganymede] (June 2008 +) with all 5 packages (DTP 1.6, EMF 2.4, GEF 3.4, WTP 3.0, XSD 2.4), Oracle 11g DB 11.1.0.6.0, Java JDK 1.6.0_04, [http://download.java.net/glassfish/v3/promoted GlassFish V3 Prelude]
+
'''Software:''' [http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/R/eclipse-jee-galileo-win32.zip Eclipse IDE for Java EE 3.5 Galileo] (June 2009 +) , JavaDB (part of GlassFish), SUN Java JDK 1.6.0_xx, [https://glassfish.dev.java.net/public/downloadsindex.html GlassFish V3 Prelude]
  
This example will run fine with any Database that EclipseLink supports.
+
This example will also run fine with any Database that EclipseLink supports.
  
 
==Prerequisites==
 
==Prerequisites==
 
===<font color="green">Install Eclipse EE</font>===
 
===<font color="green">Install Eclipse EE</font>===
*I installed a clean version of Eclipse Ganymede (June 2008) with all of WTP 3.0
+
*I installed a clean version of Eclipse 3.5 Galileo (June 2009)
  
 
===<font color="green">Install a Database</font>===
 
===<font color="green">Install a Database</font>===
*In this example I am using Oracle 11g, the table schemas have already been created manually and all entity java classes have been generated using the Eclipse [http://wiki.eclipse.org/Dali DALI] tool.
+
*In this example I am the included JavaDB that is part of GlassFish V3, the table schemas have already been created manually and all entity java classes have been generated using the Eclipse [http://wiki.eclipse.org/Dali DALI] tool.
  
 
===<font color="green">Install GlassFish</font>===
 
===<font color="green">Install GlassFish</font>===
*Do not use V3 TP2 - use the [http://download.java.net/glassfish/v3/promoted/ V3 Prelude release] instead.
+
*Do not use V3 TP2 - use the [https://glassfish.dev.java.net/public/downloadsindex.html V3 Prelude release] instead.
 
*The following issues were quickly solved within a 24h timeframe when posted to the [http://forums.java.net/jive/forum.jspa?forumID=56&start=0 GlassFish Forum]
 
*The following issues were quickly solved within a 24h timeframe when posted to the [http://forums.java.net/jive/forum.jspa?forumID=56&start=0 GlassFish Forum]
 +
**[http://forums.java.net/jive/thread.jspa?threadID=46886&tstart=0 http://forums.java.net/jive/thread.jspa?threadID=46886&tstart=0 GF3tp2 domain1 fails to start out of the box - JDK 1.7 collision and no proxy set]
 +
**[http://forums.java.net/jive/thread.jspa?threadID=46901&tstart=0 http://forums.java.net/jive/thread.jspa?threadID=46886&tstart=0 GlassFish V3 SNAPSHOT Server Plugin for Eclipse 3.4 jar problems with TP2 - use the Prelude Plugin]
 +
===<font color="green">Install Glassfish Tools Bundle for Eclipse</font>===
 +
*The following link will get you a fully configured Eclipse 3.5.1 workspace with a server configuration to Glassfish V3
 +
*http://download.java.net/glassfish/eclipse/StartDownload.html?asset=glassfish%2Feclipse%2F1.2.0%2Fglassfish-tools-bundle-for-eclipse-1.2.exe
 +
===<font color="green">Install Eclipse GlassFish Server Plugin</font>===
 +
*Currently the '''"Download additional server adapters"''' link on the ''"New Server"'' dialog will not work with Eclipse 3.5 - '''Use the "Help | Install New Software" menu instead ''' via the https://ajax.dev.java.net/eclipse/site.xml update site to get version 32+ of the plugin that is compatible with Galileo.
 +
**You may refer to the details of Eclipse Bug # [http://bugs.eclipse.org/280365 280365].
 +
<!--*It is recommended that you install the GlassFish V3 Prelude version and use the latest 1.0.9+ V3 SNAPSHOT Eclipse 3.4 Server plugin to run/debug the prelude server. 
 +
*Using the GlassFish V3 Prelude install - we select the SNAPSHOT version of the plugin after using "Download Additional Server Adapters" to get a 1.0.9 GlassFish plugin or later.
  
[http://forums.java.net/jive/thread.jspa?threadID=46886&tstart=0 http://forums.java.net/jive/thread.jspa?threadID=46886&tstart=0 GF3tp2 domain1 fails to start out of the box - JDK 1.7 collision and no proxy set]
+
[[Image:Glassfish_prelude_new_server_use_snapshot.JPG]]
  
[http://forums.java.net/jive/thread.jspa?threadID=46901&tstart=0 http://forums.java.net/jive/thread.jspa?threadID=46886&tstart=0 GlassFish V3 SNAPSHOT Server Plugin for Eclipse 3.4 jar problems with TP2 - use the Prelude Plugin]
+
-->
  
*It is recommended that you install the GlassFish V3 Prelude version and use the latest 1.0.9+ V3 SNAPSHOT Eclipse 3.4 Server plugin to run/debug the prelude server.
+
*Currently we get
*Using the GlassFish V3 Prelude install - we select the SNAPSHOT version of the plugin after using "Download Additional Server Adapters" to get a 1.0.9 GlassFish plugin or later.
+
**cannot Deploy org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR
 +
  Deployment Error for module: org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR: Exception while deploying the app : java.lang.IllegalArgumentException: Application [org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR] contains no valid components%%%EOL%%%
  
[[Image:Glassfish_prelude_new_server_use_snapshot.JPG]]
+
==EclipseLink Library Location==
 +
*The EclipseLink modules ship as 5 separate jars in the standard modules directory (Note EclipseLink SDO and JAXB are precluded by the libraries shipped with GlassFish - the milestone version is from the JPA 2.0 trunk branch.
 +
**\glassfish\modules
 +
***org.eclipse.persistence.antlr.jar
 +
***org.eclipse.persistence.asm.jar
 +
***org.eclipse.persistence.core.jar
 +
***org.eclipse.persistence.jpa.jar
 +
***org.eclipse.persistence.jpa.modelgen.jar
 +
***org.eclipse.persistence.oracle.jar (optional)
 +
==JPA Specification Library Location==
 +
*javax.persistence.jar ships with GlassFish in the standard ''modules'' directory.
 +
==Updating EclipseLink Bundles Shipped with GlassFish==
 +
*http://blogs.sun.com/GlassFishPersistence/entry/updating_eclipselink_bundles_in_glassfish
 +
==Progress==
 +
<!--*20090911: I may be missing something getting an EAR running on B63.
 +
**deployment of even a web2.5/ejb3.0 ear fails both for all of the following scenarios
 +
**ant deploy script to b63
 +
**eclipse deploy to b63
 +
**autodeploy eclipse exported ear to b63
 +
**autodeploy ant exported ear to b63
 +
**autodeploy of NetBeans 6.8 ear to b63
 +
<pre>
 +
Sep 11, 2009 7:44:41 AM org.glassfish.api.ActionReport failure
 +
SEVERE: Error during deployment : no container associated with application of type : ear
 +
java.lang.RuntimeException: no container associated with application of type : ear
 +
</pre>
 +
-->
 +
*[http://bits.netbeans.org/netbeans/6.8/m1/ NetBeans 6.8.1M1 20090822] with an embedded GlassFish b58 is working fine.
 +
*I am testing on NetBeans from now on and will investigate ant/eclipse deployment later
 +
*All of deployment, JNDI setup, persistence.xml configuration, jpql query example - in progress ......
 +
 
 +
 
 +
<!--
 +
==Downloading EclipseLink Libraries==
 +
===Download EclipseLink using HTTP - recommended===
 +
*Proceed to the following URL and download the latest eclipselink.zip which contains everything you need.
 +
**http://www.eclipse.org/eclipselink/downloads/index.php
 +
***'''Click on the "EclipseLink Installer Zip''' link which resolves to http://www.eclipse.org/downloads/download.php?file=/rt/eclipselink/releases/n.n.n/eclipselink-n.n.n.zip
 +
*Expand the zip file and get the following 2 files
 +
**eclipselink-*\eclipselink\jlib\eclipselink.jar
 +
**eclipselink-*\eclipselink\jlib\jpa\javax.persistence_*.jar
 +
===Download EclipseLink using Maven===
 +
See the repository on http://www.eclipse.org/eclipselink/downloads/index.php
 +
===Download EclipseLink using SVN - developers only===
 +
*Get the following ''<font color="blue">eclipselink.jar</font>'' and ''<font color="blue">javax.persistence*.jar</font>'' from http://www.eclipselink.org ready for your EclipseLink shared library
 +
**The following page details four different ways to either obtain the binary jars or download the source and build them yourself with an anon account.
 +
**http://wiki.eclipse.org/EclipseLink/Source-->
 +
 
 +
<font color="red">--old content end--</font>
 +
 
 +
==Deploying a secure EAR on GlassFish==
 +
*This section 20110112
 +
*Download Eclipse 3.6 Helios EE edition
 +
*Update the server plugins by adding the latest Oracle GlassFish Server Tools Plugin - GlassFish 3 OSS and Commercial will arrive with this one.
 +
**'''"Download additional server adapters"''' link on the top right of the '''define a new server''' dialog
 +
**Use '''Oracle GlassFish Server Tools''' - 1.6.1 version
 +
*Download GlassFish 3.0.1 standalone EE server (not the one in NetBeans) so we can create a server in Eclipse
 +
**http://www.oracle.com/technetwork/middleware/glassfish/overview/index.html
 +
*Use the default derby datasource
 +
 
 +
===Start the GlassFish Server===
 +
*Either start the server in Eclipse or from the command line
 +
<pre>
 +
C:\opt\glassfishv301b\glassfish\bin>asadmin start-domain
 +
Waiting for DAS to start ................
 +
Started domain: domain1
 +
Domain location: C:\opt\glassfishv301b\glassfish\domains\domain1
 +
Log file: C:\opt\glassfishv301b\glassfish\domains\domain1\logs\server.log
 +
Admin port for the domain: 4848
 +
Command start-domain executed successfully.
 +
</pre>
 +
<pre>
 +
[#|2011-01-13T12:03:09.065-0430|CONFIG|oracle-glassfish3.0.1|org.eclipse.persistence.session.file:/C:/opt/glassfishv301com/glassfish/domains/domain1/applications/org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR
 +
/org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEJB_jar/
 +
_enterprise.connection|_ThreadID=29;_ThreadName=Thread-1;
 +
|Connected: jdbc:derby://localhost:1527/sun-appserv-samples;;create=true
 +
</pre>
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
 +
    <persistence-unit name="enterprise" transaction-type="JTA">
 +
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 +
        <jta-data-source>jdbc/__default</jta-data-source>
 +
        <properties>
 +
            <property name="eclipselink.target-server" value="SunAS9"/>
 +
            <!-- property name="eclipselink.target-database"
 +
                      value="org.eclipse.persistence.platform.database.DerbyPlatform"/-->
 +
            <property name="eclipselink.logging.level" value="FINEST"/>
 +
            <!-- turn off DDL generation after the model is stable -->           
 +
            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
 +
            <property name="eclipselink.ddl-generation.output-mode" value="database"/>
 +
        </properties>
 +
    </persistence-unit>
 +
</persistence>
 +
</source>
  
 +
*Create EAR application
 +
*Deploy or drop EAR on server
 +
**GlassFish V3.0.1 is running EclipseLink 2.0.1 SVN rev# [https://fisheye2.atlassian.com/changelog/eclipselink/?cs=6600 6600] from Feb 2010
 +
<pre>[#|2011-01-13T12:03:09.049-0430|INFO|oracle-glassfish3.0.1|org.eclipse.persistence.session.file:/C:/opt/glassfishv301com/glassfish/domains/domain1/applications/org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR
 +
/org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEJB_jar/_enterprise
 +
|_ThreadID=29;_ThreadName=Thread-1;|EclipseLink, version: Eclipse Persistence Services - 2.0.1.v20100213-r6600|#]
 +
</pre>
 +
*Browser results
 +
[[Image:Glassfishv013_enterprise_app_browser_screencap.JPG]]
 +
*Now we will secure GlassFish and upgrade EclipseLink to the latest 2.3 version so we can debug sychronized source in Eclipse.
 +
**Creating GlassFish bundles (5) from the EclipseLink trunk
 +
**Run the following target
 +
<pre>
 +
C:\view_22a\2.2\trunk>ant dev-package-bundles
 +
look in
 +
C:\view_22a\2.2\trunk\plugins
 +
</pre>
 +
*Note:<font color="red">'''The updated bundles are picked up by timestamp - you will need to clear the osgi-cache if the dates are older than the bundles currently on the modules dir.'''</font>
  
All of deployment, JNDI setup, persistence.xml configuration, jpql query example - in progress when we start JEE6 examples as V3 Prelude (a JEE6) server does not support deploying JEE5 EAR projects......
+
===Enabling the Security Manager in GlassFish 3===
 +
*In the following <font color="green>'''$GlassFish$/glassfish/bin'''</font> directory off the server perform these commands to run on the security manager (off by default in WebLogic and GlassFish)
 +
*Turning on the security manager in GlassFish is very simple.  It is WebLogic that has some issues that we need to look at surrounding any custom JTA datasources and their specific grants
 +
*Just an fyi that no Grant elements are required in the EAR if you use the default datasource.
 +
<source lang="xml"><jta-data-source>jdbc/__default</jta-data-source></source>
 +
*We can use the existing code for both and configure the server on the fly by creating and deleting the following two security properties.
 +
<pre>
 +
asadmin start-domain
 +
asadmin --user admin create-jvm-options -Djava.security.manager
 +
asadmin --user admin create-jvm-options -Declipselink.security.usedoprivileged=true
 +
asadmin stop-domain
 +
asadmin start-domain
 +
</pre>
 +
*Look for the following log to verify.
 +
<source lang="java">
 +
[#|2011-01-14T12:18:45.513-0430|INFO|glassfish3.0.1|javax.enterprise.system.core.security.com.sun.enterprise.security|_ThreadID=11;_ThreadName=Thread-1;|SEC1001: Security Manager is ON.|#]
 +
</source>
 +
*If you attach JConsole to your secured GlassFish 3.0.1 or 3.1 server after you exercise the EE application ''(to create a session)'' you will see the following view.
 +
[[Image:Jconsole_mbean_view_security_manager_on_glassfish301.JPG]]
  
 
==References==
 
==References==
[[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|EclipseLink JPA on GlassFish Server V2]]
+
*[[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|EclipseLink JPA on GlassFish Server V2]]
 +
*Failed deployment of Java EE application leaves broken Persistence Unit definition on Glassfish v3 b74  https://bugs.eclipse.org/bugs/show_bug.cgi?id=297312
 +
*JMX MBean Registration for GlassFish 3.1 https://bugs.eclipse.org/bugs/show_bug.cgi?id=316512
 +
*JMX PrivilegedAccess fix for EclipseLink 2.2 http://java.net/jira/browse/GLASSFISH-15337 http://bugs.eclipse.org/333336
 +
*JMX on GlassFish 1.2 http://forums.oracle.com/forums/thread.jspa?messageID=9124630&#9124630
 +
*https://bugs.eclipse.org/bugs/show_bug.cgi?id=296269
 +
*https://bugs.eclipse.org/bugs/show_bug.cgi?id=322287
 +
*https://bugs.eclipse.org/bugs/show_bug.cgi?id=320826
 +
*Build: default and dev-package-bundles target missing missing o.e.p.jpa.osgi jar for OSGI users in plugins dir https://bugs.eclipse.org/bugs/show_bug.cgi?id=297711
 +
*Need to verify that rev 8141 fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=297312
 +
===GlassFish Server in Use===
 +
*[http://blogs.sun.com/stories/entry/t_mobile_high_availability_and GlassFish and TMobile]
 +
*[http://blogs.sun.com/stories/entry/xeroxgs GlassFish and Xerox]
 +
*[http://blogs.sun.com/stories/entry/psa_peugeot GlassFish and Peugeot]
 +
*[http://blogs.sun.com/stories/entry/telefonica_brazil_tracking_touble_tickets GlassFish and Telefonica]
 +
*[http://blogs.sun.com/stories/entry/verizon_uses_opensso_in_large GlassFish and Verizon]

Latest revision as of 21:03, 2 March 2011

EclipseLink JPA Deployed on GlassFish 3 using Eclipse 3.5

Please refer to the GlassFish V2 page for generic EclipseLink on GlassFish Issues. --old content start-- If you want to get a small web application running quickly on the GlassFish V3 application server using the Eclipse IDE, follow the instructions in this tutorial.

This basic example details how to use Eclipse to run/debug a minimum J2EE 5/6 web application servlet using EclipseLink JPA as the persistence provider. The goal of this example is to detail the minimum steps needed to run EclipseLink inside GlassFish V3 using the Eclipse IDE - at this point no presentation/controller layer such as JSF, Spring or Struts will be used beyond a basic HttpServlet so we can concentrate on the the integration layer JPA setup.

The DALI project was used to generate Entities from a schema with sequences already populated.

Tutorial Source

And the DDL generation J2SE JPA application used to populate the database schema.

http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.common.ddlgen

Development Environment

Software: Eclipse IDE for Java EE 3.5 Galileo (June 2009 +) , JavaDB (part of GlassFish), SUN Java JDK 1.6.0_xx, GlassFish V3 Prelude

This example will also run fine with any Database that EclipseLink supports.

Prerequisites

Install Eclipse EE

  • I installed a clean version of Eclipse 3.5 Galileo (June 2009)

Install a Database

  • In this example I am the included JavaDB that is part of GlassFish V3, the table schemas have already been created manually and all entity java classes have been generated using the Eclipse DALI tool.

Install GlassFish

Install Glassfish Tools Bundle for Eclipse

Install Eclipse GlassFish Server Plugin

  • Currently the "Download additional server adapters" link on the "New Server" dialog will not work with Eclipse 3.5 - Use the "Help | Install New Software" menu instead via the https://ajax.dev.java.net/eclipse/site.xml update site to get version 32+ of the plugin that is compatible with Galileo.
    • You may refer to the details of Eclipse Bug # 280365.
  • Currently we get
    • cannot Deploy org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR
 Deployment Error for module: org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR: Exception while deploying the app : java.lang.IllegalArgumentException: Application [org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR] contains no valid components%%%EOL%%%

EclipseLink Library Location

  • The EclipseLink modules ship as 5 separate jars in the standard modules directory (Note EclipseLink SDO and JAXB are precluded by the libraries shipped with GlassFish - the milestone version is from the JPA 2.0 trunk branch.
    • \glassfish\modules
      • org.eclipse.persistence.antlr.jar
      • org.eclipse.persistence.asm.jar
      • org.eclipse.persistence.core.jar
      • org.eclipse.persistence.jpa.jar
      • org.eclipse.persistence.jpa.modelgen.jar
      • org.eclipse.persistence.oracle.jar (optional)

JPA Specification Library Location

  • javax.persistence.jar ships with GlassFish in the standard modules directory.

Updating EclipseLink Bundles Shipped with GlassFish

Progress

  • NetBeans 6.8.1M1 20090822 with an embedded GlassFish b58 is working fine.
  • I am testing on NetBeans from now on and will investigate ant/eclipse deployment later
  • All of deployment, JNDI setup, persistence.xml configuration, jpql query example - in progress ......


--old content end--

Deploying a secure EAR on GlassFish

  • This section 20110112
  • Download Eclipse 3.6 Helios EE edition
  • Update the server plugins by adding the latest Oracle GlassFish Server Tools Plugin - GlassFish 3 OSS and Commercial will arrive with this one.
    • "Download additional server adapters" link on the top right of the define a new server dialog
    • Use Oracle GlassFish Server Tools - 1.6.1 version
  • Download GlassFish 3.0.1 standalone EE server (not the one in NetBeans) so we can create a server in Eclipse
  • Use the default derby datasource

Start the GlassFish Server

  • Either start the server in Eclipse or from the command line
C:\opt\glassfishv301b\glassfish\bin>asadmin start-domain
Waiting for DAS to start ................
Started domain: domain1
Domain location: C:\opt\glassfishv301b\glassfish\domains\domain1
Log file: C:\opt\glassfishv301b\glassfish\domains\domain1\logs\server.log
Admin port for the domain: 4848
Command start-domain executed successfully.
[#|2011-01-13T12:03:09.065-0430|CONFIG|oracle-glassfish3.0.1|org.eclipse.persistence.session.file:/C:/opt/glassfishv301com/glassfish/domains/domain1/applications/org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR
/org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEJB_jar/
_enterprise.connection|_ThreadID=29;_ThreadName=Thread-1;
|Connected: jdbc:derby://localhost:1527/sun-appserv-samples;;create=true
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="enterprise" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/__default</jta-data-source>
        <properties>
            <property name="eclipselink.target-server" value="SunAS9"/>
            <!-- property name="eclipselink.target-database" 
                      value="org.eclipse.persistence.platform.database.DerbyPlatform"/-->
            <property name="eclipselink.logging.level" value="FINEST"/>
            <!-- turn off DDL generation after the model is stable -->            
            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
            <property name="eclipselink.ddl-generation.output-mode" value="database"/>
        </properties>
    </persistence-unit>
</persistence>
  • Create EAR application
  • Deploy or drop EAR on server
    • GlassFish V3.0.1 is running EclipseLink 2.0.1 SVN rev# 6600 from Feb 2010
[#|2011-01-13T12:03:09.049-0430|INFO|oracle-glassfish3.0.1|org.eclipse.persistence.session.file:/C:/opt/glassfishv301com/glassfish/domains/domain1/applications/org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEAR
/org.eclipse.persistence.example.jpa.server.glassfishv3.EnterpriseEJB_jar/_enterprise
|_ThreadID=29;_ThreadName=Thread-1;|EclipseLink, version: Eclipse Persistence Services - 2.0.1.v20100213-r6600|#]
  • Browser results

Glassfishv013 enterprise app browser screencap.JPG

  • Now we will secure GlassFish and upgrade EclipseLink to the latest 2.3 version so we can debug sychronized source in Eclipse.
    • Creating GlassFish bundles (5) from the EclipseLink trunk
    • Run the following target
C:\view_22a\2.2\trunk>ant dev-package-bundles
look in
C:\view_22a\2.2\trunk\plugins
  • Note:The updated bundles are picked up by timestamp - you will need to clear the osgi-cache if the dates are older than the bundles currently on the modules dir.

Enabling the Security Manager in GlassFish 3

  • In the following $GlassFish$/glassfish/bin directory off the server perform these commands to run on the security manager (off by default in WebLogic and GlassFish)
  • Turning on the security manager in GlassFish is very simple. It is WebLogic that has some issues that we need to look at surrounding any custom JTA datasources and their specific grants
  • Just an fyi that no Grant elements are required in the EAR if you use the default datasource.
<jta-data-source>jdbc/__default</jta-data-source>
  • We can use the existing code for both and configure the server on the fly by creating and deleting the following two security properties.
asadmin start-domain
asadmin --user admin create-jvm-options -Djava.security.manager
asadmin --user admin create-jvm-options -Declipselink.security.usedoprivileged=true
asadmin stop-domain
asadmin start-domain
  • Look for the following log to verify.
[#|2011-01-14T12:18:45.513-0430|INFO|glassfish3.0.1|javax.enterprise.system.core.security.com.sun.enterprise.security|_ThreadID=11;_ThreadName=Thread-1;|SEC1001: Security Manager is ON.|#]
  • If you attach JConsole to your secured GlassFish 3.0.1 or 3.1 server after you exercise the EE application (to create a session) you will see the following view.

Jconsole mbean view security manager on glassfish301.JPG

References

GlassFish Server in Use

Back to the top