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/WebSphere Web Tutorial"

m (Install WebSphere Eclipse 3.4 Server Plugin)
m (EclipseLink JPA Deployed on IBM WebSphere 6.1 using Eclipse WTP)
Line 32: Line 32:
  
 
===Install WebSphere Eclipse 3.4 Server Plugin===
 
===Install WebSphere Eclipse 3.4 Server Plugin===
The WebSphere 6.1 server plugin is not shipped by default with Eclipse (WebSphere 6.0 for JEE 1.4 is) - you will need to update your Eclipse IDE to pick up the plugin.
+
The WebSphere 6.1 Eclipse WTP server plugin is not shipped by default with Eclipse (WebSphere 6.0 for JEE 1.4 is).
Note: I am currently looking for a WebSphere 6.1 plugin (As the 6.0 plugin requires you to stub missing jars like C:\opt\was61\lib\activitySession.jar)
+
*'''Note: The WebSphere 6.1 plugin is currently not available - see the following [http://bugs.eclipse.org/160220 Eclipse WTP enhancement request in progress].
 +
*We are not blocked from using Eclipse WTP to manage the WebSphere 6.1 server, but without this plugin we will need to attach manually to port 5005 of a running WebSphere server that was started in debug mode outside of the Eclipse IDE - we will use this alternate debug approach.
  
I am currently blocked from using Eclipse WTP to manage the WebSphere 6.1 server by a problem with the 6.0 plugin in bug [http://bugs.eclipse.org/247974 247974].
+
==WebSphere Configuration Changes==
 +
WebSphere configuration modifications can be done on the admin console.
  
I will use the alternate approach of deploying manually and attaching to the debug server port from Eclipse.
+
https://localhost:9043/ibm/console/login.do?action=secure
  
===Validating the WebSphere/Eclipse configuration===
 
*In the servers view select ''New | Server''
 
 
*Use the '''IBM|IBM WebSphere 6.1 Server''' plugin when creating a server
 
 
*Start the server to test the plugin
 
 
==WebSphere Configuration Changes==
 
WebSphere configuration modifications can be done on the admin console
 
 
==JNDI Datasource Setup==
 
==JNDI Datasource Setup==
  
Line 53: Line 46:
  
 
==Persistence JAR location==
 
==Persistence JAR location==
 +
WebSphere 6.1 (with EJB3 fixpack) comes with JPA support and will not need any other reference to the 1.0 specification persistence.jar
  
 
==EclipseLink JAR location==
 
==EclipseLink JAR location==
 +
*The eclipselink.jar will need to be setup as a shared library in the admin console off of the environment subtree.
 +
*Reference the full classpath to a copy of eclipselink.jar using a global scope.
 +
[[Image:Was61_admin_env_shared_lib1.JPG]]
 +
*Save the shared-library change and restart the server.
 +
[[Image:Was61_admin_env_shared_lib2.JPG]]
  
 
==JDBC JAR location==
 
==JDBC JAR location==
 +
 +
===Validating the WebSphere/EclipseLink configuration===
 +
*Start the server from the command-line or via windows service.
  
 
==Create J2EE application==
 
==Create J2EE application==

Revision as of 13:55, 19 September 2008

EclipseLink JPA Deployed on IBM WebSphere 6.1 using Eclipse WTP

Note: This tutorial' is under construction for the next week as of 20080918.


If you want to get a small web application running quickly on WebSphere 6.1 - 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 web application servlet using EclipseLink JPA as the persistence provider. The goal of this example is to detail the minimum steps required to run EclipseLink inside the IBM WebSphere Application Server 6.1 server 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.

Development Environment

Software: 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), Derby Database 10.4, Java JDK 1.6.0_04, IBM WebSphere 6.1.0.0 with EJB3/JPA1 update

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

Prerequisites

Install Eclipse EE

  • I installed a clean version of Eclipse Ganymede (June 2008) with all of WTP 3.0

Install a Database

  • In this example I am using the embedded Derby 10.4, the table schemas have already been created manually and all entity java classes may be generated using the Eclipse DALI tool.
  • There is also an express version of IBM DB2 Express C 9.5 available

Install WebSphere 6.1

I installed the commercial 6.1.0.0 version with the EJB 3.0 fixpack and updates.

  • download.updii.61017.windows.ia32.zip
  • 6.1.0-WS-WASSDK-WinX32-FP0000017.pak
  • 6.1.0-WS-WAS-WinX32-FP0000017.pak
  • 6.1.0-WS-WASEJB3-WinX32-FP0000017.pak
  • I augumented the original server profile


Install WebSphere Eclipse 3.4 Server Plugin

The WebSphere 6.1 Eclipse WTP server plugin is not shipped by default with Eclipse (WebSphere 6.0 for JEE 1.4 is).

  • Note: The WebSphere 6.1 plugin is currently not available - see the following Eclipse WTP enhancement request in progress.
  • We are not blocked from using Eclipse WTP to manage the WebSphere 6.1 server, but without this plugin we will need to attach manually to port 5005 of a running WebSphere server that was started in debug mode outside of the Eclipse IDE - we will use this alternate debug approach.

WebSphere Configuration Changes

WebSphere configuration modifications can be done on the admin console.

https://localhost:9043/ibm/console/login.do?action=secure

JNDI Datasource Setup

Global Scoped Datasource Setup

Persistence JAR location

WebSphere 6.1 (with EJB3 fixpack) comes with JPA support and will not need any other reference to the 1.0 specification persistence.jar

EclipseLink JAR location

  • The eclipselink.jar will need to be setup as a shared library in the admin console off of the environment subtree.
  • Reference the full classpath to a copy of eclipselink.jar using a global scope.

Was61 admin env shared lib1.JPG

  • Save the shared-library change and restart the server.

Was61 admin env shared lib2.JPG

JDBC JAR location

Validating the WebSphere/EclipseLink configuration

  • Start the server from the command-line or via windows service.

Create J2EE application

Persistence.xml

The WebSphere 6.1 server is defined as "WebSphere_6_1"

  • JTA : Put persistence.xml beside your JPA entities in yourProjectEJB/ejbModule/META-INF
<persistence version="1.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_1_0.xsd">
  <persistence-unit name="unified" 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="WebSphere_6_1"/>
      <property name="eclipselink.logging.level" value="FINEST"/>
      <property name="eclipselink.session-name" value="eclipselinkwls"/>
    </properties>
  </persistence-unit>
</persistence>
  • RESOURCE_LOCAL : non-JTA : Put persistence.xml beside your JPA entities in yourProjectEJB/ejbModule/META-INF
  • This one is used by a local SE Java app to create and pre-populated the derby database
  <persistence-unit name="stat.create.tables" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>entity..</class>
    <properties>
      <property name="eclipselink.jdbc.platform" value="oracle.toplink.platform.database.DerbyPlatform"/>
      <property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
      <property name="eclipselink.target-database" value="Derby"/>            
      <property name="eclipselink.jdbc.url" value="jdbc:derby:C:/opt/derby104/unified;create=true"/>
      <property name="eclipselink.jdbc.user" value="APP"/>
      <property name="eclipselink.jdbc.password" value="APP"/>
      <property name="eclipselink.logging.level" value="FINEST"/>            
      <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
      <property name="eclipselink.ddl-generation.output-mode" value="database"/>
    </properties>
  </persistence-unit>

Start Server

Publish EAR

Perform CRUD operations: JPQL insert and query

Browser Output

References


Originated on build 20080918 - Michael O'Brien

Copyright © Eclipse Foundation, Inc. All Rights Reserved.