Monday, September 29, 2008

Verity K2 server hangs on CFMX

I came across a situation when submitting new content for reindex or removal from a search collection simply does not do anything. The process runs forever and there's no activity by k2. I'm using CFMX7.0.2.

When this happens, check your search collection folder called trans. There is a file called data.trn in which k2 writes the commands that it is supposed to execute. I think it is sort of a batch file of all commands issued for a given collection.

A typical example of what it contains:
LAST LOGCHECK "-989436216"
LAST CLEAN "-989436216"
I noticed that from time to time I'd get some weird looking file writing/permission errors in the various k2 log files (found under [VERITY ROOT]/Data/services/ColdFusionK2_indexserver1/ folder). Whenever these happen, data.trn still shows the commands that were issued earlier. As more and more commands are issued it would keep on growing this file and adding new commands to it. But the real problem is that the first command that caused the failure is probably still there and for whatever reason cannot be finished.

So what to do? The easiest thing is to simply edit the file and remove all the lines below the 4th line in the example above - that's what a 'clean' data.trn contains. I do that after turning k2 off in the services (just in case). After this, indexing process tends to go back to normal.

Thursday, September 18, 2008

Upgrading to Rails 2.x

Here's a short (?) list of issues encountered when upgrading from Rails 1.2.6 to Rails 2.x (in my case it was Rails 2.1.1).

  • first thing is run that rake task for deprecation (place it in your lib/tasks as deprecated.rake and then run rake deprecated). It should give you a few things to change
  • Change @request, @session[], @params[] by removing @ sign in front of them.
  • Change <%= start_form_tag ... %> to <% form_for :action => '...' do %>
  • Change <%= end_form_tag %> (where the above start_form_tag appears) to <% end %>
  • Change find_first(["..."...]) to find(:first, :conditions => ["...",...]) (Note: I believe rake deprecated did not catch all of these initially!)
  • Remove model directive from your controllers
  • Follow the rake task deprecation list until all is done (I did all except the paginator at first since I wasn't sure what to do)
  • Install rails with dependencies (gem install -y rails). I got Rails 2.1.1.
  • Update gem (gem update --system)
  • In your rails application root you'd need to run rake upgrade (emm.... my memory fails me right now - I think its that?). This sort of updates the config/... files from what I gathered - namely the config/boot.rb as well as public/javascript files (I notice that prototype is after the upgrade).
  • Update config/environment.rb change RAILS_GEM_VERSION = '1.2.6' unless defined? RAILS_GEM_VERSION to RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION (or whatever your Rails 2.x version is)
  • If you used observers in your controllers remove them from there (look for observer :your-model-name_observer in your controllers)
  • Add observers into config/environment.rb (inside do |config| section add config.active_record.observers = :your-model-name_observer)
  • Update act_as_versioned plugin with the latest from git (if you don't change it this plugin apparently completely breaks the activerecord setter and you'd get NoMethodError on normal model object setters, especially with ajax in-place editor)
  • Add config.action_controller.session = { :session_key => "_your-app_session_", :secret => "random security string" } to the same config/environment.rb section as above. You can generate a big nice security hash string by doing rake secret.
  • I'm using old paginator (found in your typical Rails book) so I installed the classic_pagination plugin to make it work again (yes, yes, will replace it once I get the app running again)
  • I had a patch of some sort for in_place_editing (sorry can't remember where I got it or what was it but I know it was actually useful - I think relating to editing blank/empty data). Remove that altogether (it was in my lib/extensions.rb - things like ActionView::Helpers::JavaScriptMacrosHelper.class_eval do ...).
  • Install super_inplace_controls plugin (ruby script/plugin install as a replacement for your normal in_place_editor. Add to your layout file: <%= stylesheet_link_tag "in_place_styles" %> as well as somewhere inside the content area of the layout file a placeholder div for errors with ID inplace_error_div.
  • Change views which used the old style in_place_editor's <%= in_place_editor_field :rawdata, :col1 %> with <%= in_place_text_field :rawdata, :col1 %>
  • Leave the in_place_edit_for :model :field directives in your controller as they were
  • I changed ActionMailer::Base.server_settings = { ... in environment to ActionMailer::Base.smtp_settings = {.
  • One last note: I have other applications running on Rails 1.2.x which I still want to have so make sure you do NOT remove old gems that these might be removing. I believe running gem clean would do that so don't do it unless you want to jump into fixing all the other applications right away)
Wouldn't it be nice if upgrades were not a big deal/problem?

I've later discovered a problem with mongrel - it simply won't run as windows service. I'm using mongrel_service for this. The error shown is something along:
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- c:/ruby/
lib/ruby/gems/1.8/gems/mongrel_service-0.3.4-x86-mswin32/lib/mongrel_service/init.rb (MissingSourceFile)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:355:in `new_constants
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:134:in `load'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:203:in `each'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:203:in `each'
from c:/ruby/lib/ruby/gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:112:in `load'
... 11 levels...
from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/commands/server.rb:39
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
Turns out that the fix is pretty straight forward: change your gem folder name of mongrel_service (should be under your [ruby root]/lib/ruby/gems/1.8/gems/) from mongrel_service-0.3.4-i386-mswin32 to mongrel_service-0.3.4-x86-mswin32 (I suppose your version could be different). Thanx for te tip from this post.

Saturday, September 13, 2008

VS2005 web site publishing problems

When trying to do a Build > Publish Web Site from VS2005 of a file-based (!) Web Site project I'd get the following error: "You must choose a publish location that is different from the source Web application".

My web site project is called HRWeb. Its file-based which means that the source folder sits somewhere other then IIS' wwwroot/HRWeb. In fact, when opening the publish dialog box, VS2005 pre-fills a default location to a subfolder of where the solution file sits (something like /aspprecompile).

I wanted to publish the project to IIS on my machine, so tried http://localhost/HRWeb and got the above message. I did a similar thing elsewhere and managed to publish to a remote server with the same /HRWeb path portion, so its only on the local machine.

My work-around was to have the publishing directory something (anything) else, as long as its not under the /HRWeb (putting HRWeb2 for example does not work). So, I've put the publishing option as http://localhost/HR/ and that did the trick. Obviously I then had to manually copy the files from that directory into the one I wanted.

After doing this there was another problem. Accessing one of the sub-pages would show an error such as: "BC30456: 'Theme' is not a member of ...". Please note that the application works just fine while I develop things using VS2005 in-built web server.

To get around this I actually went back to the publishing to the local folder first on the file system and then manually moving the files over to IIS. I tried with the options on the publishing dialog ("Allow this precompiled site to be updateble" and "Use fixed naming and single page assemblies") but they made no difference - the error would persist.

All these deployment troubles came-in when my client wanted to do the publishing to the remote server from VS2005 (I was hoping he'll end-up doing an installation via the installer OR at least via the NAnt script that I had). Which now prompts me to go and figure out how can I get my NAnt to deploy things remotely instead of assuming a localhost deployment.

Friday, September 12, 2008

Rails and the plugin trap

I'm a big fan of Ruby on Rails (RoR). I've started doing some concrete projects with RoR a few months back and its been really a joy (well, almost all of the time).

With my current project I am trying to setup an access control list (ACL) security environment. First thing to do: check the plugins available. True enough, there were a few already out there that covered the security aspects. Sadly, half seem to be on Rails 2.0 (I'm still on 1.2.6), a few do not have the object-instance permissions that I was looking for and the reminder was impossible to actually run. So I wasted (?) quite a few hours just trying to find out about each one of them and then trying to put it in action. After much frustration I asked myself whether I really need an elaborate functionality that is allegedly offered by the plugins (both 1.2.6 and 2.0) or I can do away with something simpler. As always, I could go with a lot less. So I figured to scale down my hopes on this bit for now and just try implementing a simpler security scheme inside the application itself.

What really frustrated me was the fact that I'd spend sometime trying to learn about the plugin only to somehow catch the fact that you need RoR 2.0 for it (honestly, it really ought to be more visible). The other one is when you actually get the thing up, create the tables, etc and then find your unit tests (that are pretty much a copy from the readme file of the plugin) not working and spitting-out some really weird problems.... eventually I got tired of it and gave up...

App_Code in VS 2005 and web-related projects

I must be doing something terrible wrong since my VS2005 web application does not "see" the public enums/classes inside App_Code.

I tried adding a ASP.NET Web Application Project (VB) to an existing solution. I then manually created App_Code folder and placed a file which defines (without a namespace) a class and an enum. No brainer. Then I added a web service called HR.asmx and placed:

&lt;%@ WebService Language="VB" CodeBehind="~/App_Code/HR.vb" Class="HR" %>

I've added HR.vb into the App_Code.

Trying to build the web app project fails complaining it does not see these classes within the App_Code folder. I have another web site project in that solution and it builds with the exact same setup in App_Code. The obvious differences that I can see are:

  • The new one contains a Project file pointing to .vbproj file (no file path)
  • The old one has a "Full Path" and the project solution explorer name actually contains a path on the disk (something like E:\...\blah)
  • The old one contains a section Developer Web Server for project properties.
  • The old one has an option for Property Pages
  • The new one has a Properties (which opens up, among other things, a Web section where deployment via IIS/personal web server are possible)
  • The new one keeps offering a "Convert to web application" option through a right mouse click
  • The old has Build Web Site... and Publish Web Site... right-click menu options (vs a normal Build/Rebuild and a Publish... on the new Web app project)
This is what my solution explorer shows. Notice that the iconss are slightly different + the name of the first one starts with E:\...

It looks like that I've created something other then the "web application" project since my old project simply does not have these options that I see on the new one.

All this effort was due to a deployment problem I had. My customer happily uses VS2005 for project deployments. I've been trying to get my NAnt/CruiseControl to build and deploy (it works on my end of course), however, after talking to the customer I wanted to get the VS2005 to do its "Publish Website" option, thinking that it really ought to work just fine. It didn't and now I see that there's something that I did not do properly.

Any ideas/comments?