venerdì 27 novembre 2015

How to restart Weblogic Admin Server in Oracle Java Cloud Service

If you need to restart the Weblogic Admin Server in Oracle Java Cloud Service you can do this in different ways:

--[1]--

The simplest and fastest way is:

with Putty access to your JCS in SSH.
[How to access in SSH to Oracle Cloud using Putty and ppk key]

In the next image you can find all the commands and where to go to restart the Admin Server:

- The path of the domains are always the same : /u01/data/domains
- To access to /u01 remember to execute "sudo su"
- To start the AdminServer you MUST use the startJCSServer.sh under <your_domain>/bin

Use the command:
nohup ./startJCSServer.sh  -Dweblogic.Name=<your WLS Admin server name> &



If you have for example killed all the java processes (NodeManager, Admin and Managed servers), the correct sequence to restart all is:
- go in your <your WLS domain>/bin directory
- Restart the Admin server with startJCSserver.sh
- Restart the NodeManager with startNodeManager.sh, this will automatically restart your managed servers

--[2]--

You can restart everything from your JCS console:


This will restart, Admin Server, Managed Servers and Load Balancer.

--[3]--

You can also use REST APIs:
https://docs.oracle.com/cloud/latest/jcs_gs/JSRMR/index.html

Look this example with curl:
https://docs.oracle.com/cloud/latest/jcs_gs/JSRMR/Use%20cURL.html


sabato 14 novembre 2015

How to call a Rest Service on ICS (Integration Cloud Service) from JCS (Java Cloud Service)

This is a sample of URL of a service created on ICS:

https://icsemeapmtrial-icsemeapmtrialidm.integration.us2.oraclecloud.com/integration/flowapi/rest/RN_INCIDENT_DETAILS/v01/incident?orgID=35

It is a service on ICS that makes a call to RightNow. (we are requesting the INCIDENT with ID = 35)
This service requires HTTPS and Basic Authentication.

To be able to call a Rest Service on ICS from JCS, you can create on JCS, for example, a simple jsp page in which you can use JQuery.

But in this scenario you will have CORS problems.

To solve in a simple way CORS problems you can use this Proxy Servlet (CORS) : this is a war archive with .class & .java file.

If you whant you can deploy the ProxyServlet in the same WLS where is starting the request to ICS or in a different WLS.

This proxy is useful also on premise.
If you deploy it in your local computer you will have this exception during a call:

javax.net.ssl.SSLKeyException: Hostname verification failed: HostnameVerifier=weblogic.security.utils.SSLWLSHostnameVerifier, hostname=icsemeapmtrial-icsemeapmt rialidm.integration.us2.oraclecloud.com.

As workaround, you can solve it on WLS  turning off hostname verification.
In the admin console: Servers -> server name -> Configuration SSL tab -> Advanced -> Change Hostname Verification dropdown to None

The only thing that you need to do is to deploy and activate it on WLS and if you need an example on how to call it see the following JSP: IcsRightNow.jsp ( for this sample remember to put jquery lib in the same directory of the jsp)

In the following image you can see the structure of the project that I have created on a previous tutorial, and you can see where to put JQuery lib and jsp file:



To deploy the Proxy Servlet (CORS) on WLS on JCS is very simple, once you have downloaded it on your computer:

Open your Weblogic Console on JCS, click on "Lock & Edit", then select "Deployments" and then click on "Install" button, now you can upload your war on JCS:


Remember to choose a correct Target (all the cluster maybe is the best choice) for the deployment, remember at the end of the operations to click on "Activate Changes" and then to "Start" the application:






venerdì 13 novembre 2015

How to create an Oracle Database Service on Oracle Database Cloud Service

With the following images, you can see how is simple the process of creation of a new database service.

Login on your Oracle Database Cloud Service account, then click on "Create Service"


A simple web wizard will appear, in the first task you must choose a "Service Level" and a "Billing Frequency", Oracle Database Cloud Service is the most complete of functionalities:
Click next:


Now you can choose the version of the product:
Click next:


Now you can choose the software edition:
Click next:


Here you can choose user, password and how mani cpu and ram allocate for your service:
Click next:


Remember to put a pub key for ssh communication:
[Oracle Cloud & SSH: How to generate private and public keys (pub & ppk)]
Click next:


I have decided "None" in the Backup Destination field, because is a simple test environment:
If you Select a Backup Destination, you need a Storage Container.
Click next:


You can see a summary of your choices and you can proceed with the creation :
Click Create:


giovedì 12 novembre 2015

Java Cloud Service: How to enable and use RESTful Management Services on WebLogic Server and how to read logs file

Access to your JCS and open the Weblogic Console :


Login in WebLogic console:



Click on your domain (ITPWORK_domain in my case )


Scroll down the page and click on "Advanced"


Scroll down the page:


you must now select "Enable RESTful Management Services" to do this remember before to click on "Lock & Edit" button.

