Archive for the Samples & How-Tos Category

New Continuous Integration tutorial published

No Gravatar

Hot off the press – a new continuous integration tutorial. It’s really not just about continuous integration, though! You’ll find it useful even if you aren’t using a continuous integration server like Hudson. It’s useful if you are doing any part of the scenario it documents: Setting up Team Productivity Center for your team and tasks, checking in source code changes to Subversion while referencing TPC tasks, building JUnit test cases for ADF BC view objects (in a different project than the components themselves), running JUnit tests from Ant tasks (including utilizing the database connection defined in the AM via Ant), setting up a Hudson job to check out from subversion and run the tests automatically, and reporting the build results back to TPC and JDeveloper using the TPC plug-in for Hudson and the Hudson plug-in for TPC. All this and many other pearls of wisdom for testing ADF applications is available here:
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_98/jdtut_11r2_98_1.html

Even if you don’t make it all the way through to the end, or if you are only using certain parts of the tutorial, let us know if it was useful to you by visiting the last page of the tutorial where we have a small feedback form. We do really read those comments!

Fun with Hudson, Part 1.1

No Gravatar

Earlier I posted that I had used the following zip command in the ‘execute shell’ action for my Hudson build job:

zip -r $WORKSPACE/builds/$JOB_NAME-$BUILD_NUMBER * -x ‘*/.svn/*’ -x ‘*builds/*’

This zips up the content of the exported source, so that I can send it on to team members who need the source of each build but aren’t authorized for the source control system.

That has been working splendidly except that I have some resource issues on the server I’m using for these builds, so I’m occasionally running out of space. I really only need to keep the latest successful build’s zip file, so after a bit of trial and error, I came up with this script for finding older builds and deleting them:

oldbuild=$(($BUILD_NUMBER – 3))
find . -type f -name “*-$oldbuild.zip” -exec rm -f {} \;

This is using the $BUILD_NUMBER built-in environment variable from Hudson to set a variable named oldbuild to a zip from 3 builds ago, and then finding that file (since I had named the file $JOB_NAME-$BUILD_NUMBER in the zip command) and removing it.

So now Hudson is creating the builds and cleaning up after itself! Hmmm, if only I could get the kitchen to do that for dinner.

New ADF Insider on Layouts

No Gravatar

I’ve published an ADF Insider session that helps de-mystify the ADF Faces components and how to work with them (and not against them), when building ADF applications. There’s also some great information on building ADF prototypes. Take a look here:

http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/layouts/layouts.html

Fun with Hudson, Part 1

No Gravatar

I’m building a set of samples for our next release of JDeveloper, and in doing so, I found the need for Hudson. Which is good, because after my preparations to present on Hudson at Rocky Mountain Oracle User Group, I’ve become a Hudson addict and am dreaming up all kinds of ways it can improve my life! Really, though, I think Hudson is a pretty cool tool to automate all the tasks that need to happen after a developer checks in a bit of code.

A common use case for Hudson is to checkout a project from subversion (or other repository) and then for ADF applications, use the ojdeploy executable to create a JAR, WAR, or EAR of the project. This is useful for cases where the output of one development team is the EAR file, or if you want to hook in auto deployment and always have a deployed version of the application running.

However, my requirement is that the exported source of the application is the build artifact, not an EAR file. I need to give our documentation writers the source (preferably zipped up) for each new build of the application so that they can see the design-time changes that were made to implement whatever feature I’m demonstrating in the sample. I haven’t given our documentation writers access to our subversion server, so they can’t pull the source from there. They want a zipped workspace that they can download, extract, and start working with right away.

It took a little trial and error, but here’s what I came up with: A build task in Hudson that issues the zip command, ignoring ‘.svn’ and ‘builds’ directories:

zip -r $WORKSPACE/builds/$BUILD_TAG * -x ‘*/.svn/*’ -x ‘*builds/*’

This command zips the current workspace directory * (which on my Hudson slave is something like /home/lmunsing/.hudson/jobs/Summit_ADF/workspace), ignoring all the .svn directories which exist at each level, and ignoring the builds directory that I manually created in the workspace directory to hold the zip files. This means I’m getting a zip that doesn’t contain the .svn directories or their contents, and that doesn’t contain the previous build zips. I tried using the tar command, but that gave me really crazy output in the Hudson console, so I went back to zip. I also tried combining the two exclusions according to the doc by space-separating them, but that just didn’t work. I’d end up with zip that included all the previous build’s zips. I also tried doing an svn export, but of course running that from the shell doesn’t pick up the account privileges that are configured in Hudson, and I didn’t want to include the username and password on the command line. I also used the $BUILD_TAG environment variable to name the zip file.

Here’s what the command looks like in the job console (for the 26th build):

zip -r /home/lmunsing/.hudson/jobs/Summit_ADF/workspace/builds/hudson-Summit_ADF-26 builds Model src SummitADF.jws Summit_Extensions ViewController -x ‘*/.svn/*’ -x ‘*builds/*’

This took enough trial and error to get right and google wasn’t giving me help with this exact sweet spot of “.svn directories exclude hudson zip”, so hopefully this helps someone.

Now I need to modify the automated build email to alert the doc writers when a new build has been created and point them to:

http://host:port/hudson/job/Summit_ADF/ws/builds/

I’ll be using the Hudson Email Extension plug-in for that.

The next stage will be to call this shell script only if the application builds, then only if it builds and some JUnit tests (sanity tests) are successful. For that I’ll use the Hudson Parameterized Trigger plug-in. And of course report all this back to developers using the Team Productivity Center. Such fun!

New to ADF? What you need to know…

No Gravatar

If you are evaluating ADF for your organization, or if you are just getting started with ADF, you’ll appreciate this video I’ve published that guides you through all the content on the subject – books, blogs, ADF courses, and papers and tutorials and recordings on OTN. There is a lot of material available and I’ve found myself doing this for developers and managers that are trying to find their way around all the material on OTN. Now I’ve recorded a video that shows you what you should do first and what you can save for later. Happy Viewing!
ADF Collateral Tour

http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/ADFTour/ADFTour.html

Update: I’ve created a tinyurl to make this even easier to find: http://tinyurl.com/learnadf

Deploying a simple ADF App to a remote WLS server

No Gravatar

This article is a follow-up to 2 previous postings:
Understanding available WebLogic Server downloads for ADF Applications
and
Extending WebLogic Server for ADF Applications
and assumes you have followed the steps in both.
This means that you have JDeveloper installed on your local machine, that you have a WebLogic Server installed on a remote machine, and you’ve extended the WLS server with the required JRF template for ADF applications, and that you’ve started the WLS server with -Djps.app.credential.overwrite.allowed=true so that database credentials will be uploaded to the server when an application is deployed. If you haven’t done these steps, go back through the previous two posts and follow those instructions.

If you’re still with me, now you’re ready to deploy a simple ADF application to the server to validate that it’s ready for real ADF applications.

The easiest way to develop a simple ADF application (if you don’t already have one on hand) is to follow the cue cards.

  1. From your development machine, open JDeveloper and choose Help > Cue Cards and select the Build a Fusion Web Application cue card:
  2. cuecard

  3. The first step of the cue card is to install the schema. The example uses a hostname of localhost, meaning that the sample schema is installed on a local database. If you’re going to be deploying to a remote machine with WLS installed, then the schema will need to be installed somewhere where the remote machine can connect to, such as your team’s shared database. Keep that in mind through the first step and then follow through all the steps in Part 1 and Part 2 of the cue card to create the example. You’ll end up with an application with ADF business components, an ADF task flow, and two ADF Faces views:

    Task Flow for sample application

    If you want to cheat a bit, you can download the application completed through parts 1 and 2 of the cue card here.

  4. The last step of Part 2 of the cue card is to run the application locally. This is a step that you should always perform on any application before you deploy it, to ensure that it runs properly and does what you expect. This is the primary reason that WLS is embedded in JDeveloper; you can test incremental changes in an application without having to redeploy the application. Make sure that you perform this step. For the example application, you should see the following when running locally:

    runtime view of example ADF app

  5. Once the application runs successfully locally, create a connection in JDeveloper to your shared WLS server. Open the Resource Palette, right click Application Server, and choose New Application Server connection:

    resource palette

  6. Specify a name for the connection, such as SharedDevServer, and leave the default WebLogic 10.3 specified as the connection type:

    name the connection
    Click Next

  7. Specify the username and password you created when installing WebLogic Server, such as weblogic and welcome1:

    enter WLS username and password

    The security people will be after me if I don’t mention here that you should not actually use the default password, but this is the password that the JDeveloper-embedded version of WebLogic Server uses, so there you go. Click Next.

  8. Enter the hostname where you have installed WebLogic Server, and the port you installed to (7001 by default). Additionally, enter the domain that you extended with JRF. If you did not create a new domain, this might be “AdminServer”, but that’s actually not recommended because the AdminServer domain has enough tasks to do without hosting your applications. If that’s the case for you, you might want to go back to step 11 of the appendix in Steve Muench’s article and create a new domain and then extend that domain with the JRF files. In my previous post, I extended the my_domain domain and so that’s the domain I specify here:

    enter configuration details

  9. Finally, test the connection. A crucial step. Ensure that all tests complete successfully:

    test connection

  10. At this point, there’s a few things to do to make life easier for this test deployment. The first thing to ensure is that when deployed to a remote machine, that machine has access to the data source connection that the application uses. You could do this by creating a global data source in WLS and then configuring your domain to use that connection. However, we’re just testing here, so in the case that your application was built using a data source based on your local machine’s database (and presuming that the machine that you’re deploying to doesn’t also have a database running at localhost), change the database connection that the application uses to a remotely-accessible database where you have installed the FOD schema (see step two above). To do this, expand Application Resources beneath your Projects listing in the Application Navigator. Expand Connections, Database, and then right click FOD and choose Properties:

    database properties

  11. Change the connection details to point to your remotely-accessible database:

    database details

  12. The next thing that makes life easier for this test deployment is to limit the amount of typing that you have to do to access the application remotely. Some history: JDeveloper uses the name of your application, the name of your project, and then “context-root” for the root url of your web application (BrowseEditApp-ViewController-context-root, for example). It does this because it can then ensure that the url to any application that you run in the embedded server in JDeveloper is unique. However, when you run a web application in JDeveloper, the browser is automatically launched for you and you don’t have to type a url. This is fine for testing locally, but you can make things easier for deployment by changing the default url to something more manageable. To do this, double click on your web application project (ViewController) to bring up the project properties. Click the Deployment node and select the Deployment Profile:

    project properties

    You might have noticed that you didn’t have to explicitly create deployment profiles for your application (.EAR), data model (.JAR) or web applications (.WAR) – JDeveloper creates them for you and you only need to modify them if you have specific deployment configurations to consider. Click Edit to edit the automatically generated WAR deployment profile.

  13. On the General page of the WAR deployment profile dialog, select Specify Java EE web context root and enter a more user-friendly name, such as BrowseEditApp:

    specify context root

  14. You’re now ready to deploy. You will be deploying the default EAR file profile, which is stored at the application level, and includes the WAR profile that you just modified as well as the JAR file that was automatically defined for the ADF Business Components Model project. Click the dropdown next to your application name, and choose Deploy. A series of context menus will appear as you select the name of your application’s EAR deployment profile (BrowseEditApp_application1 by default), to, and then the name of your shared server that you defined in step 5 above:

    deploy to shared server
    The deployment log will appear in JDeveloper, and you should see a successful deployment like the following:

    deployment success

    If you see errors instead, check that you’ve followed the post for extending your domain.

  15. Now you can access your application from a browser. The url will be the hostname of your server, the port (default 7001), followed by the context root of your web application, followed by the servlet url “faces” because this is a JSF application, followed by the name of your starting .jspx page. In this example application, you don’t have a starting .jspx page because your starting point is actually an ADF task flow and a slew of parameters are required to load the task flow properly (in most applications, you’d have a starting index.jspx that redirects to your initial task flow’s url for convenience). So in this test, copy the Target URL from the log that was created when you test-ran the application locally in step 3 above. The tab for this log is called Running: DefaultServer. Click that tab and then select the entire contents of the Target URL:

    target url

    Right click and choose Copy, then paste that into a browser. Replace the local ip address with the hostname for your shared server, replace the 7101 embedded WLS Server port with the default standalone port of 7001, and finally replace the longer default context root with the one that you defined for this application. Leave all the remaining parameters as-is. The resulting url will be something like the following:

    http://sharedserver.mycompany.com:7001/BrowseEditApp/faces/adf.task-flow?adf.tfId=orders-flow&adf.tfDoc=/WEB-INF/orders-flow.xml

  16. Click enter to launch the application (you’ll see a spinning “O” first to let you know the application is loading). The result is your test application, deployed to a remote, standalone, JRF-extended WebLogic Server:

    deployed application

  17. Voila!

Extending WebLogic Server for ADF Applications

No Gravatar

This post serves as a step by step guide to extending a generic WebLogic Server domain on Linux using the Application Development Runtime package available on OTN. The Application Development Runtime package includes the Java Required Files (JRF) which include the ADF runtime libraries necessary to deploy ADF applications on WLS. In case you’re wondering, these libraries are already included for the default domain that’s installed with JDeveloper, so that’s why no domain extension is necessary when you’re running an application directly from JDeveloper. However, if you’ve deployed an ADF application to your domain and are getting errors like “Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: adf.oracle.domain, Implementation-Version: 11.1.1.1.0, exact-match: false], [Extension-Name: oracle.jsp.next, exact-match: false]“, then your domain doesn’t include the JRF extension and you’ll need to follow these steps.

1. From the Fusion Middleware Download page:
jdev_1.jpg

2. Scroll down to Application Development Runtime and click Disk1 to download.

3. Save the zip file to disk.

4. Open the zip once it has downloaded successfully and extract the files.

5. cd to the location of the files and run the installer:

jdev_10.jpg

6. If the installer prompts for a JDK, enter the one in the your Fusion Middleware home directory:

jdev_11.jpg

7. When the installer launches, select a directory for the inventory of the install:

jdev_12.jpg

8. If the installer was not run as root, the installer will prompt for the createCentralInventory.sh to be run before the install proceeds:

jdev_13.jpg

9. Run the script as directed:

jdev_14.jpg

The script should execute successfully.

10. Click OK in the installer dialog to continue the installation:

jdev_16.jpg

11. Click Next on the welcome page of the installer.

12. Click Next once the requirements are verified:

jdev_18.jpg

13. Specify the Oracle Fusion Middleware Home directory (where you have installed WLS 10.3) and click Next:
jdev_19.jpg

14. Click Install to start the installation:
jdev_20.jpg

15. Click Finish when the install is complete.

16. From the quick start dialog, launch the configuration wizard:
jdev_22.jpg

17. In the configuration wizard, select Extend an existing WebLogic domain and click Next:
jdev_23.jpg

18. Select the domain that you previously created and click Next:
jdev_24.jpg

19. Select Oracle JRF – 11.1.1.0 [Oracle_APPDEV1] as the extension source and click Next:

jdev_25.jpg

20. Click Next to skip the Optional configurations steps:

jdev_26.jpg

21. Click Extend to extend the domain:

jdev_27.jpg

22. Click Done to exit the configuration wizard once the extension is applied successfully.

23. Finally, to ensure that the credentials that you supply in the database connections for your ADF Application are deployed and include the password, add -Djps.app.credential.overwrite.allowed=true to the JAVA_PROPERTIES entry in the FMW_HOME/user_projects/domains/yourdomain/bin/setDomainEnv.sh file (or setDomainEnv.cmd if you are on Windows), and restart the server using FMW_HOME/user_projects/domains/yourdomain/bin/startWebLogic.sh. This is what you need to do if you have deployed an ADF application to your server but are seeing the following errors when the application is accessed:

oracle.jbo.DMLException: JBO-26061: Error while opening JDBC connection.
at oracle.jbo.server.ConnectionPool.createConnection(ConnectionPool.java:253)
at oracle.jbo.server.ConnectionPool.instantiateResource(ConnectionPool.java:168)
at oracle.jbo.pool.ResourcePool.createResource(ResourcePool.java:546)
at oracle.jbo.pool.ResourcePool.useResource(ResourcePool.java:327)
at oracle.jbo.server.ConnectionPool.getConnectionInternal(ConnectionPool.java:104)
Truncated. see log file for complete stacktrace
java.sql.SQLException: ORA-01005: null password given; logon denied

Congratulations! Your WLS domain is now ready to host ADF applications.

Understanding Database Connections in JDeveloper 11 Technology Preview

No Gravatar

I’ve written a little how-to for understanding how database connections work in JDeveloper 11 technology preview – we’ve beefed up the reusability and automation of database connections for 11, but that’s caused some confusion because its different from how things were done in 10.1.3.x. We’re still making improvements for JDeveloper 11, but for now, the following document should help with the technology preview release that’s out on OTN.

Understanding Database Connections in JDeveloper 11 Technology Preview