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

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

m (Purpose)
m
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
=EclipseLink JPA Deployed on Spring=
+
<!--=EclipseLink JPA Deployed on Spring=
 
<div style="border: 3px red solid;" align="center" ><font color="red">DISCLAIMER: This page reflects investigation into how EclipseLink users can use EclipseLink JPA and the Spring Framework inside existing WebLogic and Spring releases. It does NOT imply any formal certification from Oracle or SpringSource on any technical details or configuration within this document this time.</font></div>  
 
<div style="border: 3px red solid;" align="center" ><font color="red">DISCLAIMER: This page reflects investigation into how EclipseLink users can use EclipseLink JPA and the Spring Framework inside existing WebLogic and Spring releases. It does NOT imply any formal certification from Oracle or SpringSource on any technical details or configuration within this document this time.</font></div>  
  
Line 46: Line 46:
 
==Installation==
 
==Installation==
 
===WebLogic 10.3.3.0===
 
===WebLogic 10.3.3.0===
*In WebLogic 10.3.3.0 there exists 3 spring jars in the modules directory - these are internally wrapped API that support the 2.5.3 version of Spring as indicated.  We may upgrade these to work with Spring 3 as long as we do not encounter issues between 2.5.3 and 3.0 dependency injection.  The pitchfork jar is part of the Oracle open source project for metadata translation of [http://www.jcp.org/en/jsr/detail?id=250 JSR-250] annotations.
+
*Oracle WebLogic [http://www.oracle.com/technetwork/middleware/ias/downloads/fusion-certification-100350.html officially] supports Spring 2.5.x - we will be verifying this July 2008 statement in the ''[http://www.oracle.com/technetwork/middleware/ias/downloads/oracle-wls-certification-10gr3-matr-129284.xls System Requirements and Supported Platforms for Oracle WebLogic Server 10.3 spreadsheet - page 2]''.
 +
*In WebLogic 10.3.3.0 there exists 3 spring jars in the modules directory - these are internally wrapped API that support the 2.5.3 version of Spring as indicated.  We may upgrade these to work with Spring 3 as long as we do not encounter issues between 2.5.3 and 3.0 dependency injection.  The [http://www.springsource.com/products/pitchfork/pitchfork-faq pitchfork] jar is part of the combined '''Oracle''' and '''SpringSource''' open source project for metadata translation of [http://www.jcp.org/en/jsr/detail?id=250 JSR-250] annotations for both WebLogic ans Spring - started by Rod Johnson of Interface21 and Michael Chen of BEA under both the Apache and EPL licenses.
 +
*WebLogic has used Spring as its AOP (Aspect Oriented Programming) engine since June 2005 to provide support for DI (Dependency Injection) of resources and functionality in a '''Proxy''' implementation on the server that contains a reference to the actual business object (Bean or EJB).  The container uses Spring AOP to bytecode weave - at runtime - the proxy so that '''cross-cutting concerns''' can be architected properly.  By instrumenting a business object at runtime using [http://en.wikipedia.org/wiki/Aspect-oriented_programming AOP] we are able to provide dynamic functionality before and after a client operation in support of pre and post operations for transactions and security for example.
 
**<font color="red">[http://oss.oracle.com/projects/pitchfork/ com.bea.core.repackaged.springframework.pitchfork_1.3.0.0_2-0.jar]</font>
 
**<font color="red">[http://oss.oracle.com/projects/pitchfork/ com.bea.core.repackaged.springframework.pitchfork_1.3.0.0_2-0.jar]</font>
 
**<font color="green">com.bea.core.repackaged.springframework.spring_1.1.0.0_'''2-5-3'''.jar</font>
 
**<font color="green">com.bea.core.repackaged.springframework.spring_1.1.0.0_'''2-5-3'''.jar</font>
Line 84: Line 86:
 
         </init-param>
 
         </init-param>
 
     </servlet>
 
     </servlet>
    <!-- standard web.xml (non-Spring) - leave commented -->
 
    <!-- servlet>
 
      <description></description>
 
      <display-name>FrontController</display-name>
 
      <servlet-name>FrontController</servlet-name>
 
      <servlet-class>org.eclipse.persistence.example.jpa.spring.presentation.FrontController</servlet-class>
 
    </servlet-->
 
 
</source>
 
</source>
 +
*The reason that the '''org.springframework.web.servlet.DispatcherServlet''' class cannot be loaded by WebLogic is either that it is unavailable or that there is another version in the classpath (not likely or we would get a ClassCastException).
 +
*The '''DispatcherServlet''' is inside '''org.springframework.web.servlet-3.0.5.RELEASE.jar'''
 
*You therefore need to distribute the Spring jars or place them on the server as explained in the section
 
*You therefore need to distribute the Spring jars or place them on the server as explained in the section
 +
====Systematic Inclusion of Spring libraries in WebLogic====
 +
*The goal is to get the latest Spring 3.0.5 working with the latest WebLogic 10.3.3.0.  Hopefully we do not need to rever to using the supported Spring 3.5.3 or 3.5.6 versions.
 +
*The following ClassNotFoundExceptions are being eradicated one at a time usually be easily matching the class with the appropriate 1 of 20 Spring module.  It would be nice to use some sort of OSGI support for dynamic module loading - we are only using PDE at this point.
 +
**1) '''org.springframework.web.servlet.DispatcherServlet''' is in ''org.springframework.web.servlet-3.0.5.RELEASE.jar''
 +
**2) '''org.apache.commons.logging.Log''' is in ''commons-logging.jar''
 +
**3) '''org.springframework.web.util.UrlPathHelper''' is in ''org.springframework.web-3.0.5.RELEASE.jar''
 +
**4) '''org.springframework.context.ApplicationContext''' is in ''org.springframework.context-3.0.5.RELEASE.jar''
 +
**5) '''org.springframework.beans.factory.ListableBeanFactory''' is in ''org.springframework.beans-3.0.5.RELEASE.jar''
 +
**6) '''org.springframework.core.io.support.ResourcePatternResolver''' is in ''org.springframework.core-3.0.5.RELEASE.jar''
 +
