Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Thursday, June 20, 2019

Moving to the new blog

I lover Blogger, cross my heart I do.  It's like good old shoes. It gives you much, you have an audience, statistics, even some marketing tools, and SSL. But one day you realize that all those facilities are restrictions. Very awkward WSWYG editor, strange templates (especially if you dealt with the new generations like Jinja or Handlebars), twisted integration support, no AMP.
And even worse, I don't feel that Google really cares about Blogger. They just have forgotten about it, and one day when they remember it would be gone as it's sibling Google Reader.

Well, my friend and I have started the new standalone site. The theme is the same - all around IT, with the bias toward the Oracle. Due extremely high loads on main projects posts will be rather irregular,  But the good news there are two authors, so at least you could expect a bit more.

My first piece on the new platform Oracle 18c XE on Linux Mint

Sunday, November 19, 2017

Git clones git


Good morning folks,
And I hope that your morning as beautiful as mine, down there in Naples, Florida. I have found a plausible excuse to skip landscaping: share mine small findings with you.

I'm playing with the Bamboo server for another good story or rather few stories (main characters: SOA 12c, Bamboo, Maven, and Ant) and the very first built has failed with the error:

simple 18-Nov-2017 16:38:24 error: unknown switch 'c'
simple 18-Nov-2017 16:38:24 usage: git clone [options] [--] <repo> [<dir>]
simple 18-Nov-2017 16:38:24 
simple 18-Nov-2017 16:38:24     -v, --verbose         be more verbose
simple 18-Nov-2017 16:38:24     -q, --quiet           be more quiet
simple 18-Nov-2017 16:38:24     --progress            force progress reporting
simple 18-Nov-2017 16:38:24     -n, --no-checkout     don't create a checkout
simple 18-Nov-2017 16:38:24     --bare                create a bare repository
simple 18-Nov-2017 16:38:24     --mirror              create a mirror repository (implies bare)
simple 18-Nov-2017 16:38:24     -l, --local           to clone from a local repository
simple 18-Nov-2017 16:38:24     --no-hardlinks        don't use local hardlinks, always copy
simple 18-Nov-2017 16:38:24     -s, --shared          setup as shared repository
simple 18-Nov-2017 16:38:24     --recursive           initialize submodules in the clone
simple 18-Nov-2017 16:38:24     --template <path>     path the template repository
simple 18-Nov-2017 16:38:24     --reference <repo>    reference repository
simple 18-Nov-2017 16:38:24     -o, --origin <branch>
simple 18-Nov-2017 16:38:24                           use <branch> instead of 'origin' to track upstream
simple 18-Nov-2017 16:38:24     -b, --branch <branch>
simple 18-Nov-2017 16:38:24                           checkout <branch> instead of the remote's HEAD
simple 18-Nov-2017 16:38:24     -u, --upload-pack <path>
simple 18-Nov-2017 16:38:24                           path to git-upload-pack on the remote
simple 18-Nov-2017 16:38:24     --depth <depth>       create a shallow clone of that depth
simple 18-Nov-2017 16:38:24 
error 18-Nov-2017 16:38:24 Checkout to revision 1d00aad94cb91435c7099197965c3ef52828e80d has failed.

Obviously, Bamboo is not happy with the installed git command. So my the first thought was:

Tuesday, September 26, 2017

SOA is so Groovy

Recently, I have tested and debugged Web Service and to automate test & compare cases I've used good ol' Groovy script activity in the SoapUI TestCase. Coincidentally, I've worked on the PoC where SOA Suite standard features don't fit well project terms. Can't say I've dreamed it, rather napped after a lunch break: "What if I can melt SOA and Groovy? There is a lang:groovy element available in the SpringBean activity descriptor". Follow me and I show you how to deliver the modern functional language to your SOA composites.

Wednesday, August 16, 2017

Github: unexpected news


It's a great day for me. It's turned out that someone uses my Github repositories.
While ago I've created an Oracle-free version of FOP servlet for Apex application reports. The reason why I've created the code was simple. Naturally, I've blogged all the details and it's one of the most visited publications of mine. At the same time, servlet repository has not been used at all or I used to think so. Now I know that at least one more person, who has found this project useful. Please meet Roger Pilkey, who is so kind that he has adopted my doodles and developed new servlet for the latest Apache FOP version.
After such unexpectable and invaluable input, I have to upgrade project itself.  The major changes are:
  • Project structure has been reconfigured to use with the Apache Maven 
  • JSP page uses the latest FOP code to generate PDF response
  • Lifted index.html (with a brief description and sample form to test application)
  • Updated README.md with some project information. 
I guess it's hard to find the Apex installation with no Oracle REST Database Services installed, but if you are the happy owner of such system - you may find it useful. 

Friday, July 07, 2017

XSLT. Apples and Oranges.


Believe me or not, I'm not going to compare XSL processors or whining about poor support for XSLT 2.0. Recently I have faced the situation,  where I should merge two property lists and produce combined result. Let's do some shopping and play with the grocery lists. The reasons why I'm writing this post are:

  • SOA 11g/12c supports XSLT 2.0 transformations and you can use all the power of it. 
  • XSLT Mapper is far behind the processor and may eve lie to you with the error messages. 
The example below is a little trinket, but it may save you hours on developing external services for the data transformation. 

Tuesday, July 04, 2017

Apache Maven and SOA 11g. Enable the composite.


Okay everyone, holidays are over and it's time to complete this super long read. If you haven't seen 3 previous posts you may go and check the first one here. Today we will discuss how to enable Maven for the SOA projects. Bad thing - it has a proprietary compiler and there is no Maven plugin at all, good thing the compiler uses Ant tasks to build and deploy Oracle SOA 11g composites. Now we have a plan and our project model should be able to:
  • Compile Java code and package it along with the SOA artifacts. The reason is your composite may use custom Java classes to perform some activities that hard or impossible to implement with the XPath/XQuery/XSLT tools you have. 
  • Test Java code, before build or install, especially if you use JUnit to cover your code. 
  • Build SCA archive with the proper Ant task 
  • Deploy composite archive to the SOA servers.
