Thursday, April 17, 2014

Oracle 11g Database not registering with listener

I have two instances of an Oracle database installed on a Unix zone. Unfortunately, one of them won't register with the listener when it starts.

In the $ORACLE_HOME/dbs folder I found a file called inittstep.ora, which was the init file for the working database. In it, I found:  *.local_listener='LISTENER.tst.tadnet.net'
In the file for the non-working database, I found a similar entry but it was different so I changed it to contain the value found in the good file; however, this still didn't help.

I started the database and tried this:

SQL> show parameter local_listener

alter system set LOCAL_LISTENER='LISTENER.tst.tadnet.net' scope=both

and it worked.

See:
http://edstevensdba.wordpress.com/2011/07/30/exploring-the-local_listener-parameter/



Saturday, April 12, 2014

Setting up a Maven GWT project in Eclipse with the GWT Maven Plugin

This how-to assumes that you have the GWT Maven Plugin.

In Eclipse, choose File -> New -> Other and select a wizard, and select "Maven Project"



Here do nothing. Just press "Next"


Type in "gwt" and select the "gwt-maven-plugin" Artifact id.


Enter the appropriate archetype parameters. Here: org.wmmnpr and mykita


The new maven project should have the following structure.

To correct the project errors modify the"pom.xml". In this example the gwt.version, maven.compiler.source and maven.compiler.target had to be set to 2.6.0, 1.7 and 1.7 respectively. Also embedd the build.plugin XML element within a pluginManagement element as follows:

 <build>
    <outputDirectory>war/WEB-INF/classes</outputDirectory>
    <pluginManagement>
    <plugins>
.
.
    </plugins>
    </pluginManagement>
Run from the context menu: Maven->Update Project ...



The error should disappear.

From the context menu, select "Run As" -> "Run Configurations..."

In "Goals" type "gwt:compile"


If the following error occurs, then
[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:1.2.jboss:compile (default-cli) on project mykita: Execution default-cli of goal org.codehaus.mojo:gwt-maven-plugin:1.2.jboss:compile failed: A required class was missing while executing org.codehaus.mojo:gwt-maven-plugin:1.2.jboss:compile: org/codehaus/plexus/util/xml/XmlStreamReader

Change the version of the gwt-maven-plugin to 2.6.0 and run it again.

        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.6.0</version>

In the "Run Configuration" set-up, change the goal to gwt:run and press the "Run" button.



Here, select "Launch Default Browser" to see the application.


Wednesday, April 2, 2014

Spring IoC and PropertyEditors

Built-in PropertyEditor implementations

Spring IoC uses the concept of PropertyEditors to effect the conversion between an Object and a String. Below is a properties file containing values, which exist as strings and a Bean, which will be injected with the values.

/********* properties file begin  ***********/

threadPoolTaskExecutor.maxPoolSize=10
threadPoolTaskExecutor.running=true

/********* properties file end***********/

In a Bean, I have the following:
/********* bean begin  ***********/
    private Boolean running;

    public Boolean isRunning() {
        return running;
    }

    @Value("${threadPoolTaskExecutor.running}")
    public void setRunning(Boolean running) {
        this.running = running;
    }
/********* bean end ***********/

To convert the "running" attribute from a String to a Boolean Spring uses by default its CustomBooleanEditor class. To allow more elaborate conversion one can  register additional custom PropertyEditors describe in the spring reference manual. Below is summary of the possibilities taken from the manual.

When setting bean properties as a string value, a Spring IoC container ultimately uses standard JavaBeans PropertyEditors to convert these Strings to the complex type of the property. Spring preregisters a number of custom PropertyEditors (for example, to convert a classname expressed as a string into a real Class object). Additionally, Java's standard JavaBeans PropertyEditor lookup mechanism allows a PropertyEditor for a class simply to be named appropriately and placed in the same package as the class it provides support for, to be found automatically.

If there is a need to register other custom PropertyEditors, there are several mechanisms available. The most manual approach, which is not normally convenient or recommended, is to simply use the registerCustomEditor() method of the ConfigurableBeanFactory interface, assuming you have a BeanFactory reference. Another, slightly more convenient, mechanism is to use a special bean factory post-processor called CustomEditorConfigurer. Although bean factory post-processors can be used with BeanFactory implementations, the CustomEditorConfigurer has a nested property setup, so it is strongly recommended that it is used with the ApplicationContext, where