*Alright, we are now deployed and at the point where we are looking for the persistence unit - which is not properly configured yet.
 +
<source lang="java">
 +
Caused By: java.lang.IllegalArgumentException: No persistence unit named 'spring' is available in scope springhypercube. Available persistence units: []
 +
at weblogic.deployment.ModulePersistenceUnitRegistry.getPersistenceUnit(ModulePersistenceUnitRegistry.java:132)
 +
at weblogic.deployment.BasePersistenceContextProxyImpl.<init>(BasePersistenceContextProxyImpl.java:39)
 +
</source>
 +
*We are currently running on a modified server (so we do not have to ship the Spring modules with the EAR/WAR) with the following change to '''$WLS_Server/wlserver_10.3/common/bin/commEnv.cml:151
 +
<source lang="java">
 +
set SPRING_CP=C:/opt/spring305/dist
 +
set WEBLOGIC_CLASSPATH=%SPRING_CP%/org.springframework.web.servlet-3.0.5.RELEASE.jar;C:/opt/spring3/commons-logging.jar;%SPRING_CP%/org.springframework.web-3.0.5.RELEASE.jar;%SPRING_CP%/org.springframework.context-3.0.5.RELEASE.jar;%SPRING_CP%/org.springframework.beans-3.0.5.RELEASE.jar;%SPRING_CP%/org.springframework.core-3.0.5.RELEASE.jar;%JAVA_HOME%\lib\tools.jar;%WL_HOME%\server\lib\weblogic_sp.jar;%WL_HOME%\server\lib\weblogic.jar;%FEATURES_DIR%\weblogic.server.modules_10.3.4.0.jar;%WL_HOME%\server\lib\webservices.jar;%ANT_HOME%/lib/ant-all.jar;%ANT_CONTRIB%/lib/ant-contrib.jar
 +
 +
</source>
  
 
===Spring 3 Download===
 
===Spring 3 Download===
Line 156: Line 174:
 
**SPRING_STRUTS=org.springframework.web.struts-3.0.5.RELEASE.jar
 
**SPRING_STRUTS=org.springframework.web.struts-3.0.5.RELEASE.jar
 
===Spring Integration with WebLogic===
 
===Spring Integration with WebLogic===
*There are several options for getting the Spring framework enabled for your Spring WAR in WebLogic Server.
 
  
====Option 1: Spring library jars copied to WebLogic modules directory====
+
*There are several options for getting the Spring framework enabled for your Spring WAR in WebLogic Server.  I have ordered them in decreasing impact on the WebLogic server config and increasing application managed state.
 +
====Option 1: <font color="green">'''Spring library jars highest in WEBLOGIC_CLASSPATH var in commEnv.cmd script'''</font> - in use====
 +
*This option will override anything on the server and deployed WAR's (except '''prefer-application-packages''' overrides).  It will deal with most classLoader and CNFE issues.  Later we may want to refactor how the Spring modules are packaged to minimize server impact.
 +
 
 +
====Option 2: Spring library jars in WebLogic modules directory====
 +
====Option 3: Spring library jars in WebLogic Domain lib directory====
 +
====Option 4: Spring library jars in shared separate EAR library====
 +
====Option 5: Spring library jars deployed with EAR APP-INF/lib directory using <font color="red">'''prefer-application-packages'''</font> override====
 +
====Option 6: Spring library jars deployed with WAR lib directory====
  
 
===Eclipse 3.6 Setup===
 
===Eclipse 3.6 Setup===
Line 205: Line 230:
 
*If you were using a Hibernate SessionFactory for ORM you could describe your entities in the '''AnnotationSessionFactoryBean''' bean element to match the '''class''' elements from persistence.xml - if auto-discovery was not enabled
 
*If you were using a Hibernate SessionFactory for ORM you could describe your entities in the '''AnnotationSessionFactoryBean''' bean element to match the '''class''' elements from persistence.xml - if auto-discovery was not enabled
  
*The
 
  
 
==Transaction Manager Configuration==
 
==Transaction Manager Configuration==
Line 223: Line 247:
  
  
 
'''Previous 2008 content - currently undergoing refactoring on 20101220'''
 
 
==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 1.0.2 Installer Zip''' link which resolves to http://www.eclipse.org/downloads/download.php?file=/rt/eclipselink/releases/1.0.2/eclipselink-1.0.2.zip
 
