tips


27
May 11

VisualVM and jps Not Finding my Java Process

Today I was hit by a weird problem and I thought I’ll share the problem and the solution (thanks for the solution goes to my colleague Lauri). Googling did not help me much (probably bad keywords or not much information about it) and hopefully this post will serve as future destination for a solution for this problem.

Problem

You are running Mac OS X (maybe the problem is relevant on other platforms too) and even if you’ve started Tomcat and you can see the Java process in the Activity Monitor or with ps you can’t see the process with jps. You are not able to connect to the process with VisualVM nor JConsole. Bummer.
Continue reading →


28
Oct 10

WP Super Cache and 0 Byte Downloads

You’re using WP Super Cache on your WordPress site and some of your downloads end up 0 bytes? Check your Apache log to see if you’re running out of memory. Look for a line similar to:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 34953465 bytes) in /var/www/yourwebsite.com/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 286

The reason is that WP Super Cache is doing its best to save your server from some load and the entry point for most of the requests is actually a PHP file from the WP Super Cache. Check your .htaccess file for more details. That script tries to cache your download file which might not fit into your memory limit. Download files are anyways static (unless you add some binary cookies, which you’re probably not) and don’t need another layer of caching.

Solution

In WP Super Cache options locate “Accepted Filenames & Rejected URIs” section and add some extensions there. In this example I’ve added zip jar and exe. Mind the syntax.


26
Oct 10

How to waste couple of hours with the Play! Framework

Quick rant (downgrade) of the Play! Framework, just wasted another hour trying to find out why my configuration is not applied. This is the second time this month so I need to let out some steam.

Generally I’m a big fan of Play! It is easy to use, easy to setup and fast to develop with. Its like Struts with JRebel but feels more fresh. Okay, back to the rant.

Lets say you want to make sure that each time you run your application, the HSQLDB is initialized into the same location.

Well, you go to application.conf. Find the db.url field, comment it in, change it to

db.url=jdbc:hsqldb:file:my/fav/static/location

Done! 10 minutes you notice that

/private/var/folders/Em/EmtX3-Q+EgOCv9GUy0k8dU+++TI/-Tmp-/Jetty_0_0_0_0_8080_webapp____.7fbo9s/webapp/WEB-INF/application/db/db

is used as the DB location. After grepping, doublechecking, debugging and swearing you find in the internals of play that db.url, db.pass, db.user, db.driver are ignored if db=fs is set. WTF? No warning, no nothing that your configuration gets overwritten, aaargh!

Lets say your deployment is not Play! (they advise you to use play run to run apps written using Play! instead of a classic servlet container). Lets say you target Jetty instead.

Well, you deploy your WAR archive to Jetty and develop as you would before but then you discover that your files are no longer reloaded. You also discover that you get tons of database exceptions. After grepping, doublechecking, debuggin and swearing you find in the internals of play that once you ditch the play run and move to a classic container Play! will presume that you must have been smoking crack when you wrote application.mode=dev in your configuration file. It will just override it and make sure that you run in production mode this time. WTF? No warning, no nothing that your configuration gets overwritten, aaargh.

So next time you’re having problems with Play!, do some grepping, doublechecking, debuggin and swearing and find the location where your configuration options are overwritten by some Java code inside play.jar.


23
Apr 10

Somebody is stealing my website design – what are my options?

The authors of this blog also run a software company called ZeroTurnaround. We monitor the mentions of the company name and its products with different tools. I personally use Google Alerts (you get an email when the interwebz mentions your monitored word).

One day we stumbled upon a page that had stolen our website design. It was not a question if they had borrowed ideas from us but they had literally stolen everything. The html, css, images and even had our logo up! Our website is zeroturnaround.com and their, jbrute.info (the one which stole the design).

My first reaction was that I’ll just drop them an email, make sure that they’re aware that it is a crime (is it?) and order them to take it down and problem solved. We have no interest of suing anybody. Maybe they were just playing around. Here is a picture how it looked at that time.

