Create a Java path entry for all users

I install Java on all my machines and used to add the java path and home variables to the user (or my user) bash profile but every time I added another user this is a manual step.

Until I found this small trick. Add a system wide profile path setting by creating a file in:

/etc/profile.d/filename

All files in profile.d are added to every users login. Much cleaner than adding it to every user’s profile.

This is the contents of my file:

/etc/profile.d/java-path.sh

export JAVA_HOME="/opt/java"
export PATH=$JAVA_HOME/bin:$PATH

These variables are set next time you log in with any user on that system.

BEA-010213, Message-Driven EJB: MyProcessMDB's transaction was rolled back

I encountered this error last week and it was quite a headache to find out what the source of the problem was.

Short summary:

I thought the BEA-010213 error and the rollback log entries meant that we had a database problem. This was a wrong assumption, there’s another storage type in weblogic domains which use transactions (or state transitions?), which are JMS queues, which live in persistent stores in the managed servers.
That was the source of our problem; our persistent stores became corrupted because of storage problems.
Continue reading “BEA-010213, Message-Driven EJB: MyProcessMDB's transaction was rolled back”

Weblogic, 1 managed server gives HTTP Error 401 Unauthorized, other works fine.

I encountered this weird behaviour last week where one managed server in a cluster of two servers constantly gave the error “HTTP Error 401 Unauthorized“.
The setup was a standard Oracle Service Bus installation on Oracle Weblogic.
The domain consisted out of one Admin server, one cluster with two managed servers.
Managed Server #1 was acting without problems but all the requests which needed authentication and which where pointed to Managed Server #2 failed and responded with a 401 Unauthorized message.
There was an error in the logs of MS#2, which is displayed at the bottom of this post as well.
#### <> <Inbound http BASIC authentication failed
javax.security.auth.login.FailedLoginException: [Security:090304]Authentication Failed: User webhosting javax.security.auth.login.FailedLoginException: [Security:090302]Authentication Failed: User webhosting denied

The solution to this problem lies in the internal LDAP configuration of the faulty Managed Server. I did not find an answer to what might have caused this problem, but the solution was to rebuild the LDAP setting of the Managed Server.
This is done by following these steps:

  1. Shut down Managed Server via Weblogic Console
  2. Log in via SSH
  3. Rename the following folder: %domain_directory%/servers/%osb_managed_server_1%/data/ldap
  4. Start the Managed Server via Weblogic Console

These steps will rebuild the LDAP folder, which is the internal LDAP to which Weblogic authenticates.
You can then remove the folder you’ve backed up in step 3.
Continue reading “Weblogic, 1 managed server gives HTTP Error 401 Unauthorized, other works fine.”

Install Oracle Java in Fedora, Red Hat or CentOS using Yum and RPM

Hi guys,
This post will outline how to install Oracle Java JDK in Fedora, Red Hat or CentOS.
Please note that this will only install the JDK, when you’re done you will need to select this JDK to be able to use it. That is outlined in this blog post: Easily switch between java versions using alternatives in Linux
First determine if you need 32 or 64 bit. If you’re unsure you can check using “uname -p” in a terminal which will display your kernel and which architecture you’re using.
Next, download the JDK that you wish to use. In this example I will be installing the latest JDK from Oracle, you can find it here: Oracle Java Downloads.
I have chosen Java Platform (JDK) 8u31, which downloads the RPM.
1612441
After the download is finished, open a terminal and go to the location of the download.
Next, enter this command:
[code gutter=”false”]
sudo yum install jdk-8u31-linux-x64.rpm
[/code]
This will install the JDK.
Important: After this is done, you have placed all the files in the right location, but can’t use it until you’ve finished the steps in this blog post: Easily switch between java versions using alternatives in Linux

Select an XML tag or node using Oracle PL SQL

Hi guys,
I’ve been using this trick for a while and it’s quite useful when querying Oracle Service Bus logs. I found myself trying to explain this one to a colleague and thought it made a nice post 🙂
Let’s start with the basic command:
extractvalue
Which translates into:
[code language=”sql”]
SELECT EXTRACTVALUE(
xmltype(xml_val),
‘/xml-fragment/tns:product’,
‘xmlns:tns="http://example.org/"’,
‘xmlns:ans="http://anothernamespace.org/"’,
‘xmlns:yans="http://yetanothernamespace.org/"’
)
x
FROM xml_table
[/code]
Note: the first argument is being cast from CLOB to XMLTYPE and that you can keep adding namespaces at the end by adding commas.
I’ve added three rows in my table “XML_TABLE” for this example:
[code language=”XML”]
ROW1:
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
ROW2:
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
ROW3:
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
[/code]
Next we’ll query our XML_TABLE:
[code language=”sql”]
SELECT
EXTRACTVALUE( xmltype(xmlval), ‘/book/title’ ) AS title,
EXTRACTVALUE( xmltype(xmlval), ‘/book/author’ ) AS author,
EXTRACTVALUE( xmltype(xmlval), ‘/book/year’ ) AS year,
EXTRACTVALUE( xmltype(xmlval), ‘/book/price’ ) AS price
FROM xml_table;
[/code]
Which results in this output:
Workspace 1_034
Awesome, right!? 🙂
Continue reading “Select an XML tag or node using Oracle PL SQL”

