Dec 05 2012

Emerge kinfocenter-4.9.3 fails [Simple Solution]

Category: English posts,TechnicalIuliana @ 12:31

A few weeks ago I switched back to Linux at home, because the training for the Spring Certification exam ended (setting up the official working environment on Linux was a pain, that’s why I worked on Windows for a while). At home I have SolusOS, which takes care by himself of updates and stuff( I chose because it was more suited for a laptop). Switching back to Linux at home, made me fell like working on Linux at work too, so I remembered I had a VirtualBox machine with Gentoo on it. So I started it and begin updating it, because the poor thing was not used in a while, so this process was unavoidable.

I intended to run the basic command for updating a Gentoo system, as recommended on their official site:

# emerge --update --deep --newuse world
# emerge --depclean
# revdep-rebuild

Unfortunately it was not so easy, because I have stumbled across this problem. So kinfocenter-4.9.3 failed to compile and the problem was a missing library, obviously, but the log message was not very clear. I have to mention that when it comes to Linux I am not such a guru, so after trying the solution on the forum and failing miserably, I stared trying anything just to make this work.

The problem was obviously with the media-libs/mesa library. I had the 9.0 version installed already and as I figured from the forum topic kinfocenter-4.9.3 depended on mesa-8.0.4-r1. Apparently the solution was simple, just unmerge the current version and install the required one, the old one.  Which I did, meaning I unmerged mesa-9.0. And after doing that, I had an idea.

What  if I used revdep-rebuild? Because that’s what the manual says it does:

revdep-rebuild scans libraries and binaries for missing shared library
dependencies and attempts to fix them by re-emerging those broken bina-
ries and shared libraries. It is useful when an upgraded package
breaks other software packages that are dependent upon the upgraded
package.

And I used it. And it worked, kinfocenter-4.9.3 was installed successfully and is working fine with mesa 9.0 which was automatically installed by revdep-rebuild. :|  So my solution to fix this is made of two steps:

# emerge --unmerge media-libs/mesa
# revdep-rebuild

After revdep-rebuild finished I continued with the update of the system, and so far all is working great.

Sometimes it’s better not to be a guru in a specific domain, because it gives you the opportunity to find new and simple solutions.

Tags: , , , , ,


Nov 08 2012

Learning Spring, part VI

Category: TechnicalIuliana @ 15:44

This won’t be a post  about a problem or a question, but about an observation.

When I took the spring Core course in Belgrade this June, in the Chapter about data access the jdbcTemplate instance was created like this:
Java code:

//random DAO class
private JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);
}

Xml configuration:

<bean id="dataSource" class="..." />

After that I read Spring in Action, then the Spring reference and everywhere when given an example on how to use jdbcTemplate, the instance was created and injected like that.

And I am confused. If jdbcTemplate instance is thread-safe once configured, is recommended to not create one for each use and is stateless (does not maintain any conversational state) why don’t we just create it as a singleton bean and use it as such?
Sample of my code:

//random DAO class
private JdbcTemplate jdbcTemplate;
@Autowired
@Qualifier("jdbcTemplate")
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
    this.jdbcTemplate = jdbcTemplate;
}

Xml configuration:

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
   <constructor-arg ref="dataSource" />
</bean>

Tags: ,


Nov 06 2012

Learning Spring, part V

Category: TechnicalIuliana @ 10:37

<ref local=””/> vs. <ref bean=””/>

So here is the conclusion of this post, which was debated with my friend MARIANUL also.

The only difference between the two is syntax and  behaviour at application design time, when each of them helps you , the developer, in its own way, to figure out if the references are valid or not. At run time, there is no difference: all beans are created and reside in the same application context so the references are correctly solved.

So yeah, this is it. Simple as that. So ignore all the blog posts where you are told that code does not compile because of XML parser errors and if you doubt my findings too, dare to test and draw your own conclusions. This is what I did. :)

Tags: , , ,


Nov 05 2012

Learning Spring, part IV

Category: TechnicalIuliana @ 13:05

<ref local=””/> vs. <ref bean=””/>

So, when should we use one or the other and why?

First, I’ll offer you a link to the official Spring reference documentation related to this subject.  Basically:

Specifying the target bean through the bean attribute of the tag is the most general form, and allows creation of a reference to any bean in the same container or parent container, regardless of whether it is in the same XML file. The value of the bean attribute may be the same as the id attribute of the target bean, or as one of the values in the name attribute of the target bean.

And:

Specifying the target bean through the local attribute leverages the ability of the XML parser to validate XML id references within the same file. The value of the local attribute must be the same as the id attribute of the target bean. The XML parser issues an error if no matching element is found in the same file. As such, using the local variant is the best choice (in order to know about errors as early as possible) if the target bean is in the same XML file.

Then we will play with some source code.
Continue reading “Learning Spring, part IV”

Tags:


Oct 13 2012

Learning Spring, part III

Category: TechnicalIuliana @ 18:15

I have a new hot question for you:

We have two classes AccountServiceImpl and ClientServiceImpl. Any of these classes inherits from each other, meaning one is a subclass of the other. What will happen if we define a pointcut like this:

"execution( * *..AccountServiceImpl.update(..)) 
       && execution( * *..ClientServiceImpl.update(..)) "

And here are your options:

  1. The pointcut matches any public update methods of the two classes whatever the arguments.
  2. The pointcut matches any update methods of the 2 classes whatever the arguments and the method visibility.
  3. The pointcut matches any update methods of the two classes, with one ore more arguments and whatever the method visibility.
  4. No join point is defined.
  5. Something else will happen.

Continue reading “Learning Spring, part III”

Tags: ,


Oct 10 2012

Learning Spring, part II

Category: TechnicalIuliana @ 17:02

One of the reasons I haven’t taken SCJP yet was the stupidity of the grammar in the construction of some questions and answers on the exam.(I have given examples in the past on this blog, search a little if you are curious)  Currently I am to take the Spring Core Certification exam and  and I am terrified that I will find the same kind of questions and answers in it.  And the worst part is that there are not that many mock exam samples on the internet, so I have no chance to get used to the specific style.

For example:

In Spring Framework’s declarative transaction implementation , is it sufficient to annotate the classes with the @Transactional annotation ?
Select Your Answer :

  1. No
  2. Yes
  3. No . <tx:annotation -driven/> has to be added in configuration file

You might be inclined to say that the correct answer is 3, Continue reading “Learning Spring, part II”

Tags:


Sep 15 2012

Learning Spring

Category: English posts,TechnicalIuliana @ 23:47

A few months ago the company where I am currently employed sent me to Belgrad to train me in Spring Core. The training lasted 4 days and at the end I was supposed to take the Spring Core certification exam and pass it.

I delayed that for a while, but because now I have some spare time I decided it was time for me to do this thing. So I went over the slides and the spring code samples again. But after doing some mock tests I concluded I will most likely fail the certification, because the official materials were not enough so I started reading Spring in Action. Still I noticed that in the tests there was still stuff that I hadn’t covered. So I started reading Spring Reference. And because I have some problems in retaining information just by reading it, I stared to test the recommended examples. And this is where I hit some walls.

But before telling you what is not clear for me I shall tell you what technologies I’m using for development: Maven 3.0.0, Jdk 1.7, Intellij Idea 11.1.3 and Spring 3.1.2 (I know the certification is for 3.0, but as the Spring reference manual has 840 pages, I might as well read about the new and useful stuff added in 3.1)

The first problem I had was with the compound property names. I tried using them. Idea does not recognize them and my test fails.

Continue reading “Learning Spring”

Tags: ,