Rephrasing those steps in the project configuration terms we will talk about:
  • Additional properties for the SOA-specific tasks. 
  • Configure Java compiler and package plugin
  • Configure Ant plugin for Maven 

Sunday, February 14, 2016

APEX 5.0 and Apache FOP.

Couple days ago I've run into curious issue, how to print Classic report from Apex 5 application.
I have no ORDS 3. on my humble Fedora VM, and I not realy want to install it. Oracle BI Publisher ain't option  (unless you run corporate reports on OBIEE 11g/12c).  Well Apex has the 3rd option - External - with  Apache FOP.

Yeah, right! It has to be a servlet in your apex/utilities/fop folder. OOps, it used to be there.
Well, not a big deal, anyway it is a single JSP application with Apache FOP libraries and one big issue - it works out of the box only on Oracle Application servers, for all other cases you should get somewhere Oracle XML Parser libraries (for example - download XDK). processors. Out of this great discussion you may find whole source of fop.war servlet.
Okay then, we will create our own servlet with blackjack & ..., oops with FOP and standard Java XML parser.
what APEX expects from our application. It sends two parameters:

  1. xml   - document with report data
  2. template -  XSLT stylesheet to process data
Application should respond back with PDF document.


 To accomplish this simple task you  need:
  • Apache FOP runtime libraries.
  • Some application server to run our JSP application. (Let's stick with Apache and get a Tomcat)
  • JSP to get parameters from APEX and generate PDF page.

Let's chase to the source.

<%@ page import='org.w3c.dom.Document' %>
<%@ page import='java.io.*' %>
<%@ page import='org.xml.sax.InputSource' %>
<%@ page import='javax.xml.transform.stream.StreamSource' %>
<%@ page import='javax.xml.transform.stream.StreamResult' %>
<%@ page import='javax.xml.parsers.DocumentBuilderFactory' %>
<%@ page import='javax.xml.parsers.DocumentBuilder' %>
<%@ page import='javax.xml.transform.TransformerFactory' %>
<%@ page import='javax.xml.transform.Transformer' %>
<%@ page import='javax.xml.transform.dom.DOMSource' %>
<%@ page import='org.apache.fop.apps.Driver' %>

<%
//Set response type to PDF
response.setContentType("application/pdf");
// Prepare XML document 
    DocumentBuilder db = DocumentBuilderFactory.
                              newInstance().newDocumentBuilder();
// Parse parameter xml
    Document v_xml = db.parse(new InputSource(
                                new java.io.StringReader(
                                        request.getParameter("xml")
                      )));

// Create XSLT processor with instructions from template parameter
    Transformer v_xsl  = TransformerFactory.newInstance().newTransformer(
                                new StreamSource( 
                                        new java.io.StringReader(
                                                request.getParameter("template"))
                         ));
// Prepare output Stream
  ByteArrayOutputStream v_out = new ByteArrayOutputStream();
// Transform data into XSL-FO document 
  v_xsl.transform(new DOMSource(v_xml),new StreamResult(v_out));
  String v_fop = new String(v_out.toByteArray(),"UTF-8");
// Initialize FO driver
  Driver drv = new Driver();
  drv.setRenderer(Driver.RENDER_PDF);
// Prepare  output for PDF document 
   v_out = new ByteArrayOutputStream();
  drv.setOutputStream(v_out);
// Set Input source for FO driver
  drv.setInputSource(new InputSource(new StringReader(v_fop)));
// Produce document
  drv.run();

// Returnresult for client  
// Fix to avoid Tomcat/JBoss double open exception
  OutputStream outStream = response.getOutputStream();
  response.setContentLength(v_out.size());
  outStream.write(v_out.toByteArray());
  outStream.flush();
  
%>



Now make sure, that your WEB-INF/lib folder contains libraries to run FOP driver.  I've found old distribution with few libraries. that is how it looks like in my NetBeans Libraries list.

Well, that's all folks. If you use NetBeans or just have got my war archive - time to have fun.
Copy archive to your Tomcat webapps folder and try to open /fop page. 
You should see this some ugly page as on picture below. This means your application is up and running and click on "test servlet" URL will show you generated PDF document.

I don't see how you may run into issues with that, on my Tomcat 7/JDK 1.7 it runs out of the box.
Now you are ready to change Apex print configuration.
Set Report printing properties as below.
Print Server:External (Apache FOP)
Print Server Protocol:HTTP
Print Server Host Address:FQDN of your Tomcat server
Print Server Port:Your Tomcat listen port (8080 by default)
Print Server Script:/fop/pdf_print.jsp
It's time to run "real-life" example. I have a tiny application with standard report page and to print reports you should enable printing. It's quite easy for primitive examples like mine. Go to report region and open Print Attributes tab and dig into Printing  section (I left report customization for you, you've seen my index page design, right ).  What I used to set for report:
Enable Report PrintingYes
Link LabelGet PDF
I't just a name, put anything you like
Response HeaderReport Settings
View File AsInline
Personally I prefer to open PDF in browser, you may pick attachment and download report as PDF file.
Output formatPDF
NO reason to select anything else. It is a PDF generator isn't it?
If you know meaning of the other parameters you can change them. I left rest of the items intact. Save region settings and run your report page. You will see your Link label next to Download and if you click on it - you will get your PDF printer like I've got mine.


Here is web application to save your time and there is a GIT source code and libraries.

Enjoy and take care.