Dynamic HTTP endpoint in Oracle Service Bus 12c based on values in a database routing table

This article outlines how to set a dynamic endpoint in an OSB HTTP Business Service. The endpoint is retrieved from a routing table which resides in an Oracle 12c database.

Components used for this solution:

  1. Ubuntu Linux 14.04 64bit
    1. JDeveloper, running the Quick Start Oracle Fusion Middleware suite
      1. Oracle Service Bus 12c
      2. Oracle Weblogic 12c
      3. OSB Project location:
        1. https://github.com/visscher/Fusion/tree/master/DBRouting
    2. Oracle Virtualbox Developer Days image for DB 12c, running:
      1. Oracle Database 12c
    3. Oracle SQL Developer 4

This picture shows the running solution in the OSB test console:
Oracle Service Bus Console 12c : Pipeline Testing - DBRouting_v1Pipeline - Google Chrome_019

Database table preparation

We need a routing table in our schema, I’m using this table setup:

CREATE TABLE "C##JORIS"."ROUTINGTABLE"
  (
    "ROUTE" VARCHAR2(50),
    "ENDPOINT" VARCHAR2(100)
  );
Where ROUTE stands for the identifier and ENDPOINT is the HTTP endpoint we try to reach.
I’ve inserted two rows:
Insert into ROUTINGTABLE (ROUTE,ENDPOINT) values ('SalesOrder','http://localhost:7101/salesEndpoint');
Insert into ROUTINGTABLE (ROUTE,ENDPOINT) values ('FinanceReceipt','http://localhost:7101/financeEndpoint');
These two endpoints will point to very simple OSB services which we will create in a moment.
Selection_022

Weblogic configuration: JDBC Data Source

We need to configure a JDBC data source in our Weblogic server, this data source is used by the XQuery function to execute SQL.
Start JDEVeloper, select your integrated Weblogic Server and start it up.
When your domain is started, open the WLS Console:
http://127.0.0.1:7101/console/
Login and open the Data Sources summary:
Selection_020
Navigation in Console: DefaultDomain - Services - Data Sources
Create a new datasource, in my example I use the JNDI name “LocalDB
When you’re done with the configuration, test the datasource to make sure all is well:
Selection_021
The status message will be green and show a check mark if you’ve configured your data source correctly.

JDeveloper: Oracle Service Bus project

If you import the DBRouting project from here, you should have all the necessary services.
I will only discuss the assign steps which are needed in the DBRouting_v1Pipeline.pipeline.
Selection_023
There are three assign actions:
1.) Assign $route: node-name($body/*[1])
This assign determines our routing key. It is the same key as
the first column in the routing table.
The XPath here is used to select the name of the first node
but you can change this to what you want to route on.
2.) Assign $query: 
fn:concat("select ENDPOINT from ROUTINGTABLE where ROUTE = '", $route, "'")
This assign determines the query which will be executed in
the next step. We want to select the ENDPOINT which belongs
to the ROUTE which was assigned in step 1.
3.) Assign $query: 
(fn-bea:execute-sql(
 xs:string("LocalDB"),
 xs:string("ENDPOINT"),
 $query
 )/*:ENDPOINT)[1]
This assign actually executes the SQL query to our database,
which is the first argument.
The second argument names the re-occurring rows, in this
case "ENDPOINT".
The thirst argument is the query to execute.
The XPath after the execute-sql statement is to make sure
we only get one endpoint.
4.) After those assigns, we use place a task “Routing Options” in the HTTP Route node:
We only use the “URI” Routing Option:
$endpoint/text()
Selection_024
This ends the article, if you execute the pipeline you will see the endpoint has become dynamic, it is retreived from the routing table:
Oracle Service Bus Console 12c : Pipeline Testing - DBRouting_v1Pipeline - Google Chrome_019

Start JDeveloper on Ubuntu Linux for Fusion Middleware SOA Suite 12c

Okay, this was a bit awkward, I installed the quick start 12c Fusion Middleware and was well underway to getting it all up and running.
Untill I closed JDev and couldn’t find the executable anymore..!
For anyone who had the same embarrassing situation, it’s located here:

*MiddlewareInstallationFolder*/jdeveloper/jdev/bin/jdev

Oracle SQL Developer 4 does not run on Oracle Java 7 on Ubuntu 14.04

Wow, ain’t this awkward :-). I cannot run Oracle SQL Developer 4 (4.0.2) on Ubuntu with Oracle JDK 7..

