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

m (Persistence JAR location)
m (Replacing page with '[http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebSphere_Web_Tutorial Original WebSphere 7 tutorial page for EclipseLink JPA]')
 
(120 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=EclipseLink JPA Deployed on IBM WebSphere 7 using Eclipse WTP=
+
[http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebSphere_Web_Tutorial Original WebSphere 7 tutorial page for EclipseLink JPA]
* <font color="orange">This tutorial needs to be finished and/or expanded - as of 20100415 - I have approval to update this wiki via bug# bug# '''[http://bugs.eclipse.org/309201 309201]'''.</font>
+
 
+
<font color="red">Note: This tutorial' is under construction for the next week as of 200100415.</font>
+
 
+
If you want to get a small web application running quickly on WebSphere 7.0 you can use Eclipse to create the EAR and [[EclipseLink/Examples/JPA/WebSphere7_Web_Tutorial#Remote_Debugging_EclipseLink_in_WebSphere_7.0_from_Eclipse_3.4|attach to a running WebSphere instance in debug mode on port 7781]].
+
 
+
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 [http://www.ibm.com/developerworks/downloads/ws/was/?S_TACT=105AGX28&S_CMP=DLMAIN&S_CMP=rnav IBM WebSphere Application Server 7.0] 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 [http://wiki.eclipse.org/Dali DALI] project was used to generate Entities from a schema with sequences already populated.
+
 
+
==Development Environment==
+
'''Software:''' http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR2/eclipse-jee-galileo-SR2-win32.zip Eclipse IDE for Java EE 3.5 Galileo SR 2] (April 2010 +) IBM J9 JRE 1.6.0 build 2.4 20080816_22093.
+
 
+
==Prerequisites==
+
===<font color="green">Install Eclipse EE</font>===
+
*I installed a clean version of Eclipse Galileo 3.5 SR2 EE Edition (32-bit) (April 2010) on a Window 7 64-bit install where the default JRE was the 64-Bit server version of the SUN JVM.  I therefore needed to override the default ''java.exe'' by specifying the following shortcut override
+
<source lang="java">
+
C:\eclipse35-32bit-home\eclipse.exe -vm c:/jdk1.6.0_32-bit/bin/java.exe
+
</source>
+
*Default [[EclipseLink/Development/Testing/Prereq#Recommended_eclipse.ini_settings_for_EclipseLink|eclipse.ini]] settings must be modified as referenced.
+
 
+
===<font color="green">Install a Database</font>===
+
*We will be using a remote '''Oracle 11''' instance as well as a ''local'' '''[[EclipseLink/Examples/JPA/Derby|Derby 10.5.3.0]]''' instance.
+
 
+
===<font color="green">Install WebSphere 7.0</font>===
+
I installed the commercial '''7.0.0.0''' version of IBM WebSphere 7 and then the '''7.0.0.5''' '''fixpack in 7.0.0-WS-WAS-WinX32-FP0000005.pak''' using the ''7.0.0.5-WS-UPDI-WinIA32.zip'' installer.
+
 
+
===Install WebSphere Eclipse 3.4 Server Plugin - unusable===
+
We will first see if the WebSphere 6.0 or 6.1 plugin works with WebSphere 7.0 - it fails on missing jar files that are not present in 7.0.
+
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 for Eclipse WTP is currently being developed - see the following [http://bugs.eclipse.org/160220 Eclipse WTP enhancement request 160220 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 7781 of a running WebSphere server that was started in debug mode outside of the Eclipse IDE - we will use this alternate debug approach.
+
*<font color="red">If you try to stub out the 73 jars required by the WebSphere 6.0 plugin to make it work with a WebSphere 7.0 server - you will get the following exception '''starting''' WebSphere from Eclipse.</font>
+
<source lang="java">
+
com.ibm.ws.exception.ConfigurationError: java.lang.Exception: Cannot find BundleContext for service com.ibm.ws.runtime.config.ConfigServiceImpl
+
at com.ibm.ws.runtime.WsServerImpl.bootConfigService(WsServerImpl.java:335)
+
at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl.java:171)
+
</source>
+
 
+
==WebSphere Configuration Changes==
+
*WebSphere configuration modifications can be done on the admin console .
+
**http://localhost:9060/ibm/console/
+
**Which redirects to
+
***https://localhost:9043/ibm/console/login.do?action=secure
+
***or if a secure login was not selected
+
***http://localhost:9060/ibm/console/unsecureLogon.jsp
+
 
+
==JNDI Datasource Setup==
+
 
+
===Global Scoped Datasource Setup===
+
 
+
==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
+
 
+
==Persistence JAR location==
+
*Where does the standard library '''plugins/com.ibm.ws.jpa.jar''' fit in? Is this a JPA spec jar or an '''OpenJPA''' implementation?
+
 
+
==EclipseLink JAR location==
+
==JDBC JAR location==
+
==Create J2EE application==
+
==Persistence.xml==
+
==Publish EAR==
+
===Validating the WebSphere/EclipseLink configuration===
+
===Without eclipselink.jar reference===
+
===With eclipselink.jar reference===
+
==Perform CRUD operations: JPQL insert and query==
+
===Browser Output===
+
==Remote Debugging EclipseLink in WebSphere 7.0 from Eclipse 3.4==
+
The following procedure details how to attach to a debug version of IBM WebSphere 7.0 with the Eclipse 3.4 IDE.
+
 
+
Note: we will not be modifying startServer.bat.  The java process in that script is only for server startup - if you need to debug this part of the server.
+
===Modify console setup to start server in debug mode===
+
*Login to the console using your admin login or a default username like ''system''
+
**http://mobrien-pc2.st-mdc.ca.oracle.com:9064/ibm/console/login.do
+
*Navigate to Servers | Server Types | WebSphere Application servers | server1
+
*Navigate on the right down to Additional Properties | Debugging service
+
*Enable JDWP by ckecking the checkbox ''Enable service at server startup"
+
**The default properties below will be OK unmodified
+
***JVM debug port = 7781
+
***JVM debug arguments = -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7781
+
*Optionally you can add server packages if you have the source for WebSphere
+
*We will be debugging client test code and EclipseLink API in the Eclipse IDE
+
 
+
[[Image:Websphere7_console_debug_screen.JPG]]
+
 
+
===Start the WebSphere Server===
+
Either run bin/startServer.bat or the following server ant test target in our suite.
+
<pre>
+
<trunk>jpa\eclipselink.jpa.test>ant server-start
+
</pre>
+
 
+
===Attach Eclipse 3.4 to the debug port on WebSphere 7===
+
*Right-click your test code
+
*Debug as | Debug Configurations
+
*select Remote Java Application
+
*create a new config by hitting the top-left ''new launch configuration'' icon
+
*type a name for your config and modify only the port to read 7781
+
*''apply'' changes
+
*click debug
+
 
+
[[Image:Eclipse34_remote_debug_websphere7_screen.JPG]]
+
 
+
You should see the a stack trace ready for any breakpoints in your code that are hit - or suspend an orb thread to break into the code.
+
<pre>
+
</pre>
+
 
+
===Deploy and Run EAR application===
+
Depending on your breakpoints you will see a stacktrace hit in the Eclipse IDE similar to the following.
+
<pre>
+
VirtualAttributeTestSuite [Remote Java Application]
+
IBM J9 VM[localhost:7781]
+
Thread [P=833989:O=0:CT] (Running)
+
Daemon Thread [Signal Dispatcher] (Running)
+
...
+
Daemon Thread [Thread-52] (Running)
+
Daemon Thread [ORB.thread.pool : 0] (Running)
+
Daemon Thread [ORB.thread.pool : 1] (Suspended (breakpoint at line 302 in ConcurrencyManager))
+
ConcurrencyManager.isAcquired() line: 302
+
ClientSession(AbstractSession).isInTransaction() line: 2405
+
ClientSession(AbstractSession).beginTransaction() line: 538
+
SequencingManager$Preallocation_Transaction_NoAccessor_State.getNextValue(Sequence, AbstractSession) line: 455
+
SequencingManager.getNextValue(AbstractSession, Class) line: 905
+
ClientSessionSequencing.getNextValue(Class) line: 70
+
ObjectBuilder.assignSequenceNumber(Object, AbstractSession) line: 277
+
RepeatableWriteUnitOfWork(UnitOfWorkImpl).assignSequenceNumber(Object, ClassDescriptor) line: 402
+
RepeatableWriteUnitOfWork(UnitOfWorkImpl).registerNotRegisteredNewObjectForPersist(Object, ClassDescriptor) line: 3952
+
RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(Object, ClassDescriptor) line: 359
+
RepeatableWriteUnitOfWork(UnitOfWorkImpl).registerNewObjectForPersist(Object, Map) line: 3899
+
EntityManagerImpl.persist(Object) line: 254
+
JPATxEmInvocation(JPAExEmInvocation).persist(Object) line: 336
+
JPATxEntityManager(JPAEntityManager).persist(Object) line: 123
+
VirtualAttributeTestSuite.testInsertVirtualAttribute() line: 63
+
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
+
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 45
+
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 37
+
Method.invoke(Object, Object...) line: 599
+
VirtualAttributeTestSuite(TestCase).runTest() line: 154
+
VirtualAttributeTestSuite(TestCase).runBare() line: 127
+
VirtualAttributeTestSuite(JUnitTestCase).runBareServer() line: 391
+
TestRunnerBean.runTest(String, String, Properties) line: 87
+
EJSRemote0SLTestRunner_ed643271.runTest(String, String, Properties) line: not available
+
_EJSRemote0SLTestRunner_ed643271_Tie.runTest(InputStream, ResponseHandler) line: not available
+
_EJSRemote0SLTestRunner_ed643271_Tie._invoke(String, InputStream, ResponseHandler) line: not available
+
WSExtendedServerDelegate(ServerDelegate).dispatchInvokeHandler(InterceptorManager, ServerRequestInfoImpl, String, Object, ServerRequestReader) line: 622
+
WSExtendedServerDelegate(ServerDelegate).dispatch(ServerRequest) line: 475
+
ORB(ORB).process(ServerRequest) line: 504
+
ORB.process(ServerRequest) line: 1571
+
Connection.respondTo(RequestHandler, IIOPReader) line: 2771
+
Connection.doWork(RequestHandler, IIOPReader) line: 2640
+
WorkUnitImpl.doWork() line: 63
+
PooledThread.run() line: 118
+
ThreadPool$Worker.run() line: 1527
+
Daemon Thread [AIO Timer Thread 1] (Running)
+
Daemon Thread [WebContainer : 0] (Running)
+
...
+
        Daemon Thread [RT=7:P=833989:O=0:WSTCPTransportConnection[addr=10.156.52.98,port=1553,local=9104]] (Running)
+
</pre>
+
 
+
==References==
+
*See [[EclipseLink/UserGuide/Developing_JPA_Projects_%28ELUG%29|Developing JPA Projects]] in the EclipseLink User's Guide.
+
**http://www.ibm.com/developerworks/eclipse/downloads/ganymede/
+
*http://www.ibm.com/developerworks/eclipse/downloads/ganymede/dev.html
+
==History==
+
*20090115: Originated on build EclipseLink 1.1 M6 - Michael O'Brien
+
*20100415: Updating for eclipselink.jar placement for container managed and application managed scenarios in EclipseLink enhancement # [http://bugs.eclipse.org/309201 309201]
+

Latest revision as of 12:32, 5 October 2010

Original WebSphere 7 tutorial page for EclipseLink JPA

Back to the top