SVN integration to Eclipse setup and error – unable to load default svn client

-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.200.v20090520
-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
256m
-vmargs
-Djava.library.path=/usr/share/java/
-Djava.library.path=/usr/lib/jni/
-Xms128m
-Xmx512m
-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins

http://subclipse.tigris.org/update_1.6.x – depends on what eclipse you have – check this for compatibility. how do i know what version i have.

sudo apt-get install libsvn-java

default path /usr/lib/eclipse/eclipse.ini

http://ubuntuforums.org/showthread.php?t=916633

One of prevailing repository tools is SVN. I like and use it. I am also a fun of eclipse. The two would make programming cool.

To install SVN in eclipse

Go to http://subclipse.tigris.org/ and see the download and install link. Check which to install based on the Eclipse version – which is depicted on the page.

Install JavaHL

From your command line in Linux: sudo apt-get install libsvn-java.
This is the major factor for the unable to load default svn client error.

Finally

Update your eclipse.ini by adding this line just next to -vmargs at the end
-Djava.library.path=/usr/share/java/
-Djava.library.path=/usr/lib/jni

The location of eclipse.ini would be in your installation folder. The default location for eclipse which loaded from package would be /usr/lib/eclipse/eclipse.ini

Now, restart your Eclipse and enjoy SVNing.

Adding multiple javascript files to page

I was pulling my hair just for some silly stuff. All I wanted was to put two external javascript file for my floundering page – that was it!! and I do it as

<script language="javascript" src="sourceone" />
<script language="javascript" src="sourcetwo" />

BTW, I am using firefox on ubuntu, then when I try to run the page it would turn white. Astonishingly, the kick for the error was

<script language="javascript" src="sourceone"></script>
<script language="javascript" src="sourcetwo" ></script>

Showing error message on selectOneMenu while selecting default

So, we have a menu, brimmed with our objects from list/database. The intention would be creating a default “Select” kind of the first row and to brag on the user when s/he selects the default.

The trick is simple, create the first list with null object and label it as Select. Lets show it with simple example.
We want to have a list of programming languages on our select menu. And, the first would be a default object.

    //Actual domain class
    class Language{
        private String name;
        private String type;
        private boolan isCompiled;

       getters/setters goes here
   }
   //Bean class
   class someBean{
        private List languages;
        .
        .
        public String getLanguages(){
            //Let languages would be filled by some service or factory
            this.languages = someLanguageFactory.getAllLanguages(); 
           //Assign the first element as null
           this.languages.add(0, null);
       }
   }
   
   //JSF page
   :
   :
   <h:selectOneMenu id="selectLanguage" value="someBean.languages" 
     requred="true" ....

This should do the task, make the list required, and populate the first list null. So, during validation if the selection is null it would be rejected as we have told it to watch an eye on blank fields.

datatable/component not updated after deleting and adding new one

During working on tabular data, it is common to have edit and delete command buttons for each row.

And, after we update or delete we want the table to be updated. Let’s looks some simple example.

The table on the JSF might look like


<form id="tablularForm">
<h:datatable id="tabularData" value="#{someBean.list}"
binding="#{someBean.htmlDataTable}" var="data">
<h:column>
<h:outputText id="colum1" value="#{data.column}" />
</h:column>
<h:column>
<h:CommandLink id="edit" value="Edit" action="#{someBean.editAction}" reRender="tabularData"/>
</h:column>
<h:column>
<h:CommandLink id="delete" value="Delete" action="#{someBean.deleteAction}" reRender="tabularData"/>
</h:column>
</h:datatable>
<h:CommandButton id="add" value="add" action="#{someBean.addAction}" />
</h:form>

The above ideal table would work fine.

The datatable would store values by reading from bean and would be updated on Edit and Delete actions accordingly.

This is b/c of the reRender attribute of the components.

The glitch comes when there is no any data in the table. Say you daleted all the data and you want to add a new one.

Or it is the brand new table to be added.

The row would be added but it wont be shown on the table. In short the table would not be updated.

The thing is when we use reRender, we have to use the enclosing component not the component to be safe!.

When it tries to rerender if the component was not there initially, it wont rerender it.
So, here we can use the id of the form for rerendering the datatable and we would be OK.

See why jsf apps are slow in cases