To be complete: when running SQL Developer with JDK 7 from Oracle itself, displays the following error;

joris@dipshit:~/programs/sqldeveloper$ ./sqldeveloper.sh
Oracle SQL Developer
Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
LOAD TIME : 968#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x6aa69be0, pid=9537, tid=1836366656
#
# JRE version: Java(TM) SE Runtime Environment (7.0_65-b17) (build 1.7.0_65-b17)
# Java VM: Java HotSpot(TM) Server VM (24.65-b04 mixed mode linux-x86 )
# Problematic frame:
# C 0x6aa69be0
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/joris/programs/sqldeveloper/sqldeveloper/bin/hs_err_pid9537.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
/home/joris/programs/sqldeveloper/sqldeveloper/bin/../../ide/bin/launcher.sh: line 1193: 9537 Aborted (core dumped) ${JAVA} "${APP_VM_OPTS[@]}" ${APP_ENV_VARS} -classpath ${APP_CLASSPATH} ${APP_MAIN_CLASS} "${APP_APP_OPTS[@]}"

Solution: Run Oracle SQL Developer with OpenJDK

First we’ll need to install OpenJDK:

sudo apt-get install openjdk-7-jdk 

Then we’ll need to change the path which SQL Developer uses. This was asked once when you first started it and it is saved in the following path:

~/.sqldeveloper/4.0.0/product.conf

The file [[ product.conf ]] contains the value SetJavaHome, we need to change this to the OpenJDK path;

If you're running 32 bit Ubuntu:

SetJavaHome /usr/lib/jvm/java-7-openjdk-i386

Or if you're running 64 bit Ubuntu:

SetJavaHome /usr/lib/jvm/java-7-openjdk-amd64

After saving this change, you can start SQL Developer on Ubuntu 14.04 and it will use OpenJDK 7, without changing your regular Java settings!

Oracle SQL – BLOB to XML Type ( ORA-06502 PL/SQL : numeric or value error : raw variable length too long )

I am working with a database schema where xml content is being stored in a BLOB and I’m working on querying that XML.
When you cast the BLOB to VARCHAR, you’ll run into the limit of 2000 characters with the following error:

ORA-06502 PL/SQL : numeric or value error : raw variable length too long

So this trick came in handy:

SELECT XMLTYPE( BLOB_FIELD, 871 ) AS AWESOMEXML FROM YOUR_TABLE;

Please be very aware of the character set that you are using, you can enter a world of hurt when you’re using the wrong one. The number 871 is the character set UTF8, which we are using.
For other character sets, check http://www.mydul.net/charsets.html

Weblogic does not start, java.lang.NumberFormatException, EmbeddedLDAP

I encountered the following exception when trying to start our AdminServer today:

<May 30, 2013 1:04:27 PM CEST> <Critical> <WebLogicServer> <BEA-000386> <Server subsystem failed. Reason: java.lang.NumberFormatException: null
java.lang.NumberFormatException: null
 at java.lang.Integer.parseInt(Integer.java:454)
 at java.lang.Integer.parseInt(Integer.java:527)
 at weblogic.ldap.EmbeddedLDAP.validateVDEDirectories(EmbeddedLDAP.java:1104)
 at weblogic.ldap.EmbeddedLDAP.start(EmbeddedLDAP.java:242)
 at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
 Truncated. see log file for complete stacktrace
>
<May 30, 2013 1:04:27 PM CEST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FAILED>
<May 30, 2013 1:04:27 PM CEST> <Error> <WebLogicServer> <BEA-000383> <A critical service failed. The server will shut itself down>
<May 30, 2013 1:04:27 PM CEST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FORCE_SHUTTING_DOWN>

This does not really explain what went wrong, but the solution is to remove the replicas.prop file and restart the AdminServer again.
The replicas.prop file is located at :
$DOMAIN/servers/AdminServer/data/ldap/conf/replicas.prop
Rename (move) replicas.prop to replicas.prop.bak and retry the startWeblogic. In my case this solved the not starting server.