Some Trials & a lot of Errors

I tried a bunch of framework and other language and I usually feel overwhelm when its time to do something real with what I've learned. So that why I created this site, to write my progress and help some noob like me that stumble into the sames problems.

Browse: Page 2

SVN moving files lose history

By Chris on October 19, 2014

My coworker was moving files around in our SVN repo and we end up losing the history of the file. It seem it was because of our IDE (eclipse svn at the time), after some searching we manage to find a way to do it by using the svn command rename & move.

Doing everything by command line can be a nightmare if you are looking for a external tool Tortoise SVN should do the trick, it has the rename command and you can use Tortoise to repair the move operation.

The following will tell SVN that the new file is actually the renamed old one:

  1. Open the “Check for Modifications” Window.
  2. Mark both the old file name (listed as missing) and the new one (listed as unversioned)
  3. Right click this selection and chose “Repair Move”.

If you already lost the history on a file you really need, you can always resurrect the old file with svn copy. You “svn copy” the old version into its old place, merge the new file’s history into it then”svn move’’ this file to the new file name.

More info type:

svn help rename

in the command prompt.

Posted in prog | Tagged source control, svn | Leave a response

List Return a java.lang.UnsupportedOperationException when adding or removing a element

By Chris on October 12, 2014

While trying to remove a element after creating a List from a array using the Array.asList(array[]) method I’ve stumbled on that error.

java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:131)
at java.util.AbstractList.add(AbstractList.java:91)

Then I remember this, list created by the Arrays.asList method are immutable

Same goes for empty lists. So instead create a arraylist :

List<String> list = new ArrayList<String>(Arrays.asList(split));

Posted in java, prog | Tagged arraylist, java, java.util.List | Leave a response

JENKINS: How to fix a java.net.NoRouteToHostException.

By Chris on October 5, 2014

Our build server (jenkins) had that error

 

BUILD FAILED

com.jcraft.jsch.JSchException: java.net.NoRouteToHostException: No route to host

Full stack trace below if you really need it. I assume there was a problem with where Jenkins was deploying the apps or at a issue trying to run integration test on the remote server. After talking to IT it seem I was right. the server were Jenkins deploys the app was down (physically down). We had to restart it and then it worked fine.

Full stack :

BUILD FAILED

com.jcraft.jsch.JSchException: java.net.NoRouteToHostException: No route to host

at com.jcraft.jsch.Util.createSocket(Util.java:341)

at com.jcraft.jsch.Session.connect(Session.java:186)

at com.jcraft.jsch.Session.connect(Session.java:154)

at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:212)

at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:158)

at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)

at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)

at org.apache.tools.ant.Task.perform(Task.java:348)

at org.apache.tools.ant.Target.execute(Target.java:357)

at org.apache.tools.ant.Target.performTasks(Target.java:385)

at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)

at org.apache.tools.ant.Project.executeTarget(Project.java:1306)

at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)

at org.apache.tools.ant.Project.executeTargets(Project.java:1189)

at org.apache.tools.ant.Main.runBuild(Main.java:758)

at org.apache.tools.ant.Main.startAnt(Main.java:217)

at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)

at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

Caused by: java.net.NoRouteToHostException: No route to host

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)

at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)

at java.net.Socket.connect(Socket.java:529)

at java.net.Socket.connect(Socket.java:478)

at java.net.Socket.<init>(Socket.java:375)

at java.net.Socket.<init>(Socket.java:189)

at com.jcraft.jsch.Util.createSocket(Util.java:335)

… 20 more

 

Posted in prog | Tagged build server, java, jenkins | Leave a response

Why is String not sorting with the Local ?

By Chris on September 28, 2014

Comparing and sorting Strings might not work out like you expected specially when your dealing with a language other than English.

Normally comparing strings in done with simple Unicode ordering. If you want to have localized ordering (the kind expected by an end user) you need to use a Collator.

Commonly used String methods such as:

  • String.equalsIgnoreCase(String)
  • String.compareTo(String)

can have unexpected result depending on the context you’re using them. The reason is that programmers tend to apply them to tasks they really aren’t meant for, simply out of habit.

The fundamental difference is that localized comparison depends on Locale, while String is largely ignorant of Locale.

The only robust way of doing localized comparison or sorting of Strings, in the manner expected by an end user, is to use a Collator, not the methods of the String class.

For more info check out the code example at http://www.javapractices.com or at http://www.guru99.com/java-strings.html

Posted in java, prog | Tagged collator, java, sorting, String | Leave a response

Oracle doesn’t support limit

By Chris on September 20, 2014

My god sometime I bang my head on the wall to do something simple on oracle. So oracle don’t support limit so to do something simple has :

SELECT f_name, l_name, age from
employee_data ORDER BY age DESC
LIMIT 20

become :

SELECT f_name, l_name, age
FROM
( SELECT f_name, l_name, age, ROWNUM r
FROM
( SELECT f_name, l_name, age FROM employee_data 
      ORDER BY age DESC
)
WHERE ROWNUM <= 40
)
WHERE r >= 21;

 