*Expand the zip file and get the following 2 files
 
**eclipselink-1.0.2\eclipselink\jlib\eclipselink.jar
 
**eclipselink-1.0.2\eclipselink\jlib\jpa\javax.persistence_1.0.0.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 - ''(I am running rev 2.0.0.20090218-SNAPSHOT)''
 
**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
 
 
 
http://www.springframework.org/download
 
http://sourceforge.net/project/downloading.php?group_id=73357&use_mirror=voxel&filename=spring-framework-2.5.5-with-dependencies.zip&50273885
 
 
==Eclipse Launch Targets==
 
<pre>
 
-javaagent:c:\opt\spring3\org.springframework.instrument-3.0.0.RELEASE.jar
 
</pre>
 
 
==Change Log==
 
==Change Log==
 
*20080922 - start tutorial template (no content)
 
*20080922 - start tutorial template (no content)
Line 254: Line 252:
  
 
==References==
 
==References==
 +
*[http://download.oracle.com/docs/cd/E12840_01/wls/docs103/programming/spring.html Oracle WebLogic Server - Spring Applications Reference]
 
*[http://oss.oracle.com/projects/pitchfork/ Oracle Pitchfork open source metadata translation project]
 
*[http://oss.oracle.com/projects/pitchfork/ Oracle Pitchfork open source metadata translation project]
 
*[http://download.oracle.com/docs/cd/E12839_01/web.1111/e14453/enable_spring.htm#CHDIIIGJ WebLogic support for Spring Dependency Injection]
 
*[http://download.oracle.com/docs/cd/E12839_01/web.1111/e14453/enable_spring.htm#CHDIIIGJ WebLogic support for Spring Dependency Injection]
Line 268: Line 267:
 
*Need to respond to...
 
*Need to respond to...
 
**http://old.nabble.com/Eclipselink-with-Spring-2.5.6-and-Weblogic-10.3-p24095716.html and http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg02836.html
 
**http://old.nabble.com/Eclipselink-with-Spring-2.5.6-and-Weblogic-10.3-p24095716.html and http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg02836.html
 +
-->

Latest revision as of 13:20, 25 December 2010

Back to the top