Archive

Archive for the ‘software development’ Category

Jackrabbit with Spring

No Gravatar

I was searching for a way to use Jackrabbit with Spring. There are articles about this topic, but each of them suggests using spring-modules. Now, my problem with spring-modules jcr implementation is, that they depend on non-released or obsolete 3rd party JARs, like apravez.* and jeceira. Just take a look at the pom file, and you’ll see.

On the other hand I do not feel a need for jcrTemplate, jcrCallback or any other ORM flavor helpers. I just need a nice, easy integration of Jackrabbit, where I can easily inject JCR Session into any class with spring.

The JNDI way would do, but I do not want to use JNDI, I want to configure Jackrabbit from my spring beans.

Now with those premises, I came out with a quite easy setup, that follows below.

Spring configuration:



  
    
    
  

  
    
      
    
  

  
  

The configuration of Jackrabbit is defined in repository.xml file, – I just took the default repository.xml, the one that is created when running TransientReposiotry for the first time. Of course for better integration and configuration define your own.

There is one more configuration point and that could be seen in the XML from above. Spring bean jcrConfiguration defines where the repository.xml configuration is and the path to repository resources, – the second argument. For test purpose I just used /tmp/repository but for production you might set it to something like: repository

Do not forget to set up spring RequestContextListener or you’ll be missing session (and request) scope in spring configurations. In web.xml just define a listener:



  org.springframework.web.context.request.RequestContextListener

From code we’ll just going to use the jcrSession. Here is a small example for usage:

@Service
public class TopicService implements BeanFactoryAware {

  private BeanFactory beanFactory;

  public Session getJcrSession() {
    Session jcrSession =
	  (Session) beanFactory.getBean("jcrSession");
    return jcrSession;
  }

  @Override
  public void setBeanFactory(BeanFactory beanFactory)
      throws BeansException
  {
    this.beanFactory = beanFactory;
  }

  public void myFucntion() {
    Session session = getJcrSession();

    // here you do what you would do with JCR...
  }
}

As my service is singleton I inject Spring Bean Factory with the help of org.springframework.beans.factory.BeanFactoryAware mixin, so each time I call getJcrSession() I get a JCR session bind to HTTP session.

Well, that’s it. A simple configuration, easy usage.

Share

Ubuntu guy in a world of Apples… Part IV: Java Developer

No Gravatar

After a lot of work and some traveling I’m back, and I’m about to write about how do I manage to use Mac for Java development. (Note: This is the last part of the Apple Project series.)

First of all, let me describe what I use and how do I/we use it.

Eclipse is our choice of IDE. We use Subversion as SCM, Maven as a build system/dependency management/reporting/documentation/etc.. Beside these we use, (just to mention few that could be in relation with OS):

  • AspectJ
  • Spring
  • Hibernate for JPA
  • TestNG

Primarily we are building web applications, backed with RDBMS – so I need a some local database for my Mac, and our choice of RDBMS is PostgreSQL, but we use Oracle and DB2 as well.

Read more…

Share

Subversive with JavaHl under Ubuntu

No Gravatar

Eclipse SVN plugin Subverisve comes with javaHl support for windows, but not for linux.

Under linux you could use SVNKit, but that is somewhat slower, and a bit buggy. That is an out-of-box solution. But you could use javaHl JNI svn client too.

Read more…

Share

Bye, bye P2! Hello UM again!

No Gravatar

Had enough. P2 gave me just too much headache.

Today I removed P2 from my two production Eclipse installation. What a relief…

Update Manager (UM) works fine, as it worked in 3.3. Installed AJDT, Q4E, SpringIDE, TestNG, AnyEdit, … without any issue.

At my last few tries, I managed to install AJDT successfully, but after it I locked myself out. At next install P2 were missing AspectJ feature, and were willing to do nothing.

I read somewhere that P2 will not let you install uninstallable or wrong software… well… no comment.

I still beleave P2 is “not an evil”, and it will turn out to be great. But now I think it came in to suddenly and with lot of missing features/bugs. – I know this is the best way to test it… :-) , and I usually happily volunteer in these kind of testings, but not arbitrarily.

Share

Eclipse P2 puzzle

No Gravatar

My frustration about Eclipse P2 from the last time grows…

I just wanted to add documentation for few plug-ins today. As usually those documentations are also plug-ins. P2 here we go…

Found the plug-ins in no time. Install…