The plan was easy but getting contact information was not. At least they had taken down our contact information from the footer. Not finding even an email (then again, smart move, too many stories of criminals accidently leaving their card at the scene of the crime) from the webpage I turned to DNS whois. Whois records show

Domain ID:D32012015-LRMS
Domain Name:JBRUTE.INFO
Created On:24-Mar-2010 20:00:01 UTC
Last Updated On:24-Mar-2010 20:15:33 UTC
Expiration Date:24-Mar-2011 20:00:01 UTC
Sponsoring Registrar:GoDaddy.com Inc. (R171-LRMS)
Status:TRANSFER PROHIBITED
Registrant ID:CR44517482
Registrant Name:Conor Ryan
Registrant Organization:Warlock 999 Development
Registrant Street1:One Vernon Drive
Registrant City:Vernon
Registrant State/Province:New Jersey
Registrant Postal Code:07976
Registrant Country:US
Registrant Phone:+1.5555555555
Registrant *************@warlock999.info

All emails sent to warlock.info or jbrute.info bounce. Googling the name and address does not bring much up. It’s like a dead end. I’ve also contacted the registrar and hosting, still waiting for replies. They’ve updated their website design today, removed the video, our logo and put up some text.

What are my options to deal with something like this? Proving that the design belongs to us should be easy (the html is too similar). How should I go about documenting this? I did make a screenshot when I first stumbled upon, but you could always say that I’m good in Photoshop.

Are there other options to contact a domain name owner besides information from website and WHOIS?


28
Dec 09

Bleeding edge of development – upgrading system and ANT stops working

I run Debian Unstable as my main desktop system. I shoot myself in the foot couple of times a year with the upgrades but I like using the bleeding edge of development.

Today after my “regular” upgrade I noticed that one of the ANT tasks did not perform as I would have expected.

/home/toomasr/workspace/project/build.xml:459: The following error occurred while executing this line:
/home/toomasr/workspace/project/changelogic-build.xml:72: Please check the correctness of the root url property. The server returned HTTP response code 300 or above for the URL http://172.17.57.242/lib/changelogic-build.xml

A quick ant -debug did not help me much.

/home/toomasr/workspace/project/build.xml:459: The following error occurred while executing this line:
/home/toomasr/workspace/project/changelogic-build.xml:72: Please check the correctness of the root url property. The server returned HTTP response code 300 or above for the URL http://172.17.57.242/lib/changelogic-build.xml                                                                                                                                       
        at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:508)                                                                                   
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:369)                                                                                                                  
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)                                                                                                     
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                                                              
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)                                                                                            
        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: /home/toomasr/workspace/project/changelogic-build.xml:72: Please check the correctness of the root url property. The server returned HTTP response code 300 or above for the URL http://172.17.57.242/lib/changelogic-build.xml
        at org.apache.tools.ant.taskdefs.Exit.execute(Exit.java:142)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor6.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.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
        at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:367)
        ... 17 more
--- Nested Exception ---
/home/toomasr/workspace/project/changelogic-build.xml:72: Please check the correctness of the root url property. The server returned HTTP response code 300 or above for the URL http://172.17.57.242/lib/changelogic-build.xml
        at org.apache.tools.ant.taskdefs.Exit.execute(Exit.java:142)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor6.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.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
        at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:367)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        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)
 
Total time: 3 seconds

The access log on the server did not show anything for the request. Browsing to the url with FireFox worked just fine. Where to even start debugging this? The simple env did not show any proxies configured either. Quite lost.

At last I decided to trace the problem with strace. strace -f ant my_target > result 2>&1 produced 35 892 lines of output. Searching for the ip showed me the message

35596 [pid 13544] connect(46, {sa_family=AF_INET6, sin6_port=htons(80), inet_pton(AF_INET6, "::ffff:172.17.57.242", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 ENETUNR      EACH (Network is unreachable)

Weehah, I’m getting somewhere! Googling a bit showed me multiple solutions. Either a system wide sysctl -w net.ipv6.bindv6only=0 or just -Djava.net.preferIPv4Stack=true will do the trick. I hope this helps somebody.