test

Wanted but not invoked: However, there were other interactions with this mock: ->

Wanted but not Invoked Error in mockito and its solution

This happens with mockito when trying to verify the invocation on an object with specific method.

But what happens is you have interacted with other method of that object but not the one mentioned.

If you have an object named CustomerService and say it has two methods named saveCustomer() and verifyExistingCustomer()

And mockito looks something like

verify(customerService, atleast(1)).verifyExistingCustomer(customer), 

But in your actual service you called the saveCustomer() at least once.. BINGO you would get that error.

Also Recommended for you

See how you can get started with mockito with simple example

Do you like Algorithms?

Find K complementary numbers from given array

Can you form the longest palindrome from the given random characters?

eraser

deleted object would be re-saved by cascade (remove deleted object from associations):

Kind of oxymoron ha?!.

You try to delete but you are told it would be re-saved.

Actually it is a safe guard by hibernate that this action is meaningless unless you do the actual stuff.

Two things to check:

  • make sure any collection that holds the object is cleared before deleting the object
  • Clear the child object from the parent object before deleting the child if you have cascade="all"

See also Why jsf applications get slow when using a jpa connection

Learn How to add unicode characters to database from hibernate application

Action in bean is never triggered/called from jsf page

One plus side of the compiled languages would be telling us every error during/after compilation which would save a lot time from chicanery. But, in JSF you may get unexpected error which is a silent.

The page would run and the action linked to, say command button or command link, may not be triggered.

If you got that, just check your form fields – especially if you are working with datatable, make sure all the conversion and validations are working as expected. If the validation/conversion is not working properly, then the framework would exit before reaching the backend.

One way to troubleshoot this would be to have <h:messages /> with appropriate attributes, like adding showDetail=”false” showSummary=”true”, on your form – that, definitely, would help you to debug the problem.

JSF navigation error because of invalid path in faces config

javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)     at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)

A continuous and erratic error you would see on the console of this title might come across your JSF development once in a while.

Also you may see the browser is taking long while this error happens.

It has to do with navigation in the faces-config.xml file. in my case, I had forgotten to add the forward slash in front of my file – that is

   <navigation-case>
     <from-outcome>hint</from-outcome>
     <to-view-id>/index.jsp</to-view-id>
   </navigation-case>

The above is snippet from the faces-config.xml file. As you can see, the index.jsp file is without the forward slash – That was the problem

Happy JSFing.

java.lang.NoClassDefFoundError – javax/servlet/jsp/jstl/core/Config

A kind of friendly error that would bade a visit while working on JSF and Tomcat would be: java.lang.NoClassDefFoundError – javax/servlet/jsp/jstl/core/Config.

Thankfully, this has a very simple remedy of adding JSTL jars of standard.jar and jstl.jar.

You can get those jars from http://jakarta.apache.org/site/downloads/downloads_taglibs.html

Invocation of init method failed – hibernate exception of caching

While working with hibernate you might come up with this error, as I do :(
Fortunately, here is how to make your java happy:

On your hibernate.xml [ or maybe you might named it other ], there is a part describing property:

<property name="hibernateProperties">
 <props>
 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
 <prop key="hibernate.show_sql">true</prop>
 <prop key="hibernate.c3p0.minPoolSize">5</prop>
 <prop key="hibernate.c3p0.maxPoolSize">200</prop>
 <prop key="hibernate.c3p0.timeout">1800</prop>
 <prop key="hibernate.c3p0.max_statement">50</prop>
 <prop key="hibernate.generate_statistics">true</prop>
 <prop key="hibernate.cache.use_second_level_cache">true</prop>
 <prop key="hibernate.cache.use_query_cache">true</prop>
 <prop key="hibernate.cache.provider_class" >org.hibernate.cache.EhCacheProvider</prop>
 </props>
 </property>

The last two props are the ones we want to blame!!
One way to get rid of this problem would be by just making the values of those to false – hmm… would work but we would miss the capability of caching … Here is the next

Download the ehcache from this location and put it in your classpath.
Update the hibernate.xml file’s property section by adding the following:

<prop key="hibernate.cache.provider_class" >org.hibernate.cache.EhCacheProvider</prop>

Now you+java+hibernate+me HAPPY..
hope would help someone..