And wait, wait, wait… (about 5-20 minutes!) while my eclipse is locked, as P2 is modal. Why? At least let me work while P2 figures out if those plug-ins would fit my installation.

Fortunately I can send the install part, – if everything is fine for P2, – to work in background, but that does not lasts so long usually.

As I learned so many times that things ain’t what they look like, I started to browse the Net (after 3h of cooldown). And I found a lot of pro and contra. There is even a recept how to replace P2 with UM.

Now as I retraced the whole thing one again, I can understand both parties. Developers are probably frustrated, while simple users are happy with it, – or at least will be…

I still do not feel P2 mature enough to replace UM (Update Manager), as there are missing features and obvious bugs.

Missing stuff:

  • Resolve dependencies automatically – there are a hell a lot of plug-ins, sometimes I just can’t gather myself what do I need. – You need to know the software you’re installing… – this is no good for simple users…
  • Show information about the plug-in and its dependencies. Instead of right click, properties…

I’m still frustrated, and I hope it is just because of the absence of the knowledge.

I still need to pull up my plug-ins for 3.4, so I’ll be learning soon… :-)

Share
Categories: eclipse, news, software development Tags: ,

Eclipse Ganymede and P2

No Gravatar

Yesterday Ganymede arrieved. Fresh new Eclipse 3.4 and a tons of plugins as usually.

Some nice new features, feels like a bit faster. But! P2, the new “update system”… grrr. Okay, the old one was bad, I know. But it did work. It took me usually about 30 minutes to assemble an eclipse-jee with AJDT, subversive, q4e, mylyn exts and to import some of my workspaces. Today, with Ganymede and P2 it took me about 4 hours. Ouch. And I still do not have AJDT, and no dependency viewer from q4e.

I hope this will stabilize, and that this will pay off…

Share

Change system time, to emulate… are you sure?!

No Gravatar

Just need to emulate how would an application work in 3 month, or after 2010, or whatever. Think twice before you just change your system time to test.

If you really need to do it, do it from within virtualization. Or…

Or you might face strange effects when you switch back to current time. Some applications depend on files last modified date. And some would check for biggest time ever, to protect them self from using  trial for ever…

In our case after switching back to normal time Eclipse WTP just stopped publishing to server… guess why… :-)

Share

Eclipse WTP Server start hangs… on Windows…

No Gravatar

We have a strange animal: A web application with really lots of jars. (Today total of 273 JARs.)

We use Maven 2, Eclipse with WTP, Tomcat, Q4E, etc.., but from these technologies only Eclipse, WTP and Tomcat are relevant for the problem I’d like to describe. Most of developer machines runs Windows XP, and some Windows 2000, and just few Linux.

As we use Maven 2, the jars came form ${user.home}/.m2/repository/ folder. We just let Q4E set up the path for our projects inside Eclipse. For some reason we stack with Q4E 0.3.0, and we tweaked the WTP Server (Tomcat) launch settings, to have all JARs included. We did not used “served modules without publishing”, nor “J2EE Module Dependencies” for few (here) non-relevant reasons.

After adding few new modules (JARs) to the webapp, for few developers the Tomcat Server just failed to start. No log, and nothing in the debug view, nor in the error view. Eclipse WTP were just waiting for Tomcat to start… forever… We were bitterly searching for solution/bug. With no luck. After adding even more JARs, even more developers were complaining: the same problem.

Read more…

Share

Weird Eclipse behaviour

No Gravatar

I use Eclipse as my primary IDE under Ubuntu Linux (now Hardy). IMHO it’s a great combination. Stable, fast, clean. But from time to time, as Eclipse evolves, and there are more and more plugins I use, I ran into strange erratic behaviour of Eclipse. First there were the nasty problem with PermGenSpece, and now this…

Read more…

Share

Maven 2.0.9 dependency import and Continuum 1.1

No Gravatar

We use Maven2 for developing our huge application, (and few smaller). We have almost 200 projects which depends on each other somehow. That’s why I really like Maven2. It was a nightmare to handle all those dependencies by hand, – as we did it before moving to Maven. Of course there are other great things about Maven, like reports, site and of course the release management. – OK, there is still an annoying bug with release plugin, ranges and snapshots, but we can live with it.

With the release of 2.0.9, we got a new powerful feature for handling dependency versions. The so called “Importing Dependencies” noted in release notes and described in the documentation and in wiki.

Read more…

Share