Autocomplete not working in Netbeans – 8.0.2

with 2 comments

  • Delete everything in the cache directory of netbeans
     rm -rf ~/.cache/netbeans/8.0.2/*
  • Restart Netbeans


Written by thangaveluaishwarya

April 4, 2015 at 11:05 PM

Posted in Uncategorized

Unsatisfied Dependency Exception : CDI 1.1 + Bean Validation + GlassFish 4.0 -> requires jersey-gf-cdi.jar upgrade

with one comment

Recently,  I faced Unsatisfied Dependency Exception, when trying to integrate BeanValidation with CDI 1.1 . Independently (without integration) everything worked fine. Looks like, the present Glassfish version 4.0 doesn’t support CDI 1.1 + Bean Validation together.

To be still clearer, Jersey (reference implementation for JAX-RS)  jar related to CDI  i.e., jersey-gf-cdi.jar in GF-4.0 version, is not supporting this integration .

I made the below changes, for Bean Validation integration with CDI 1.1 in Glassfish 4.0 to work.

Applicaiton Server used : Glassfish 4.0

Technology : JEE-7, CDI 1.1

Exception Trace :

org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=Foo,parent=Foo,qualifiers={@foo()}),position=-1,optional=false,self=false,unqualified=null,350112977)

at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(
at org.jvnet.hk2.internal.Utilities.justInject(
at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(
at org.jboss.weld.bean.ManagedBean.create(
at org.jboss.weld.context.unbound.DependentContextImpl.get(


Solution :

  • Download jersey-gf-cdi-2.0.jar . Download specifically 2.0 version for glassfish4.0. If other higher versions 2.10 are used, incompatibilty with other jars (firstly with jersey-server.jar) will arise.

  • Rename the jar to jersey-gf-cdi.jar
  • Replace it in glassfish4.0/glassfish/modules/
  • Delete osgi-cache folder -> Path : glassfish4.0/glassfish/domains/domain1/osgi-cache
  • Refresh and restart glassfish. New osgi-cache will be created in domain 1 with the latest jersey-gf-cdi.jar. Problem will be solved 🙂

This issue will be resolved in Glassfish-4.0.1 version (not released yet). We’ll have to do the above till GF-4.0.1 is released.

Have a great day 🙂

Reference :

CDI – Lifecycle Management by Container

with 3 comments

We know that, CDI Managed Beans are contextual. Their lifecycle management is done by the container. One of its main advantages is type-safe dependency injection.

But how does it do it?
In the below code, during application initialization process, the container checks for Type-Safe Resolution for News bean annotated with @Inject and then instantiates it.


Here the container checks ,

  • if the bean type is equal to the required type(type: News here) at the injection point in Consumer Bean class.
  • if the qualifier of bean is equal to the required qualifier at the injection point.
  • (If no qualifier specified , then default qualifier is @Default)

public class News {
  public String getLatestNews(){
    return "FIFA 2014 WorldCup";

@Path(value = "consumer")
public class Consumer {

  private News news;

  public String tweetLatestNews(){
    return news.getLatestNews();

Any mismatch will result in unsatisfied or ambiguous dependency problem.




New DelegatingScript Base Class – Groovy 2.2 feature

leave a comment »

Script base class of Compiler Configuration can be customized.
Delegating Script Base Class helps to delegate the calls in a script to a class that has DSL methods/functions & variables.

import org.codehaus.groovy.control.CompilerConfiguration

def scriptInfo='''
        model="Nexus 5"

class MobileDealer{
    String model
    void getModel(){
        println "Mobile : $model"

def compilerConfig=new CompilerConfiguration()
def shell=new GroovyShell(compilerConfig)
def script=shell.parse(scriptInfo)
MobileDealer m=new MobileDealer()
  • Line 1 – import package of Compiler Configuration class
  • Line 3-6 has the script where the delegate is set and is run finally.
  • Line 8-13 has the class declaration of the delegate class MobileDealer. The methods and variables in this class can be reused commonly in scripts.
  • Line 15new instance of compiler configuration is created
  • Line 16DelegatingScript is set as the base class for that particular compilerConfiguration instance
  • Line 17-new groovyShell instance is created with the present compiler Configuration
  • Line 18-The above “scriptInfo” is parsed to DelegatingScript type
  • Line 20-MobileDealer class is set as delegate in the script.
  • Line 21-the script is run.


Written by thangaveluaishwarya

February 14, 2014 at 12:32 PM

Groovy-2.X tidbits

leave a comment »

Did you know …?

1.We can know the last element of an array by using -1 as the index
def a=[1,2,3,4,5,6,7]
assert a[-1]==7

2.Groovy is much like an English speaking language
Eg :   for loop
Earlier in Java,

for(int i=1;i<=10;i++){

*NOTE: Now that Java 8 has introduced Instream for loop with range.

In Groovy,

 println 'Groovy'

3.Default access specifiers

  • for Class -> public
  • for Method -> public
  • for variables -> private

4.Groovy generates 2 constructors implicitly
(1) a public constructor
(2) a public constructor where its class variables can be passed as parameters.

5.Values in the constructor can be assgined via Implicit coersion and Explicit coersion too

class Season{
def type
def month

//Normal way
def s1=new Season(type:"winter",month:"December")

//Implicit coersion - pre-defining the type of variable.
Season s3=[type:"autumn",month:"September"]

//Explicit coersion using 'as'
def s2=[type:"summer",month:"May"] as Season

6.Underscores can be used in number literals for better understanding

long creditCardNumber=1234_2345_3456_4567L

Advancements in languages is happening day by day.
Groovy beta version has come up with advanced features like Delegating scripts, TypeChecking Extensions in Script, project coin(present in Java7) and etc.,However Java 8 is also coming up with much advanced features.

We should bear in mind that language should be only the means to make things simpler.
It’s wise to choose the right one based on our needs.

Written by thangaveluaishwarya

February 9, 2014 at 2:46 PM

Problems faced with Ubuntu 12.04 LTS in Lenovo Z580: Black/Purple Screen + OverHeat + Hanging of system and returning to Login Screen.

with 5 comments


  • Lenovo Z580
  • Ubuntu 12.04 LTS

PROBLEM 1: Black Screen recurrence and OverHeat generation in machine
Many a time, my machine got hanged and produced black/purple screen.After that I had to forcefully shutdown and restart the machine.

For this, I made changes in the grub file as below,

To go to the grub file —> gksudo gedit /etc/default/grub

grub file:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX="noapic, nolapic"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)

# Uncomment to disable graphical terminal (grub-pc only)

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux

# Uncomment to disable generation of recovery mode menu entries

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

Then in the terminal run,

sudo update-grub

PROBLEM 2: System getting stuck and returning to login screen:

After resolving the black screen problem, system still faced the problem of getting stuck while working on something and when I pressed Ctrl+Alt+Del, after sometime it took me to a command screen which said ,

could not write bytes: broken pipe.
checking battery state.

and then to the login screen.Now when I logged in, the programs, that I was working on, where closed without saving.

If this is what, even you are facing, then below is the solution for it.

It might be due to,

1. Mimatch of the nvidia version when we installed Ubuntu with that of the version getting updated.This mismatch in version doesn’t compatibilize with eachother and causes screen hanging.
For this, use the below commands

sudo apt-get purge nvidia-*

Here we purge nvidia instead of removing it.

  • PURGE: ‘purge’ removes nvidia completely from your machine including the configuration files.
  • REMOVE: ‘remove‘ removes the software but not the configuration files.
sudo apt-get install nvidia-current-updates

Above command does a fresh new installation of the latest nvidia onto your system.

2. Also check that Ubuntu 12.04 uses ldm and not gdm because it is said Ubuntu 12.04 uses lightdm(ldm) as its display manager.
For changing, exhibit the following commands,

sudo apt-get install lightdm
sudo dpkg-reconfigure lightdm
sudo stop gdm
sudo start ldm

Now Restart your system and it should work fine without getting stuck.

Any Driver Problems:
When you install Ubuntu from your USB card/CD, it doesn’t give you third party software in readymade Eg: Wifi-Drivers , Bluetooth Drivers etc.,

For this ,you should either carry out your installation with Internet on, so that latest packages will also be updated
When u install Ubuntu in your machine without Internet, you have to manually install the driver packages.

Have a great day 🙂

EJB class able to render REST WebService via Annotation

with 3 comments

Advancements in Java, especially the advent of JEE6 and JEE7  has eased the way we code.
Deployment descriptors for Servlet classes, Entity classes, Web Services are being replaced by annotations, thus advancing towards the concept of Convention over Configuration.

Below is a simple example on how to make a Session Bean class provide a RESTful WebService using annotations.

Here I have used JEE 7 and GlassFish 4 Application Server.
Note: As of now, JEE7 is  compatible only with GlassFish 4.

Here I have considered WebsterPublications example which has,

  •  DictionaryEntity – Entity class
  •  DictionaryResource – EJB+REST Service Provider Class

STEP 1: Create

@Table(name = "WP_DICTIONARY")
public class DictionaryEntity {

    private Long id;

    @NotNull(message = "Enter a word")
    private String word;

    @NotNull(message = "Enter the word's meaning")
    private String meaning;

    //Getters , Setters

Attributes can be annotated with constraints like @NotNull, @Pattern and can be made to through message during runtime, when violations occur.

STEP 2: Create

@Path(value = "dictionary")
public class DictionaryResource {

    @PersistenceContext(unitName = "webster")
    private EntityManager em;

    @Path(value = "wordlist")
    public List<DictionaryEntity> getWordList(){
        Query query=em.createQuery("select d from DictionaryEntity d");
        List<DictionaryEntity> wordList=query.getResultList();
        return wordList;

Here we can notice that this class apart from acting as a Stateless Bean also provides a RESTful WebService.
i.e., stateless session bean class providing the output object via REST WebService (Here JSON object got as Output).

Mapping the persistence unit and connection pooling in glassfish server is done (default Derby DB used).

STEP 3: Create

Since DictionaryResource acts like a Servlet by providing WebService, it’s essential to provide its entry in web.xml.
But this can also be done through annotation even.

WebsterRESTConfig class is created that extends Application and adds DictionaryResource as its resource class.Like DictionaryResource various other resource class can also be added."webresources")
public class WebsterRESTConfig extends Application {

    public Set<Class<?>> getClasses() {
        Set<Class<?>> resources = new java.util.HashSet<>();
        return resources;

   private void addRestResourceClasses(Set<Class<?>> resources) {

Here @ApplicationPath is equivalent to the servlet-mapping URL-Pattern that we would specify in web.xml.

Also note, while instantiating Set<Class<?>> resources = new java.util.HashSet<>(); I haven’t used generics in HashSet<> but have just used a plane Diamond notation. This is one of the light-weight changes in Java SE 7.

Now when we give the path as:


The result is obtained as below.


In my this post I wanted to highlight on the concept of Convention Over Configuration which is taking a great leap as the advancements in JEE versions are happening.Without even taking the pain to write the conventional web.xml deployment descriptor, we are now that able to  configure those settings by using simple annotations at the right place.

You can find the above source code in my GitHub repository. 

I wish you all a BLASTFUL 2014 🙂