[SOLVED] Hangs while Configuring CLASSPATH

Posted by Anantha Narayanan On 11:15 AM

I had created a new app in grails, and my colleague was trying to access this app after copying this folder to his local machine. Our environments were setup as follows:

GRAILS Version - 2.4.0
GROOVY Version - 2.3.3
JAVA Version - 1.8

Both of our environments matched. When he created a fresh application, grails created the application, however he was not able to run the application. The same was case with the copied application.

After 5 odd minutes the error was thrown into the screen:

C:\MyTrainigs\GroovyApp\test123>grails
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=32m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; sup
| Configuring classpath
| Error Resolve error obtaining dependencies: Failed to read artifact descriptor for xalan erializer:jar:2.7.1 (Use --stacktrace to see the full trace)
| Error Required Grails build dependencies were not found. This is normally due to internet connectivity issues (such as a misconfigured proxy) or missing repositories in grails-app/conf/BuildConfig.groovy. Please verify your configuration to continue.


Only then we realized that this is internet access issue as grails pointed out. We were both accessing the application from corporate network, through internet proxy. The my colleague tried to access internet through data card and it worked. He was able to execute the application.

So if you have tried all other resolutions and if it has not worked, setup your proxy in startGrails.bat and it will work.

The example for setting up this is as below:
set JAVA_OPTS=%JAVA_OPTS% -Dhttps.proxyHost=yourproxyserver -Dhttps.proxyPort=proxyport

Let me know if this works for you.

Rounding off decimal value in Groovy

Posted by Anantha Narayanan On 9:56 PM

I am new to groovy language, so assume its going to be bare basic.

By default you have an object defined in groovy like follows:

groovy> def number=12.11 
groovy> println number.round(2) 

Exception thrown

groovy.lang.MissingMethodException: No signature of method: java.math.BigDecimal.round() is applicable for argument types: (java.lang.Integer) values: [2]
Possible solutions: round(java.math.MathContext), find(), pow(int), and(java.lang.Number), power(java.lang.Integer), mod(java.lang.Number)

I was searching in google for identifying the issue, but could not resolve it. Later only I realized that round() is available in double in groovy. I then explicitly converted the variable to double using toDouble() method and chained the round() method to it. It solved my problem.

groovy> def number=12.11 
groovy> println number.getClass()
groovy> println number.toDoublt().getClass()
groovy> println number.toDouble().round(2) 

class java.lang.Double
class java.math.BigDecimal
12.11

So it is evident that the method round() is not available to BigDecimal whereas it is available to Double.

So how can I round off a BigDecimal? Waiting for the answer.

Playing video files in HTML5

Posted by Anantha Narayanan On 12:53 PM

Section 3: How to play video files in HTML5

The sweetest and simplest way to play video files is HTML5.

<video src="videofile.ogg" autoplay poster="posterimage.jpg">
  Sorry, your browser doesn't support embedded videos, 
  but don't worry, you can <a href="videofile.ogg">download 
  it</a>and watch it with your favorite video player!
</video>

Arriving upon a video format and a codec is the complex part of playing a video file. Refer the browser compatibility in MDN before you use this.

Note: the source you are using in src need not be from same server where html5 is residing. This means that you can embed videos from YouTube inside your webpages using this same tag. The advantage is that you can put more controls on your webpage by using JavaScript.

Playing audio files in HTML5

Posted by Anantha Narayanan On 12:38 PM

Section 3: How to play audio files in HTML5

The sweetest and simplest way to play audio files is HTML5. You will agree with me after seeing the following code:

<audio src="audiotest.ogg" autoplay>
  Your browser does not support the <code>audio</code> element.
</audio>

Was I right in guessing your reaction?

The only point you must know while playing audio files within browsers is that there is no ONE format of audio compatible with all browsers out there. So what is the option? You must encode your audio files to at least two formats, OGG and MP3. For a full list of browser compatible audio file formats refer this link in MDN.

But for now, you will be safe if you had OGG and MP3. The mechanism is called as fallback, where the browser reads the first format, and if it can play it will play. Otherwise it will move on to the next one and play the second one.

<audio controls autobuffer>
  <source src="sample.mp3"/>
  <source src="sample.ogg"/>
</audio>

What has been done in the latest example is to move the src of <audio> tag separately as a new tag within <audio> called the <source>. You can define different formats of the same file, and the browser just plays the one format which it can read. Even if the browser can understand multiple formats, it just settles and plays the first one it can understand.

Sweet new tags in HTML5

Posted by Anantha Narayanan On 12:24 PM

Section 2: Sweet, I have new tags

While HTML5 is not always about introducing new tags, its there. Its just not added newly because they had to, but they really help identify the content you are going to put in the webpage.

Before understanding new tags which are introduced, we will understand the meaningless nature of <div> tags. A div tag is used only to stuff contents together, and later style it using stylesheets (CSS). Consider the following example:

<div id="navigation">
  some navigation links
</div>

Well do you consider the following or above to be simple enough to understand?

<nav>
  some navigation links
</nav>

It makes sense to write less code and which is intelligible for humans. After all humans write HTML.

For a full list of tags available in HTML5 check this link in MDN.

Previous Section Next Section

Starting with HTML5

Posted by Anantha Narayanan On 12:22 PM

Section 1: HTML5 basics

What is the point of learning Grails (or any other web framework) if you don't know basic HTML. In this age of HTML5, I am starting to learn HTML5 the old fashioned way, self-learning.

I will be sharing my learning to all those who want it. This is really basic stuff.

The following is the simplest of simple valid HTML5 page you will create yourself.

<!DOCTYPE html>
<title>Hello World</title>
<h1>My first HTML5 Document</h1>

Yes, you heard it right, you don't need a <head> or <body> etc. tags to call your document a valid HTML5 document. The browsers now-a-days (except IE) are smart enough to identify that <title> is the title of the document, and <h1> has to be printed within the body.

If you doubt that the above code is not a valid HTML5, be my guest and copy the code and paste it in the validator. http://validator.w3.org/#validate_by_input

This is the first thing you must know about HTML5.

Next Section

Recommended Post Slide Out For Blogger