Archive for January 2014

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 🙂