(Java&Maven)
I have two projects built with maven. One of them includes the other.
The new requirement that I have done is working in the original (common) project, but, even the simplest call to this functionality from the upper project results with an error (in current case with ClassNotFoundException, but this can be any time of error).
Here is one of the thing that should be done when you don't have the clue - check dependencies. By using maven it is possible to have a mess with them if you do not use exclusions within dependency tags. This way you can get two versions of the same JAR downloaded, and the older version used - so you got the class not found exception.
Useful tool is within Eclipse Galileo: open pom.xml and check all items within Dependency Hierarchy. From there you can build a list with duplicated and conflicted versions of JARs, and a list of exclusions you need to set in same pom.xml file.
After altering pom.xml file, check the hierarchy again - you should have one position in the hierarchy for each resolved dependency (or at least positions within same library in the hierarchy without any conflicts).
Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts
Monday, 22 November 2010
Wednesday, 1 July 2009
Uncompilable source code
Got this at the very end of the java file.
I have solved this one only by removing and reentering new line sign after class definition in that file.
Many other strange errors can be solved this way.
I have solved this one only by removing and reentering new line sign after class definition in that file.
Many other strange errors can be solved this way.
Labels:
Java
Friday, 6 February 2009
Eclipse Tomcat in more than 45 seconds
(Eclipse 3.3 - for Eclipse 3.4+ check comments on this post)
Do you have some web application that cannot be started in Eclipse's Tomcat in 45s, and you get that annoying time out message?
Do you have some web application that cannot be started in Eclipse's Tomcat in 45s, and you get that annoying time out message?
- Go to Windows > Preferences in Eclipse
- Search for Server
- Set Server timeout delay at you're own will
Preference TimeOut Shorter 11s Short 22s Normal 45s Long 90s Longer 180s Unlimited unlimitedSource: https://bugs.eclipse.org/bugs/show_bug.cgi?id=151993
Friday, 16 January 2009
Debugging log4j itself
Problem: You cannot find out which log4j.properties file is used.
Try running VM with parameter
-Dlog4j.debug
You'll get info about log4j properties in console.
See: http://logging.apache.org/log4j/1.2/manual.html
Try running VM with parameter
-Dlog4j.debug
You'll get info about log4j properties in console.
See: http://logging.apache.org/log4j/1.2/manual.html
Saturday, 25 October 2008
GWT under NetBeans memory problem
To solve JavaHeapSpace when starting some GWT project under NetBeans, edit file
/nbproject/build-gwt.xml
under next path in this XML
project/target[name="-post-compile"]/java
add attribute/value pair inside java tag
maxmemory="128M"
under next path in this XML
project/target[name="-post-compile"]/java
add attribute/value pair inside java tag
maxmemory="128M"
Monday, 14 January 2008
Current directory in Java
Here is something that I need all the time:
Current directory can be retrieved with:
Some other properties from System are also very useful (here is the list of all properties)
Current directory can be retrieved with:
System.getProperty("user.dir");Some other properties from System are also very useful (here is the list of all properties)
Labels:
Java
Saturday, 22 December 2007
String's methods with regular expressions
The next example is for method replaceFirst(String regex, String replacement) which should find first substring that matches given regular expression and change it with replacement.
What if you want to replace only the first substring that is equal to "[sometnig]" - this represents regular expression that will match every single character from the word 'something', and, so
What we need here is static method Pattern.quote(String s) which will make regular expression that matches string s as is. Thus, call
will return "this is a anything test".
BTW: This is just for replacing only the first substring matched. If you want to replace all substring that are matched, you should use String's method replace. Also, there is method replaceAll which, again, uses String parameter for regular expression pattern matching.
What if you want to replace only the first substring that is equal to "[sometnig]" - this represents regular expression that will match every single character from the word 'something', and, so
a.replaceFirst("[something]", "anything");
will return (bold substrings are match and replacement):- if a="this is a [something] test"
then "anythinghis is a [something] test" - if a="[something]"
then "[anythingomething]"
What we need here is static method Pattern.quote(String s) which will make regular expression that matches string s as is. Thus, call
a.replaceFirst(Pattern.quote("[something]"), "anything");
if a="this is a [something] test"will return "this is a anything test".
BTW: This is just for replacing only the first substring matched. If you want to replace all substring that are matched, you should use String's method replace. Also, there is method replaceAll which, again, uses String parameter for regular expression pattern matching.
Labels:
Java
Subscribe to:
Posts (Atom)
Popular Posts
-
(Eclipse 3.3 - for Eclipse 3.4+ check comments on this post) Do you have some web application that cannot be started in Eclipse's Tomc...
-
(Archiva 1.1.3 with default Derby database) Many times I have had this problem. It's time to note the solution here, so I would not wa...
-
(Kubuntu 10.10 with Wine 1.3.10) I have installed a Windows program under Wine, but it wasn't working. When I run the EXE from console...