Click on "Save" button.


Now click on "Activate Changes"


As you can see, you will receive a message that all the servers must be restarted.


Under Environment->Servers, select Control and shutdown all the servers.




Now with Putty access to your JCS in SSH.
[How to access in SSH to Oracle Cloud using Putty and ppk key]
In the next image you can find all the commands and where to go to restart the Admin Server:
The path of the domains are always the same : /u01/data/domains
To access to /u01 remember to execute "sudo su"
To start the AdminServer you MUST use the startJCSServer.sh under <your_domain>/bin
Use the command:
nohup ./startJCSServer.sh  -Dweblogic.Name=<your WLS Admin server name> &


When the Admin Server is Running restart the Console and login:


Now you can restar the managed Server:





Now you can call RESTful Management services.

At the first access will appear a pop-up for Authentication, put here the same user and password that you are using for the login in WebLogic Console.

In the next images you can see some sample url to call:

[Oracle Docs on RestFul Management Services]


Servers informations:


Specific Server Info:


Logs for a specific server:


Here we are reading a Log of a Managed Server with Rest and with a simple Browser:
If you plan to do this I suggest to use Log Rotation on WSL and to limit the size of each lof file, to do this in the Admin Console go to Environment->Servers->your managed server->Logging.


I suggest to use a Rest Client, for example I use Postman Chrome App:



sabato 7 novembre 2015

DevOps & Oracle Cloud: Complete step by step guide on how to create from scratch a Maven Project (war) on Eclipse, synchronize it with a Git on Oracle Developer Cloud Service and finally how to use DevCS to build (Hudson) and deploy it on Java Cloud Service


For this guide you need only a laptop or PC with JDK8 and WLS12.1.3 already installed. (WLS is not mandatory but recommended)

If you are not interested on deploying the application on Java Cloud Service, you must follow only the task 3, 6
  1. Generate private and public keys (pub & ppk) for SSH communication
    • you will need a pub key for the creation of a new service in Oracle Java Cloud Service
    • you will need a ppk key for ssh communication from your laptop to Java Cloud Service
  2. Create a Service on Java Cloud Service
  3. Create a Project & a Git repository on Developer Cloud Service
  4. How to access in SSH to Java Cloud Service using Putty and ppk key
  5. How to setup a SSH communication between Developer Cloud Service and Java Cloud Service to enable the Deploy from DevCs to JCS
  6. How to create from scratch a Maven Project on Eclipse, synchronize it with a Git on Oracle Developer Cloud Service and finally how to use DevCS to build and deploy it on Java Cloud Service
If you follow this guide I suggest to look and follow this Gantt file that I have prepared for a customer that I follow. 


This is a "pessimistic" Gantt, but it is an idea of what to do during the waiting time of the creation of Java Cloud Service, but as you can see,  in around 4 hours (I was able to do this in 2 hours) you will be able to create an Hybrid DevOps architecture from scratch. (Task "Porting Application" is out of the scope of this guide).

Obviously for a new project you will spend few seconds, with Oracle Cloud Plug-in inside Eclipse, you will able to create a new project on premise and on cloud and synchronize it in a simple way.

How to setup a SSH communication between Developer Cloud Service and Java Cloud Service to enable the Deploy from DevCs to JCS

If you need to access to JCS (Java Cloud Service) from DevCS (Developer Cloud Service), for example you need to do this when you deploy something from DevCS to JCS, you must enable an SSH communication with pub & private keys between DevCS and JCS.

You must obtain a key from DevCS and insert this key on JCS.

To obtain the key from DevCS you can do a REST call:
https://developer.us2.oraclecloud.com/developer50378-metcsgse00503/api/deployment/sshkey

The red part is tipical of your DevCS environment, is the url that you have after the login on your DevCS.

You must use the same user and password that you use in the login of DevCS, in the next image you can see a sample of rquest with Postman on my domain :



Now you need to copy the highlighted part as you can see in the next image:


Access to JCS with Putty:
[How to access in SSH to Oracle Cloud using Putty and ppk key]

Paste the highlighted part in the authorized_keys.


In the next image you can see the new inserted part in my authorized_keys ...

That's all !!!


How to access in SSH to Oracle Cloud using Putty and ppk key

To access to your JCS (Java Cloud Service) environment, you can use Putty.
You need to configure a ssh session with a private key.
You must use your Public IP address of JCS Service, you can find it on your JCS account.
Port in 22.


The user is always "opc"


Set the location of your private key.
[Oracle Cloud & SSH: How to generate private and public keys (pub & ppk)]
Remember: You have used the public key during the creation of JCS service.


Now you can access to JCS.


Oracle Cloud & SSH: How to generate private and public keys (pub & ppk)

A simple way to generate pub & ppk keys for SSH is to use Putty Key Generator, you can download it from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and is the best choice if you will use Putty for SSH connections.