Wednesday, February 01, 2017

GridControl 12c switch repository database to RAC

This post may be useful if you consider scale out Oracle Enterprise Manager Cloud Control 12c with RAC database. Migration to the cluster is quite simple with rconfig utility. You can start with Oracle Database documentation or google for numerous posts about that process. I omit database migration by itself and describe the final steps only. In an ideal world, you always have a source instance and new shiny RAC, but in reality, you may not have enough resources and you have converted database in-place, as I've done?
Well, it means that you can't have both databases up and running at the same time. For my case original single instance repository has become a cluster node, which means OMS is down and emctl utility throws errors and doesn't change the configuration.Here you may find a few steps how to address this issue:
1. Open a new terminal connection and start AdminServer from the command line:
[oracle@host]$$MW_HOME/gc_inst/user_projects/domains/GCDomain/bin/startWebLogic.sh
It will throw a l-o-o-o-t of error messages about JPS database availability. Just keep it going until you 'd have your RUNNING state. Now you should be able to run $OMS_HOME/bin/emctl  normally nd update database connection descriptor using documentation steps. Just use another terminal window to keep AdminServer up and running.
2. OMS configuration doesn't understand format host:port:service, which means you have the only choice for cluster databases: SQL*Net service descriptors. Example for SCAN listeners would look like the sample command below:

[oracle@host]$ $OMS_HOME/bin/emctl config oms -store_rpos_details -repos_conndesc \
"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=scan-listener.your.domain.com)(PORT=1521)))(CONNECT_DATA=(SERVICE=omsservice.yourdomain.com)))"  -repos_user sysman

3. Service Descriptor is the standard SQL*Net format with some limitations (at least on Linux platforms):
  • The descriptor is enclosed in double quotes. 
  • Descriptor shouldn't contain any spaces. 
Return to the first session and stop AdminServer with Ctrl-Break. Now you can start Grid Control as usual, repository connection points to the clustered repository.

Tuesday, October 11, 2016

OTN Appreciation Day : The Great Resource to Appreciate.

For many years, Oracle Technology Network is the great source of technical knowledge, bright ideas and helpful tips from community members. I can't even remember when I've started to use it for the very first time, what I know for fact it was the last century.
To get an idea how different the internet we have in now days take a look  this screenshot from May 2000.


Many thanks to everyone who keeps this site up and running. You are doing a great job and people around the globe truly appreciate that.

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. 

Monday, August 03, 2015

W10. I'm all set

For the last few weeks my laptop has got more updates then  my LG G3.


Recently I've updated Virtual box to the new 5.0 release. I love VirtualBox. It's lightweight, cross-platform, easy to use and now (at least!) it supports USB 3.0.  Even better now you can run guest system in detached or background mode. It's not a killer feature, but if you have more than one system it's great relief (I know that VMware server does it for ages).


  Next, I've my system to Windows 10 . I could say only WOW, yep in capital. It's fast, sharp looking, and seamless. I've never ever had such system upgrade experience form Microsoft.Every single device were detected and installed properly. Every program was saved and ready for use. The only one exception - Skype, I have to get new version and install it, but I don't mind, because now I have one application.

The only cloud on my sunny sky: Pristine new VirtualBox had not detected any USB devices on my shiny Windows 10. I've went through all guest systems and reinstalled and updated addons. I've updated all guest system (I know it doesn't help with host, but it's a good reason) and changed USB configuration. I've reinstalled extension pack.
I've googled and binged around (Btw, new browser is amazing) with no luck.
Well,  if you can't find any meaning results but SMM posts and virus traps, it means - no one has this issue but you. I've checked Virtual Box service logs and found several entries like this one:

00:00:52.291557   WARNING [COM]: aRC=E_FAIL (0x80004005) aIID={afca788c-4477-787d-60b2-3fa70e56fbbc} aComponent={HostWrap} aText={Could not load the Host USB Proxy Service (VERR_FILE_NOT_FOUND). The service might not be installed on the host computer}, preserve=true  aResultDetail=1

Well I've checked vboxdrv service and it seems to be fine, but it's not. Long story short - I've uninstall extension pack and uninstall VirtualBox completely. Of course after fresh installation all my devices have returned from non existence.

I don't blame Microsoft or Oracle. they have done a great job -  It's a Windows baby.