Posted in db, prog | Tagged limit, oracle, sql | Leave a response

Update table using Inner Join return ORA-00933

By Chris on September 13, 2014

I was trying to update a table that using sql join but I kept getting ORA-00933  

I tried the following:

Using A SQL JOIN In A SQL UPDATE Statement Using A SQL JOIN In A SQL UPDATE Statement (www.bennadel.com)

update table using inner join (venushuynh.wordpress.com)

but I kept getting the ORA-00933

then tried this Oracle Update with Join (geekswithblogs.net) but still didn’t work.

After some deep search I’ve found my error in a oracle forum: SQL Error: ORA-01779: cannot modify a column which maps to a non key-preser

Even though it’s not the same ORA error it fixed the problem nonetheless

Here my sql statement that worked for me:

UPDATE mytable m

set m.status=7

where m.id in (select mytable.id from mytable inner join otherTable on mytable.matchid=othertable.matchid where othertable.userid=1234)

Posted in db | Tagged db, error, oracle | Leave a response

Hibernate Session saveOrUpdate does not update

By Chris on September 7, 2014

Another problem I’ve it recently with saveOrUpdate that can be fix by using the same saveOrUpdate but give the class name.

Using the session.saveOrUpdate(myObject) might give you a unknown entity while using the same method with the class name in parameter won’t.

session.saveOrUpdate(myObject); //give a unknown entity
session.saveOrUpdate("MyObjectClassName", MyObject); //Work

The important difference between the org.hibernate.Session class methods, save & saveOrUpdate is, save generates a new identifier and results in an INSERT query, whereas saveOrUpdate does an INSERT or an UPDATE.

For a more complete summary of what each of these method do check the hibernate site or this stackoverflow question/answer

Posted in db, prog | Tagged db, hibernate | Leave a response

Lessons learned: Why struts not working ?

By Chris on September 2, 2014

If you happen to rename your folder that contain your jsp and js, don’t forget to update the struts config (and the tiles). This will save your precious time even hours …

Posted in java | Tagged java, javascript, js, jsp, struts | Leave a response

Oracle have no Boolean, how to fix this

By Chris on August 30, 2014

For some reason Oracle have no Boolean

Since there is no BOOLEAN datatype in Oracle, as far as tables are concerned.

CREATE TABLE BooleanTable (MyBool BOOLEAN);

return :

ORA-00902: invalid datatype

But there is a BOOLEAN datatype in PL/SQL.

What should we do instead?

According to Tom at ThinkOracle you could create the table using char like this :

CREATE TABLE BoolTable (MyBool CHAR(1) CHECK (MyBool IN ( 'Y', 'N' )));

In our case (where I used to worked) we used Number instead. Same thing we did with the char but instead of “y/n” we use ‘0’ or ‘1’ where ‘0’ = false and ‘1’ = true

Related:

http://thinkoracle.blogspot.ca/2005/07/oracle-boolean.html

Posted in db | Tagged boolean, oracle, pl/sql, sql | 1 Response

Jmeter: ERROR – jmeter.save.SaveService: Conversion error

By Chris on August 23, 2014


One of our engineer made some change to the Jmeter script and I couldn’t find what was the error. The test was giving me “Error in TestPlan – see log file”

After some digging I found out there was an ext lib missing.

ERROR - jmeter.save.SaveService: Conversion error com.thoughtworks.xstream.converters.ConversionException: kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup

—- Debugging information —-

message : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup

cause-exception    : com.thoughtworks.xstream.mapper.CannotResolveClassException

cause-message : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup

class   : org.apache.jorphan.collections.ListedHashTree

required-type : org.apache.jorphan.collections.ListedHashTree

path: /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup

 

Finally this error was due to 2 things

1- We needed to have the same version of jmeter than the other programmer was using (2.5.1 + at the time)

2- We needed a library that I didn’t know about http://jmeter-plugins.googlecode.com/files/JMeterPlugins-0.5.1.zip

Posted in jmeter | Tagged jmeter, load testing | Leave a response

« PreviousNext »

Tags

4hww 2018 about addiction arraylist book ClassLoaders date dating db deployment DeploymentException errors hibernate icon ideas j2ee java java.util.List jboss linux List memory motivation mysql netstat oracle port programing quora rest reviews self help soap sql star startup String struts struts tag styleClass tags to_date welcome windows

Recent Comments

  • kevin on Oracle have no Boolean, how to fix this

Calendar

April 2021
MonTueWedThuFriSatSun
« Mar  
 1234
567891011
12131415161718
19202122232425
2627282930 

Archives

  • March 2021
  • February 2021
  • May 2020
  • January 2019
  • December 2018
  • July 2018
  • April 2018
  • January 2018
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • November 2013
  • September 2013
  • August 2013
  • July 2013

Copyright © 2021 Some Trials & a lot of Errors.

Powered by WordPress and Hybrid.