Unix

Install VMWare tools

It’s a small but simple task to install VMWare tools on your virtual machine.

I used the VMware vSphere Client to connect iso of the official VMWare client software as a cdrom to the cdrom drive of the running vm.

sudo mkdir /media/CD
sudo mount /dev/hda /media/CD

Copy the tar.gz file to a temp directory

mkdir /tmp
cp /media/CD/VMwareTools-4.0.0-208167.tar.gz /tmp

Extract the archive file

cd /tmp
tar xvzf VMwareTools-4.0.0-208167.tar.gz

Run the installation file

cd vmware-tools-distrib
sudo ./vmware-install.pl

The default parameters where sufficient for me so i could quickly continue I had to compile the tool again because there where no precompiled valid for my system. I neede to have a c ompiler that i had installed earlier

apt-get install gcc

after installation i restarted the vmxnet driver with the command dispayed in the terminal (i included the sudo command)

sudo /etc/init.d/networking stop
sudo rmmod pcnet32
sudo rmmod vmxnet
sudo modprobe vmxnet
sudo /etc/init.d/networking start

After this the client VMWare tools are installed.

Popularity: 7% [?]

Development

Configure Hudson Subversion Credentials

When hudson is using a secured subversion repository you need to supply the credentials for the used repository. You can enter your credentials using the following url:

http://[server]:[port]/hudson/scm/SubversionSCM/enterCredential

You will get a screen where you can register credentials connected to a repository

Popularity: 33% [?]

Development, maven

Getting started with Hudson

To get started with hudson you need to download the latest hudson version

Winstone is included in the war file so with a single command you can start hudson

set HUDSON_HOME=D:\workspace\BuildServer\hudson_home
set JAVA_OPTS=-XX:PermSize=50m -XX:MaxPermSize=100m -Xms64m -Xmx128m
java -DHUDSON_HOME=%HUDSON_HOME% -jar hudson.war --httpPort=8081

Popularity: 12% [?]

Development, maven

Include integration tests in maven build with TestNG

To execute integration tests you can use testNG an other test framwork bases on junit framework.

Test Suite
Just create a simple testNG suite defined in a XML format:

<suite name="LoginTestSuite">
  <test name="loginTest1-1">
     <parameter name="username" value="jcooper"/>
     <parameter name="password" value="welcome1"/>
     <parameter name="validTest" value="true"/>
     <classes>
     <class name="com.iteye.exchange.account.AllLoginTestsIT "/>
    </classes>
  </test>

  <test name="loginTest1-2">
     <parameter name="username" value="scot"/>
     <parameter name="password" value="dontknow"/>
     <parameter name="validTest" value="false"/>
     <classes>
     <class name="com.iteye.exchange.account.AllLoginTestsIT "/>
    </classes>
  </test>

  <test name="loginTest1-3">
     <parameter name="username" value="unknown"/>
     <parameter name="password" value="hack"/>
     <parameter name="validTest" value="false"/>
     <classes>
     <class name="com.iteye.exchange.account.AllLoginTestsIT "/>
    </classes>
  </test>
</suite>

Annotations
It calls the following Selenium test case where i have created a simple login script that logins with the supplied username and password (annotated with testng annotations ). It validates the tests if a valid or invalid repose is available in the HTML page.

Used annotations:

  1. @BeforeClass you specify the setup method. In this case a connection to a running selenium server.
  2. @Test to specify a tests method. In this case the execution of the login script
  3. @Parameters to specify a tests method parameters. In this case the username, password and if it’s a valid test
  4. @AfterClass to specify the post test method. In this case the closure of the selenium server

Selenium Test case
The Selenium test case:

package com.iteye.exchange.account;

import com.thoughtworks.selenium.*;
import org.testng.annotations.*;

public class AllLoginTestsIT extends SeleneseTestCase {
	private DefaultSelenium selenium;

	@BeforeClass
	public void setup() {
		selenium = new DefaultSelenium("localhost", 4444, "*iexplore",
				"http://localhost:8080/");
		selenium.start();
	}

	@Test
	@Parameters( { "username", "password", "validTest" })
	public void testLogin(String username, String password, Boolean validTest)
			throws Exception {
		selenium.open("/");
		selenium.type("username", username);
		selenium.type("password", password);
		selenium.click("//input[@value='Login']");
		selenium.waitForPageToLoad("30000");

		if (validTest) {
			verifyEquals(selenium.getText("//div[@id='nav']/div/span"),
					username);
			selenium.click("link=Logout");
			selenium.waitForPageToLoad("30000");

		} else {
			verifyEquals(selenium
					.getText("//form[@id='id1']/div[2]/ul/li/span"),
					"Unknown username / password");
		}
	}

