Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Examples/JPA/WebLogic Web Tutorial

< EclipseLink‎ | Examples‎ | JPA
Revision as of 15:50, 21 May 2008 by Unnamed Poltroon (Talk) (Create server in Eclipse)

EclipseLink JPA Deployed on WebSphere 10.0 using Eclipse WTP

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


If you want to get a small web application running quickly on WebLogic - 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 needed to run EclipseLink inside WebLogic 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

Hardware: Windows Vista SP1, HP Core2Quad, 2.4Ghz, 3Gb Ram

Software: Eclipse IDE for Java EE 3.4 M5 Ganymede (Feb 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.5.0_11, WebLogic 10.0.1

This example will run fine with Eclipse 3.3 EE and any Database that EclipseLink supports.

Prerequisites

  • Install Eclipse EE
    • I installed a clean version of Eclipse Ganymede M5 with all of WTP 3.0
  • Install a Database
    • In this example I am using Oracle 11g, the table schemas have already been created manually and all entitity java classes have been generated using the Eclipse DALI tool.
  • Install BEA WebLogic Server Tools for Eclipse
    • Eclipse 3.3/3.4 EE does not come with the WebLogic server configurations, you must upgrade from the dev2dev site in order to pick up the 10.x server plugins.
    • Either add the 2.0.2 update site URL to your Eclipse 3.4 install, or download the zip file containing the features/plugins directories and overlay on your Eclipse install manually.
    • Alternatively, you may be able to use the "J2EE Preview at localhost" as the server config - however I will need to verify this.

WebLogic configuration Changes

JNDI Datasource Setup

  • Currently using non-JTA RESOURCE_LOCAL with jdbc parameters set in persistence.xml
  • JTA setup pending

EclipseLink JAR location

The eclipselink.jar should be placed off of $WEBLOGIC_HOME/samples/domains/wl_server/lib

JDBC JAR location

Copy your jdbc driver jar to $WEBLOGIC_HOME/samples/domains/wl_server/lib

Create server in Eclipse

Open the servers view New | Server | BEA | WebLogic 10.

Eclipse weblogic server screen2.jpg

Create J2EE application

Check out the 3 example projects in the trunk '(TBD) or create your own J2EE Enterprise Application as below. File | new | project | J2EE | Enterprise Application Project Select server, use 5.0 Ear version

Create a new Web and an optional EJB project

Select generate deployment descriptor if you want to change the context-root

  • Path changes
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.persistence.core"/>
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.persistence.jpa"/>
or
	<classpathentry combineaccessrules="false" kind="src" path="/eclipselink.jar"/>
  • After EAR project creation - reference the org.eclipse.peristence.core and jpa projects or include a reference to eclipselink.jar in your WAR project.
  • If you don't reference the eclipselink.* projects then include a classpath reference to persistence.jar and an Oracle (or other Database) JDBC driver jar for your DB - You will need to put this JDBC driver jar in your WebLogic /domains/wl_server/lib directory as well.


Persistence.xml

  • Put persistence.xml in yourProjectEJB/ejbModule/META-INF or...
<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="unifiedWebLogic" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <properties>
      <property name="eclipselink.target-server" value="WebLogic_10"/>
      <property name="eclipselink.logging.level" value="FINEST"/>
      <property name="eclipselink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
      <property name="eclipselink.jdbc.platform" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform"/>
      <property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:orcl"/>
      <property name="eclipselink.jdbc.user" value="user"/>
      <property name="eclipselink.jdbc.password" value="pw"/>
    </properties>
  </persistence-unit>
</persistence>

Deployment

Currently editing....

Perform a JPQL query

  • Browser Output

Eclipselink example jpa weblogic web jpql action cap.jpg

References

Back to the top