Tuesday, February 26, 2013

Rhino.Mocks WhenCalled() throws exception "Method requires a return value or an exception to throw"

When using of WhenCalled, you should also specify Return statement at the end. More details here.




Sunday, September 16, 2012

Copy maven dependencies to WEB-INF/lib

Use Case

Configure Dynamic Web Project in Eclipse to copy maven dependencies (jars) to WEB-INF/lib.

Solution

1. Update eclipse.ini, specify -vm option

-vm
C:\Program Files\Java\jdk1.6.0_25\bin\

2. Convert project to MAVEN backed, set packaging to WAR.

3. Configure JRE
Go to Project > Properties > Java Build Path > Libraries. Choose JRE System Library and click 'Edit'. Choose Execution Environment from list of available environments, use the same vm as eclipse.ini has.

4. Configure Deployment Assembly
Go to Project > Properties > Deployment Assembly. Click Add button, then choose Java Build Path Entries. Choose Maven Dependencies from the list and click OK. 


Monday, October 31, 2011

ActiveMQ 5.3 / System.IO.EndOfStreamException / "Unable to read beyond the end of the stream.

Issue

I've got a problem with long-running message listeners in ActiveMQ. After approximately 60s, long-running operation breaks with exception - Thread was aborted.

Solution

Solution and reason are described there: https://issues.apache.org/jira/browse/AMQNET-196

After adding: ?transport.keepAliveResponseRequired=true to connection string everything became working like a charm.

Monday, July 11, 2011

HTTP Error 404.15 – Not Found: The request filtering module is configured to deny a request where the query string is too long

Use Case

Query string exceeds reasonable size for HTTP GET.

Solution

Quick and dirty solution is to increase the maximum querystring size by setting the maxQueryString attribute on the requestLimitselement in the system.webServer/security/requestFiltering configuration section in your application’s web.config:

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxQueryString="NEW_VALUE_IN_BYTES" />
        </requestFiltering>
    </security>
</system.webServer>

http://mvolo.com/blogs/serverside/archive/2007/12/08/IIS-7.0-Breaking-Changes-ASP.NET-2.0-applications-Integrated-mode.aspx

Or use HTTP POST, if you can.

Drop all user objects in the schema

Use Case

Drop objects in schema without deletion of user

Solution

Very helpful script can be found at: http://stackoverflow.com/questions/842530/plsql-drop-all-database-objects-of-a-user



create or replace
FUNCTION                DROP_ALL_SCHEMA_OBJECTS RETURN NUMBER AS
PRAGMA AUTONOMOUS_TRANSACTION;
cursor c_get_objects is
  select object_type,'"'||object_name||'"'||decode(object_type,'TABLE' ,' cascade constraints',null) obj_name
  from user_objects
  where object_type in ('TABLE','VIEW','PACKAGE','SEQUENCE','SYNONYM', 'MATERIALIZED VIEW','FUNCTION','PROCEDURE') AND object_name <> 'DROP_ALL_SCHEMA_OBJECTS'
  order by object_type;
cursor c_get_objects_type is
  select object_type, '"'||object_name||'"' obj_name
  from user_objects
  where object_type in ('TYPE');
BEGIN
  begin
    for object_rec in c_get_objects loop
      execute immediate ('drop '||object_rec.object_type||' ' ||object_rec.obj_name);
    end loop;
    for object_rec in c_get_objects_type loop
      begin
        execute immediate ('drop '||object_rec.object_type||' ' ||object_rec.obj_name);
      end;
    end loop;
  end;
  RETURN 0;
END DROP_ALL_SCHEMA_OBJECTS;


Usage is easy:


select DROP_ALL_SCHEMA_OBJECTS from dual;

Wednesday, June 29, 2011

ext.net checkbox in grid header

Use Case

Place checkbox (or virtual any custom control to the header)

Solution

Use AfterRender event to override header cell's text.
Inspired by http://extjs-world.blogspot.com/2011/06/how-to-show-image-or-checkbox-html.html



                function afterRender(_grid) {
                     var columns = _grid.getColumnModel().config;
                     var view = _grid.getView();
                     var columnIndex = 0;
                     Ext.each(columns, function(column){
                        if (column.id.indexOf(""IDX"") == 0) {
                            var headerHtml = '<div class=""x-grid""' + columnIndex + '-hd-inner x-grid' + columnIndex + '-hd-' + column.id + '"" unselectable=""on"" style=""text-align: center;"">' + column.header;
                            headerHtml += '&nbsp;<input type=""checkbox"" id=""'+column.id+'_CHCK"">';
                            headerHtml += '</div>';
                            //replace the view headerCell 
                            view.getHeaderCell(columnIndex).innerHTML = headerHtml;
                        }
                        columnIndex = columnIndex + 1;                        
                     });
                };
                ");