Thursday, October 30, 2014
Weblogic : Creating Datasource using MAVEN and WLST Script
One of the interesting features of 12c is the option of using Maven for many of the administration tasks.
Maven along with WLST becomes the most convenient and powerful option to perform many of the administration tasks like creating domain,start and stop servers, listing deployed composites etc..
In this post I would like to introduce how maven plugin can be used to invoke a WLST script which creates a datasource in the weblogic domain.
As a first step we need to install maven plugin wls-maven-plugin.
This plugin present in the ORACLE_HOME/wlserver_12.1/server/lib
Open a command prompt and navigate to the above location
Now we need to install this plugin to our repository( here by default the repository will be the local repository which is present at c:/users/<username>/.m2 (for windows)).
To install the plugin use the following command
mvn install:install-file -Dfile=wls-maven-plugin.jar -DpomFile=pom.xml
Once the installation is successful we can verify whether the required goals are available using the following command
Maven along with WLST becomes the most convenient and powerful option to perform many of the administration tasks like creating domain,start and stop servers, listing deployed composites etc..
In this post I would like to introduce how maven plugin can be used to invoke a WLST script which creates a datasource in the weblogic domain.
As a first step we need to install maven plugin wls-maven-plugin.
This plugin present in the ORACLE_HOME/wlserver_12.1/server/lib
Open a command prompt and navigate to the above location
Now we need to install this plugin to our repository( here by default the repository will be the local repository which is present at c:/users/<username>/.m2 (for windows)).
To install the plugin use the following command
mvn install:install-file -Dfile=wls-maven-plugin.jar -DpomFile=pom.xml
Once the installation is successful we can verify whether the required goals are available using the following command
mvn com.oracle.weblogic:wls-maven-plugin:help
Here we can see the wlst task is available.
Now we are ready to execute the WLST script using maven
Create a datasource.properties file as shown below(change the values as per your requirement)
==================
domain.name=base_domain
admin.url=t3://localhost:7101
admin.userName=weblogic
admin.password=weblogic1
datasource.name=MyDataSource
datasource.database.name=XE
datasource.target=DefaultServer
datasource.filename=DS_One.xml
datasource.jndiname=DS_One_JNDI
datasource.driver.class=oracle.jdbc.xa.client.OracleXADataSource
datasource.url=jdbc:oracle:thin:@localhost:1521:XE
datasource.username=aq_user
datasource.password=aq_user
datasource.test.query=SQL SELECT * FROM DUAL
============================================
Save the following python script as datasource.py
note : remember to give the exact path to the datasource.properties file)
========start of python script ==========
from java.io import FileInputStream
propInputStream = FileInputStream("\\path\\to\\datasource.properties")
configProps = Properties()
configProps.load(propInputStream)
domainName=configProps.get("domain.name")
adminURL=configProps.get("admin.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")
dsName=configProps.get("datasource.name")
dsFileName=configProps.get("datasource.filename")
dsDatabaseName=configProps.get("datasource.database.name")
datasourceTarget=configProps.get("datasource.target")
dsJNDIName=configProps.get("datasource.jndiname")
dsDriverName=configProps.get("datasource.driver.class")
dsURL=configProps.get("datasource.url")
dsUserName=configProps.get("datasource.username")
dsPassword=configProps.get("datasource.password")
dsTestQuery=configProps.get("datasource.test.query")
connect(adminUserName, adminPassword, adminURL)
edit()
startEdit()
cd('/')
cmo.createJDBCSystemResource(dsName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName)
cmo.setName(dsName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName )
set('JNDINames',jarray.array([String('jdbc/' + dsName )], String))
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName )
cmo.setUrl(dsURL)
cmo.setDriverName(dsDriverName)
cmo.setPassword(dsPassword)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCConnectionPoolParams/' + dsName )
cmo.setTestTableName(dsTestQuery)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName )
cmo.createProperty('user')
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName + '/Properties/user')
cmo.setValue(dsUserName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName )
cmo.createProperty('databaseName')
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName + '/Properties/databaseName')
cmo.setValue(dsDatabaseName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName )
cmo.setGlobalTransactionsProtocol('OnePhaseCommit')
cd('/SystemResources/' + dsName )
set('Targets',jarray.array([ObjectName('com.bea:Name=' + datasourceTarget + ',Type=Server')], ObjectName))
save()
activate()
========================end of python script===============
Now open command prompt
Execute the following command after correcting the path as per your soa installation
mvn wls:wlst -DfileName=path/to/datasource.py - DmiddlewareHome=path/to/oraclehome
-DdomainHome=path/to/domainhome
Once the script is executed successfully. Open the weblogic console and verify the datasource is created successfully
Monday, October 27, 2014
Namespace value in SOAPAction does not match Namespace value 'http://schemas.xmlsoap.org/soap/envelope/' in xml tag 'Body'
This issue normally comes when we use Service Callout.
Service Callout has an option to configure Body or Payload
Payload means , it will be send as a child of Body.
If you pass your request which is already a SOAP Body as a payload, and if you select Payload Document Option it will be like sending a SOAP Body inside SOAP Body. That might result the above error.
In such cases choose wisely which option you need to select while sending request via service callout
If your request itself is a SOAPBody choose the SOAP Body option. Otherwise choose the payload option
Service Callout has an option to configure Body or Payload
Payload means , it will be send as a child of Body.
If you pass your request which is already a SOAP Body as a payload, and if you select Payload Document Option it will be like sending a SOAP Body inside SOAP Body. That might result the above error.
In such cases choose wisely which option you need to select while sending request via service callout
If your request itself is a SOAPBody choose the SOAP Body option. Otherwise choose the payload option
Tuesday, October 21, 2014
How to install a maven plugin to the central repository
If you want to install a plugin to the central repository like Archiva or Artifactory, follow the below steps
1) Download the plugin jar from
2) Extract the jar file and from the META_INF folder copy the path to POM file
3) Open the command prompt and navigate to the directory where the jar and POM file resides
4) Run the following command by replacing the jar file name and pom name
For eg. to install properties-maven-plugin-1.0-alpha-2.jar to central repository
mvn deploy:deploy-file -DpomFile=<path_to>\properties-maven-plugin-1.0-alpha-2\META-INF\maven\org.codehaus.mojo\properties-maven
-plugin\pom.xml -Dfile=properties-maven-plugin-1.0-alpha-2.jar -Durl=http://localhost:8091/artifactory/internal -DrepositoryId=internal
Now to use this plugin along with your POM file add the following section in the POM file under the plugin section
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>build-${deploy}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
1) Download the plugin jar from
2) Extract the jar file and from the META_INF folder copy the path to POM file
3) Open the command prompt and navigate to the directory where the jar and POM file resides
4) Run the following command by replacing the jar file name and pom name
For eg. to install properties-maven-plugin-1.0-alpha-2.jar to central repository
mvn deploy:deploy-file -DpomFile=<path_to>\properties-maven-plugin-1.0-alpha-2\META-INF\maven\org.codehaus.mojo\properties-maven
-plugin\pom.xml -Dfile=properties-maven-plugin-1.0-alpha-2.jar -Durl=http://localhost:8091/artifactory/internal -DrepositoryId=internal
Now to use this plugin along with your POM file add the following section in the POM file under the plugin section
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>build-${deploy}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
Thursday, October 9, 2014
12C OSB DVM usage :oracle.tip.dvm.exception.DVMValidationException: Unable to get Metadata Manager
When we use DVM in OSB 12c, during runtime there is a possibility to encounter a below as given below
weblogic.work.ExecuteThread.run(ExecuteThread.java:263) Caused by: oracle.tip.dvm.exception.DVMValidationException: Unable to get Metadata Manager for DVM "xxx.dvm" Please ensure the Metadata Manager is available. at oracle.tip.dvm.DVMManagerImpl.getDVMRTObject(DVMManagerImpl.java:223) at oracle.tip.dvm.DVMManagerImpl.lookupValue(DVMManagerImpl.java:88) at com.bea.wli.sb.functions.dvm.DVMFunctions.lookupValue(DVMFunctions.java:40) ... 78 more
This could be due to the fact that process is not able to locate the dvm file. If the DVM file is part of your project ensure you refer that in the dvm lookup fuction as given below
dvm:lookup('<projectname>/<relativepathToDVMfile>.dvm', 'PROPERTY_KEY', 'key', 'PROPERTY_VALUE', ' ')
weblogic.work.ExecuteThread.run(ExecuteThread.java:263) Caused by: oracle.tip.dvm.exception.DVMValidationException: Unable to get Metadata Manager for DVM "xxx.dvm" Please ensure the Metadata Manager is available. at oracle.tip.dvm.DVMManagerImpl.getDVMRTObject(DVMManagerImpl.java:223) at oracle.tip.dvm.DVMManagerImpl.lookupValue(DVMManagerImpl.java:88) at com.bea.wli.sb.functions.dvm.DVMFunctions.lookupValue(DVMFunctions.java:40) ... 78 more
This could be due to the fact that process is not able to locate the dvm file. If the DVM file is part of your project ensure you refer that in the dvm lookup fuction as given below
dvm:lookup('<projectname>/<relativepathToDVMfile>.dvm', 'PROPERTY_KEY', 'key', 'PROPERTY_VALUE', ' ')
Oracle Maven Sync Plugin Installation : Return code is: 401, ReasonPhrase: Unauthorized
While trying to install the maven-sync-plugin to a centralized repository like Archiva/Artifactory
sometimes an authorization error happens as follows
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts:
Could not transfer artifact com.oracle.maven:oracle-maven-sync:jar:12.1.3-0-0 f
rom/to remote-repository (http://localhost:8091/artifactory/internal): Failed to
transfer file: http://localhost:8091/artifactory/internal/com/oracle/maven/orac
le-maven-sync/12.1.3-0-0/oracle-maven-sync-12.1.3-0-0.jar. Return code is: 401,
ReasonPhrase: Unauthorized. -> [Help 1]
This can be resolved by doing the following steps
1) Create a new user called demouser in the Archiva/Artifactory
2) Give the permissions to the user to the desired repositories
3) encrypt the password using the command mvn -ep <password>
4)Use the encrypted password in the settings.xml, as shown below
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>internal</id>
<name>internal</name>
<url>http://localhost:8091/artifactory/internal</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshot</id>
<name>snapshot</name>
<url>http://localhost:8091/artifactory/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
<mirrors>
<mirror>
<id>mirror</id>
<name>mirror</name>
<url>http://localhost:8091/artifactory/repo1</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>internal</id>
<username>demouser</username>
<password>{y2ZZOfE4lLkH78iLLX9xLQjL2/Rkoocq/Yq5HrACJdM=}</password>
</server>
<server>
<id>snapshot</id>
<username>demouser</username>
<password>{y2ZZOfE4lLkH78iLLX9xLQjL2/Rkoocq/Yq5HrACJdM=}</password>
</server>
</servers>
</settings>
6)Also create a master password using mvn -emp <masterpassword>
7)Create a settings-security.xml with the encrypted master password as shown below
Note: replace your master password inside the <master> tag
<settingsSecurity>
<master>{nng7rwwwwKMHM+yJE3201WFQ1WlzYUfgoZGxW2mIcTc=}</master>
</settingsSecurity>
8)Place this settings.xml and settings-security.xml under <userhome>/.m2 directory
9) Now execute the install command as follows.
open the command prompt
Navigate to <ORACLE_HOME>\oracle_common\plugins\maven\com\oracle\maven\oracle-maven-sync\12.1.3
The execute the following command at the prompt :
mvn deploy:deploy-file -DpomFile=oracle-mave
n-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar -Durl=http://localhost:8091/artifactory/internal -DrepositoryId=internal
Note : Ensure the -DrepositoryId is spelled as given in the above command(case sensitive). Don't use -DRepositoryId
10)Once this command runs successfully, then execute the push goal as shown below
mvn com.oracle.maven:oracle-maven-sync:push
-DoracleHome=C:\installed\Oracle\Middleware12C\Oracle_Home -DserverId=internal
This too will now run successfully and your repository will now have all the necessary artifacts installed .
11) To validate your installation run the following command. This will show all the availble goals which you can now use
mvn help:describe -DgroupId=com.oracle.soa.plugin -DartifactId=oracle-soa-plugin -Dversion=12.1.3-0-0
The result will be as follows
====================================
This plugin has 6 goals:
oracle-soa:compile
Description: Compiles the composite. Note that 'compiling' a composite does
not actually produce any new files, it is really a 'validation' and
produces only output messages.
oracle-soa:deploy
Description: To deploy a SOA composite (supports all formats SAR, MAR,
etc.)
oracle-soa:help
Description: Display help information on oracle-soa-plugin.
Call mvn oracle-soa:help -Ddetail=true -Dgoal=<goal-name> to display
parameter details.
oracle-soa:sar
Description: Packages the composite into a SAR.
oracle-soa:test
Description: To execute SCA Test Suites.
oracle-soa:undeploy
Description: Undeploy a SOA composite from a SOA managed server or cluster
For more information, run 'mvn help:describe [...] -Ddetail'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
sometimes an authorization error happens as follows
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts:
Could not transfer artifact com.oracle.maven:oracle-maven-sync:jar:12.1.3-0-0 f
rom/to remote-repository (http://localhost:8091/artifactory/internal): Failed to
transfer file: http://localhost:8091/artifactory/internal/com/oracle/maven/orac
le-maven-sync/12.1.3-0-0/oracle-maven-sync-12.1.3-0-0.jar. Return code is: 401,
ReasonPhrase: Unauthorized. -> [Help 1]
This can be resolved by doing the following steps
1) Create a new user called demouser in the Archiva/Artifactory
2) Give the permissions to the user to the desired repositories
3) encrypt the password using the command mvn -ep <password>
4)Use the encrypted password in the settings.xml, as shown below
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>internal</id>
<name>internal</name>
<url>http://localhost:8091/artifactory/internal</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshot</id>
<name>snapshot</name>
<url>http://localhost:8091/artifactory/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
<mirrors>
<mirror>
<id>mirror</id>
<name>mirror</name>
<url>http://localhost:8091/artifactory/repo1</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>internal</id>
<username>demouser</username>
<password>{y2ZZOfE4lLkH78iLLX9xLQjL2/Rkoocq/Yq5HrACJdM=}</password>
</server>
<server>
<id>snapshot</id>
<username>demouser</username>
<password>{y2ZZOfE4lLkH78iLLX9xLQjL2/Rkoocq/Yq5HrACJdM=}</password>
</server>
</servers>
</settings>
6)Also create a master password using mvn -emp <masterpassword>
7)Create a settings-security.xml with the encrypted master password as shown below
Note: replace your master password inside the <master> tag
<settingsSecurity>
<master>{nng7rwwwwKMHM+yJE3201WFQ1WlzYUfgoZGxW2mIcTc=}</master>
</settingsSecurity>
8)Place this settings.xml and settings-security.xml under <userhome>/.m2 directory
9) Now execute the install command as follows.
open the command prompt
Navigate to <ORACLE_HOME>\oracle_common\plugins\maven\com\oracle\maven\oracle-maven-sync\12.1.3
The execute the following command at the prompt :
mvn deploy:deploy-file -DpomFile=oracle-mave
n-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar -Durl=http://localhost:8091/artifactory/internal -DrepositoryId=internal
Note : Ensure the -DrepositoryId is spelled as given in the above command(case sensitive). Don't use -DRepositoryId
10)Once this command runs successfully, then execute the push goal as shown below
mvn com.oracle.maven:oracle-maven-sync:push
-DoracleHome=C:\installed\Oracle\Middleware12C\Oracle_Home -DserverId=internal
This too will now run successfully and your repository will now have all the necessary artifacts installed .
11) To validate your installation run the following command. This will show all the availble goals which you can now use
mvn help:describe -DgroupId=com.oracle.soa.plugin -DartifactId=oracle-soa-plugin -Dversion=12.1.3-0-0
The result will be as follows
====================================
This plugin has 6 goals:
oracle-soa:compile
Description: Compiles the composite. Note that 'compiling' a composite does
not actually produce any new files, it is really a 'validation' and
produces only output messages.
oracle-soa:deploy
Description: To deploy a SOA composite (supports all formats SAR, MAR,
etc.)
oracle-soa:help
Description: Display help information on oracle-soa-plugin.
Call mvn oracle-soa:help -Ddetail=true -Dgoal=<goal-name> to display
parameter details.
oracle-soa:sar
Description: Packages the composite into a SAR.
oracle-soa:test
Description: To execute SCA Test Suites.
oracle-soa:undeploy
Description: Undeploy a SOA composite from a SOA managed server or cluster
For more information, run 'mvn help:describe [...] -Ddetail'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Subscribe to:
Posts (Atom)