	@AfterClass
	public void tearDown() {
		selenium.stop();
	}
}

Maven build file

In the maven buildfile you need to include testng as dependency for the project (only needed in the test phase). I start and stop Jetty and Selenium in the pre-integration-test and post-integration-test phase so they are up and rud running when i execute the integration tests using the maven-failsafe plugin.

Don’t forget to include maven-failsafe to the verify phase to let the build fail if there is an error in a integration test.
To let Jetty run as a demon process just give the daemon element a true value

..
<dependencies>
  <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>5.12.1</version>
    <scope>test</scope>
  </dependency>
  <dependencies>
  ...
    <plugin>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty-maven-plugin</artifactId>
      <version>7.0.1.v20091125</version>
      <executions>
        <execution>
          <id>start-jetty</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>run</goal>
          </goals>
          <configuration>
            <daemon>true</daemon>
            <scanIntervalSeconds>2</scanIntervalSeconds>
            <stopPort>9966</stopPort>
            <stopKey>foo</stopKey>
            <webdefaultxml>src/main/resources/webdefault.xml</webdefaultxml>
          </configuration>
        </execution>
        <execution>
          <id>stop-jetty</id>
          <phase>post-integration-test</phase>
          <goals>
            <goal>stop</goal>
          </goals>
          <configuration>
            <scanIntervalSeconds>2</scanIntervalSeconds>
            <daemon>true</daemon>
            <stopKey>HALT</stopKey>
            <stopPort>9100</stopPort>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-failsafe-plugin</artifactId>
      <version>2.5</version>
      <configuration>
        <suiteXmlFiles>
          <suiteXmlFile>testng.xml</suiteXmlFile>
        </suiteXmlFiles>
        <includes>
          <include>**/*IT.java</include>
        </includes>
      </configuration>
      <executions>
        <execution>
          <id>integration-test</id>
          <phase>integration-test</phase>
          <goals>
            <goal>integration-test</goal>
          </goals>
        </execution>
        <execution>
          <id>verify</id>
          <phase>verify</phase>
          <goals>
            <goal>verify</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>selenium-maven-plugin</artifactId>
      <version>1.0</version>
      <executions>
        <execution>
          <id>start-sel</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>start-server</goal>
          </goals>
          <configuration>
            <background>true</background>
            <logOutput>true</logOutput>
            <multiWindow>true</multiWindow>
          </configuration>
        </execution>
        <execution>
          <id>stop-sel</id>
          <phase>post-integration-test</phase>
          <goals>
            <goal>stop-server</goal>
          </goals>
        </execution>
      </executions>
    </plugin>

in this example the tests a straight forward and i didn’t use yet the added function that testNG has to offer. That is that you can specify test groups. To get a good explanation and example i refer to Maven Handbook Chapter 7.4
Resources

Popularity: 13% [?]

Oracle, Weblogic

Getting started with Weblogic Scripting WLST

Using WLST is a good practice to specify configuration etc. How many times did you encounter that data sources where not configured as specified. Administrators are using configuration wizards to manual apply configurations. This is a time consuming process and can easly be simplified by using scripting language. In software development we are using this already a long time. Using ANT or Maven to compile application sources and run automated tests.

Still using scripts is often seen as a ‘thing’ for programmers and system administrators somehow don’t have the trust in the use of scripts. Start using script and you will notice the decrease in workload when you have to apply configuration steps to your development environments {test, acceptation, production}. Scripts are executing alway the same logic and you reduce the type errors when configration changes are made by hand. How often you have you encountered a type error when a software release is promoted from Test to Acceptation. To get started with the Weblogic Scrpting language you can record the activities you preform within the Enterprise Manager.

Recording actions in the console
Click in the console in int the top menu on Record

You will get a notification that recording has been started and written to a mentioned location.

Then you preform your configration action. In this case a created a datasource to my local XE database using the HR user.
After that you press again record to stop the recording.

After that you can press Preferences and select the tab ‘WLST Script Recording’ to see where the script is stored and if you want to change future recordings you can adjust here the settings.

Below you see the content of the recording when creating a datasource:


startEdit()

cd('/')
cmo.createJDBCSystemResource('hrDataSource')

cd('/JDBCSystemResources/hrDataSource/JDBCResource/hrDataSource')
cmo.setName('hrDataSource')

cd('/JDBCSystemResources/hrDataSource/JDBCResource/hrDataSource/JDBCDataSourceParams/hrDataSource')
set('JNDINames',jarray.array([String('jdbc/oracle/xe/hr')], String))

cd('/JDBCSystemResources/hrDataSource/JDBCResource/hrDataSource/JDBCDriverParams/hrDataSource')
cmo.setUrl('jdbc:oracle:thin:@weblogic11g:1521:xe')
cmo.setDriverName('oracle.jdbc.xa.client.OracleXADataSource')
setEncrypted('Password', 'Password_1278942495114', '/opt/oracle/middleware/user_projects/domains/single-server-domain/Script1278942290175Config', '/opt/oracle/middleware/user_projects/domains/single-server-domain/Script1278942290175Secret')

cd('/JDBCSystemResources/hrDataSource/JDBCResource/hrDataSource/JDBCConnectionPoolParams/hrDataSource')
cmo.setTestTableName('SQL SELECT 1 FROM DUAL\r\n\r\n\r\n')

cd('/JDBCSystemResources/hrDataSource/JDBCResource/hrDataSource/JDBCDriverParams/hrDataSource/Properties/hrDataSource')
cmo.createProperty('user')

cd('/JDBCSystemResources/hrDataSource/JDBCResource/hrDataSource/JDBCDriverParams/hrDataSource/Properties/hrDataSource/Properties/user')
cmo.setValue('hr')

cd('/JDBCSystemResources/hrDataSource/JDBCResource/hrDataSource/JDBCDataSourceParams/hrDataSource')
cmo.setGlobalTransactionsProtocol('TwoPhaseCommit')

cd('/SystemResources/hrDataSource')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

activate()

All parameters are hard coded but it’s a point place to start with WLST.

Good practice is to separate the configuration parameters from the logic. This can be done by setting the configuration parameters at the beginning of the script or put the parameters in a seperate property file. I prefer this last option, this way the script doesn’t need to be altered when properties values are adjusted.

I encountered the issue that within the properties you can’t use a ‘.’ as a separator i had to change this to make my script work.

weblogic.server.url=t3://weblogic11g:7001
weblogic.username=weblogic
weblogic.password=weblogic1

datasource_hr_name=hrDataSource
datasource_hr_jndiname=jdbc/oracle/xe/hr
datasource_hr_jdbc_url=jdbc:oracle:thin:@weblogic11g:1521:xe
datasource_hr_jdbc_drivername=oracle.jdbc.xa.client.OracleXADataSource
datasource_hr_username=hr
datasource_hr_password=hr
datasource_hr_test_sql=SELECT 1 FROM DUAL

datasource_hr_server_name=AdminServer

giving the following error:

Problem invoking WLST - Traceback (innermost last):
  File "D:\workspace\IT-Eye\Weblog\WeblogicScriptingwlst\runwlstscript\hrDatasource.py", line 1, in ?
AttributeError: java package 'weblogic' has no attribute 'username'

I replaced the separator ‘.’ with ‘_’ and tried again:

c:wlst -loadProperties hrDatasource.properties hrDatasource.py

giving me the following result:

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://weblogic11g:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'single-server-domain'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

Location changed to edit tree. This is a writable tree with
DomainMBean as the root. To make changes you will need to start
an edit session via startEdit().

For more help, use help(edit)
You already have an edit session in progress and hence WLST will
continue with your edit session.

Starting an edit session ...
Started edit session, please be sure to save and activate your
changes once you are done.
Saving all your changes ...
Saved all your changes successfully.
Activating all your changes, this may take a while ...
The edit lock associated with this edit session is released
once the activation is completed.
Activation completed
Disconnected from weblogic server: AdminServer

WLST examples

Documentation

Popularity: 46% [?]

Development, Oracle, OSB

Install Oracle Service Bus and SOA suite in same server

Today i installed a fresh Weblogic Development server for development. I decides to install SOA suite an OSB in on the same server following the blog OracleServiceBus in same Server of Manoj Neelapu. This is a great way of saving resources while running a Weblogic Server configuration.

Chris Tomkins has made a viewlet demonstrating his installation steps: Creating a single server domain with SOA Suite and Oracle Service Bus functionality.

Popularity: 47% [?]

Development, Oracle, OSB

INST-07417 error while installing OSB 11g

Today i was installing osb 11g on my vm ware server when i encounterd the following error:

INST-07417: Evaluation Database has not been installed in the specified Weblogic Server Location. Provide a different Location.


During the installation i have chosen all the available components:

  • Oracle Server Bus Server
  • Oracle Service Bus IDE
  • Oracle Service Bus Examples

I decided to not install the examples to see if that would help.

I continued the installation and didn’t receive any errors. I got a nice installation summary.

It’s quite strange that you can’t install the Examples directly with the installation of the server. Has anyone got an idea why this doesn’t work?

environment

  • Oracle 10G XE database
  • RCU 11.1.1.3
  • Weblogic 10.3.3

Popularity: 8% [?]

ADF, Development, Oracle

ADF checkbox representing a yes or no value

In ADF you can present values as {‘Y’,'N’} or {‘YES’ ,’NO} with a dropdown box. But when you have to have a high usability of you application you would like to use checkboxes for boolean values instead of drop down boxes. In ADF this can be achieved by putting the values into a LOV and adjust the display type to checkbox. To show how it’s done i have made the following step by step example:

I have created in the hr schema of the database a person table with different boolean indicators.

 CREATE TABLE "HR"."PERSONS"
   (	"ID" NUMBER NOT NULL ENABLE,
	"BLN" NUMBER NOT NULL ENABLE,
	"YNBLN" VARCHAR2(1 BYTE) NOT NULL ENABLE,
	"YESNOBLN" VARCHAR2(20 BYTE),
        "EMAIL" VARCHAR2(20 BYTE),
	 CONSTRAINT "PERSONS_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "USERS"  ENABLE
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "USERS" ;

In the three BLN columns i store in a different way a indicator value.

  • Number: {1:true, 0:false}
  • Char: {Y:true, N:false}
  • String: {Yes:true;No:false}

After creating the table i made a ADF model application and created a Entity Object on this table and a view object based on the entity object.

When running the Application Module for a test you see the default presentation of the fields are input fields.

Changing the presentation of the number boolean indicator is quite straight forward. In the entity object Person we change the Attribute Type of Bln from Number (as it’s defined in the database) to Boolean. Because the entity knows that the Database Column is a numbered datatype it will take care of the data conversions. After this change we restart the Application Module. We see now that the numbered value presentation is been replaced by an check-box. This is done because the entity objects treats the values as a Boolean instead of a numbered value, and this conversion is quite easy to do.

Converting a boolean value to {Y,N} or to {YES, NO} needs some more work. You can use different solutions, you can generate a specific entity class where you do the conversion from boolean to any other data type. I have chose to use a static LOV list to convert boolean values to other data types values.


I created the LOV with three attribute values: Boolean, Char and String. This to show the working of different data types, it would be quite strange to have in a single application different way’s of storing boolean values.

I have given them the following values in a fixed list.

After specifying the LOV we have to tell the View Object that it should use the values from the LOV to be stored as a representation of the check or unchecked state of the checkbox. This is done in the following way.

Open of the View Object the tab View Accessors and press the green + to add a View Accessors. Shuffle the YesNoLOV to the right pane.

After adding the LOV as a View Accessor we go to the Attributes tab of the View Object and select the attribute that we want to change in this example Ynbln. We want to let the checkbox represent a Y value when checked and otherwise a N. To do this we select the Ynbln attribute and press the green + at the bottom of the screen to add a List of Values. Select in the Data Sourece List the added YesNoLOV1 that we created as a View Accessor and specify the column that the checkbox should represent. In this case the column valueYN.

Select no the tab UI Hints. Uncheck here at the option ‘Include “No Selection” Item:’ in the Choice List Options. We want always a value Y or N we don’t want a null value if the checkbox is not pressed.

Now we have configured the presentation of this attribute. Default the View Object will represent the value with a dropdown listbox. To use the checkbox we have to open the View Object and edit the specified attribute ‘Ynbln’. We select the Control Hits item on the left and alter the Control Type to ‘Check Box’.

Do you can do the same exercise for the attribute Yesnobln and use instead of the YNvalue the YesNo value.

To test the working of this solution run the Application Module and modify records. Check the modified records with SQL to check if the data that you have changed is stored in the correct format into the database.

As you see the corresponding results in the table.

Popularity: 87% [?]

Development, Oracle

Oracle APEX 4.0 Released

APEX 4.0

Today Oracle APEX 4.0 got released!! Download the new version here

Popularity: 19% [?]

ADF, Development, Oracle, Spatial

Using ADF GeoMap component

In preparation of an Oracle Spatial Presentation i have made a sample on how to implement Spatial data into an ADF Application. For this demo i used the sample data that comes with the MapViewer application. If you don’t have this sample data please install that first before you continue.

Start your 11g JDeveloper

READ THE FULL ARTICLE >>

Popularity: 48% [?]