Saturday, November 26, 2011

Maven Dependency (MVN) for Oracle 11g

mvn install:install-file -Dfile=/u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar -Dpackaging=jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0

<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>

Wednesday, November 16, 2011

Ant Error: Error starting modern compiler

I setup an eclipse project in myeclipse for spring and I received the following error when trying to build the spring core project using Ant build:

Buildfile: C:\Projects\ProjectName\projectSpringCore\build.xml

compile:

    [mkdir] Created dir: C:\Projects\ProjectName\projectSpringCore\build

     [copy] Copying 20 files to C:\Projects\ProjectName\projectSpringCore\build

    [javac] Compiling 17 source files to C:\Projects\ProjectName\projectSpringCore\build

BUILD FAILED

C:\Projects\ProjectName\projectSpringCore\build.xml:25: Error starting modern compiler

Total time: 285 milliseconds

After some searching

http://www.myeclipseide.com/index.php?name=PNphpBB2&file=viewtopic&t=17956

This can arise for different reasons – though generally these reasons are all related – the version of Java being used by the Ant compiler in IDE does not match that already and referred to in JAVA_HOME.

image

To solve this in Eclipse, Go to Run > External Tools > External Tools Configurations > JRE

Select Separate JRE and match that with the one selected as JAVA_HOME.

image

You can verify the selected Java is the same using the Installed JREs tab

image

Monday, November 14, 2011

Using message.properties instead of message_en.properties

If you get the following error on using getMessages method:-
.getMessage("check.name", null, locale); 

org.springframework.context.NoSuchMessageException: No message found under code 'check.name' for locale 'en_US'.
org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:135)
    com.tauck.spring.HomeController.home(HomeController.java:41)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:592)

    
   
You need to change the following line in servlet-contxt.xml file

<beans:bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">    
        <beans:property name="basename" value="classpath:com.mycompany.util.messages" />    
</beans:bean>  


to



<beans:bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">    
        <beans:property name="basename" value="com/mycompany/util/messages" />  
</beans:bean>