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;                        
                     });
                };
                ");


Thursday, June 23, 2011

oracle export import shell scripts

Use Case

Need to  export / import oracle schema from command line (linux shell)

Solution

Great scripts could be found at: http://noerror.blogspot.com/2005/01/expimp-korn-shell-scripts.html
However, on my environment they could not be executed due to very minor syntax issues which could be result of different versions of shell executable.

My corrected version is listed below (slightly updated, since I have to call exp / imp under hi-privileged account).

Usage is easy:

./export.sh -p [dba_user_password] -f [export_file_name] -s [schema_name1,schema_name2,...]
./import.sh -p [dba_user_password] -f [export_file_name] -o [from_schema_name] -t [to_schema_name]

Also, some useful information could be found at:
http://www.dbaexpert.com/blog/2008/04/comprehensive-shell-script-to-export-the-database-to-devnull/
and http://dbamac.wordpress.com/2008/08/01/running-sqlplus-and-plsql-commands-from-a-shell-script/

===============  export.sh  =================


#!/usr/bin/ksh
# export.sh - Korn Shell script to export (an) Oracle schema(s).
# January 6, 2005
# Author - John Baughman
# Hardcoded values: copy_dir, pipefile, dba
# Jun 23, 2011
# Changed by SK
dba=sys

copy_dir=/home/oracle/dbcopy/
# Check the dump directory exists
if [[ ! -d "${copy_dir}" ]];then
echo
echo "${copy_dir} does not exist !"
echo
exit 1
fi

pipefile=~/backup/backup_pipe
# Check we have created the named pipe file, or else there is no point
# continuing
if [[ ! -p ${pipefile} ]];then
echo
echo "Create the named pipe file ${pipefile} using "
echo " $ mknod ${pipefile} p"
echo
exit 1
fi

# Loop through the command line parameters
# -p - Currently the PSG user password.
# -d - The Oracle SID of the database to export. This matches the TNS entry.
# -s - The schema to import
# If either/all of these don't exist, prompt for them.
# Now, check the parameters...
while getopts ":p:f:s" opt; do
case $opt in
p ) psg_password=$OPTARG ;;
f ) raw_name=$OPTARG ;;  #raw_name=${OPTARG##/*/} ;;
s ) shift $(($OPTIND-1))
raw_schema=$* ;;
\? ) print "usage: export.sh -p password -s schema[...]"
exit 1 ;;
esac
done

# Get the missing ${dba} user password
while [[ -z ${psg_password} ]]; do
read psg_password?"Enter ${dba} Password: "
done

# Get the missing SID
#while [[ -z ${sid} ]]; do
#read sid?"Enter Oracle SID: "
#done

# Get the missing "raw" name
while [[ -z ${raw_name} ]]; do
read raw_name?"Enter the export dump file name: "
done



while [[ -z ${raw_schema} ]]; do
print "Enter the schema(s)"
read raw_schema?"(if more than one schema, they can either be space or comma delimited): "
done

# Fix up the raw schema list
schema_list=""
#raw_schema=$(print $raw_schema tr "[a-z]" "[A-Z]")
for name in $raw_schema; do
if [[ -z $schema_list ]]; then
schema_list="${name}"
else
schema_list="${schema_list},${name}"
fi
done
raw_schema=${schema_list}
schema_list="(${schema_list})"

# Fix up the export file name here...
export_file=${copy_dir}${raw_name}.Z

# Let's go!!!
print ""
print "*******************************************************"
print "* Exporting ${raw_schema} schema(s) at `date`"
print "*******************************************************"
print

compress < ${pipefile} > ${export_file} &
exp \'${dba}/${psg_password} as sysdba\' direct=y log=${copy_dir}${raw_name}.exp.log statistics=none buffer=1000000 feedback=10000 file=${pipefile} owner=${schema_list}
#exp ${dba}/${psg_password}@${sid} direct=y log=${copy_dir}${raw_name}.exp.log statistics=none buffer=1000000 feedback=10000 file=${pipefile} owner=${schema_list}

print
print "*******************************************************"
print "* Export Completed at `date`"
print "*******************************************************"
print

exit 0



===============  import.sh  =================

#!/usr/bin/ksh
# import.sh - Korn Shell script to import (an) Oracle schema(s).
# January 6, 2005
# Author - John Baughman
# Hardcoded values: copy_dir, pipefile, dba
# Jun 23, 2011
# Changed SK

dba=sys

copy_dir=/home/oracle/dbcopy/
# Check the dump directory exists
if [[ ! -d "${copy_dir}" ]];then
echo
echo "${copy_dir} does not exist !"
echo
exit 1
fi

pipefile=~/backup/backup_pipe2
# Check we have created the named pipe file, or else there is no point
# continuing
if [[ ! -p ${pipefile} ]]; then
echo
echo "Create the named pipe file ${pipefile} using "
echo " $ mknod ${pipefile} p"
echo
exit 1
fi

# Loop through the command line parameters
# -p - Currently the PSG user password.
# -d - The Oracle SID of the database to export. This matches the TNS entry.
# -f - The export file to import.
# If either/all of these don't exist, prompt for them.
# Now, check the parameters...
while getopts ":p:f:o:t" opt; do
case $opt in
p ) psg_password=$OPTARG ;;
f ) raw_name=${OPTARG##/*/} ;;
o ) from_user=$OPTARG ;;
t ) shift $(($OPTIND-1))
to_user=$* ;;
\? ) print "usage: import.sh -p password -f dump_file.dmp -o from_user -t to_user"
exit 1 ;;
esac
done

# Get the missing ${dba} user password
while [[ -z ${psg_password} ]]; do
read psg_password?"Enter ${dba} Password: "
done

# Get the missing SID
#while [[ -z ${sid} ]]; do
#read sid?"Enter Oracle SID: "
#done

# Get the missing "raw" name
while [[ -z ${raw_name} ]]; do
read raw_name?"Enter the export dump file name: "
done

# Get the missing "from_user" name
while [[ -z ${from_user} ]]; do
read from_user?"Enter the from_user name: "
done

# Get the missing "to_user" name
while [[ -z ${to_user} ]]; do
read to_user?"Enter the to_user name: "
done

# Fix up the export file name here...
export_file=${copy_dir}${raw_name}.Z

print
print "*******************************************************"
print "* Importing ${export_file} at `date`"
print "*******************************************************"
print

uncompress < ${export_file} > ${pipefile} & imp \'${dba}/${psg_password} as sysdba\' log=${copy_dir}${raw_name}.imp.log statistics=none buffer=1000000 feedback=10000 file=${pipefile} ignore=y fromuser=${from_user} touser=${to_user}

print
print "*******************************************************"
print "* Import Completed at `date`"
print "*******************************************************"
print

Oracle 10g exp problem - EXP-00008: ORACLE error 6550 encountered, ORA-06550: line 1, column 13

Use Case

During exp following error occured:


EXP-00008: ORACLE error 6550 encountered
ORA-06550: line 1, column 13:
PLS-00201: identifier 'EXFSYS.DBMS_EXPFIL_DEPASEXP' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
EXP-00083: The previous problem occurred when calling EXFSYS.DBMS_EXPFIL_DEPASEXP.schema_info_exp
. exporting statistics
Export terminated successfully with warnings.

Solution

Please, follow these steps:

1. Connect as SYS using SQL*Plus

2. Run CATEXF.SYS
@ ?/rdbms/admin/catexf.sql


Now, if EXFSYS schema is not created look into log files and search for any errors.

Another helpful link: http://oracle-in-examples.blogspot.com/2008/03/exp-00008-oracle-error-6550-encountered.html

Wednesday, June 1, 2011

oracle schema export / import

To export single schema, use following command.

exp username/password FILE=dump.dmp OWNER=username

imp username/password FROMUSER=user1 TOUSER=user2 FILE=dump.dmp

In some cases, exp/imp must be running as SYSDBA, in this case, enclose username into single quotes with backslashes.

imp \'sys/***** as sysdba\' FROMUSER=user1 TOUSER=user2 FILE=dump.dmp

Monday, February 28, 2011

oracle 10xe, oracle 12705 cannot access nls data files or invalid environment specified

Issue

Can not connect to Oracle10g Express edition from SqlDeveloper. Following error occured: oracle 12705 cannot access nls data files or invalid environment specified

Solution

Add option to  sqldeveloper.conf

AddVMOption -Duser.region=US
AddVMOption -Duser.language=EN

Monday, January 17, 2011

asp.net strongly typed view and virtual path provider

Use Case

Have custom system inspired by VirtualPathProvider samples from MSDN. Need ability to use strongly typed views.

Solution

In the case of using generic views (not-strongly types), everything works fine. The problem appears when I'm trying to use strongly-typed view as shown below:


<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Abc.Xyz.MyClass>" %>

The problem is obvious and well-known, if Views/ folder miss web.config file, asp.net mvc application can't load the view. In Virtual Path Provider solution is more tricky. The quickest solution (for me) was to add content of web.config file that must reside in views folder directly to main web.config file in separate location.

For example, if you have your VPP accepting smth like "~/page/xxx", the problem is easily solved by adding following snippet to your web.config

+++++


  <!-- Important change for virtual pages -->
  <location path="page">
    <system.web>
      <httpHandlers>
        <add path="*" verb="*"
            type="System.Web.HttpNotFoundHandler"/>
      </httpHandlers>

      <!--
        Enabling request validation in view pages would cause validation to occur
        after the input has already been processed by the controller. By default
        MVC performs request validation before a controller processes the input.
        To change this behavior apply the ValidateInputAttribute to a
        controller or action.
    -->
      <pages
          validateRequest="false"
          pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
          pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
          userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <controls>
          <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
        </controls>
      </pages>
    </system.web>

    <system.webServer>
      <validation validateIntegratedModeConfiguration="false"/>
      <handlers>
        <remove name="BlockViewHandler"/>
        <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
      </handlers>
    </system.webServer>
  </location>

++++

During research, I've found several good articles:




Tuesday, January 11, 2011

Jack Rabbit WebDAV and MS Office

Use Case

Have MS Office to work with Jack Rabbit WebDAV

Solution

The solution given below is for internal usage only. Do not follow if you're not realize what you're exactly doing.

There is well known feature of MS Office which prevents it from correct work with WebDAV. During transmissions back and forth MS Office magically lose important auth headers which actually imply on WebDAV security. After hours of struggling with this, the only solution for internal usage was to disable authorization in Jack Rabbit.

I tried to play with security settings in jack rabbit but wasn't successful. The reason is that by default anonymous user has read only permission and any other login has full permission. I was able to tweak file:
SimpleAccessManager.java, rebuild sources and everything got worked :)

jack rabbit over http / rest

Use Case

Provide REST access to jack rabbit.

Solution

Use following article from jack rabbit guru:

http://jukkaz.wordpress.com/2009/11/24/jackrabbit-over-http/
http://jukkaz.wordpress.com/2009/11/18/content-repository-over-http/

It's also good idea to take a look at: http://sling.apache.org. It works perfectly, but I didn't like it because wan't able to reconfigure it to use external jack rabbit installation.. Maybe another day.

For those who need to access Jack Rabbit from .NET, I may suggest excellent WebDav Client Library for .NET from http://www.webdavsystem.com/client

Monday, January 10, 2011

jboss hosts

Use Case

Get JBoss to listen all IP addresses.

Solution

Start JBoss using command: run.bat -b 0.0.0.0. Note that this is easiest but not best way to go. If your server will have more than one network card, you will have to specify interface implicitly.

More information how to setup serveral hosts using JBoss can be found at:

http://community.jboss.org/wiki/VirtualHostswithJBossAS
http://docs.jboss.org/jbossas/guides/webguide/r2/en/html/ch07.html

jboss + jack rabbit

Use Case

Setup Jack Rabbit on JBoss

Solution

JBoss AS (jboss-5.1.0.GA), Jack Rabbit (2.2.0, jackrabbit-webapp-2.2.0.war).

There is official manual on how to setup Jack Rabbit onto JBoss: http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss

However, I prefer to work with WAR distributable files, so, my steps were a bit different:

1. Download jackrabbit-jcr-rmi-2.2.0.jar  from https://repository.apache.org/content/groups/public/org/apache/jackrabbit/jackrabbit-jcr-rmi/2.2.0/jackrabbit-jcr-rmi-2.2.0.jar, put this file to jboss/server/default/lib

2. Copy jackrabbit-webapp-2.2.0.war to deploy directory

3. Start JBoss

In my case, jack rabbit started but wasn't able to create repository. The reason is odd error that default RMI port 1099 was occupied. That error will be fixed in 2.2.1.

I managed to fix this issue by specifying different RMI port (1100) in  jboss\bin\jackrabbit\bootstrap.properties. Not sure that this is correct, but after this, JBoss picked up JackRabbit, created repo, give me webdav access and much more.

Useful links:

JackRabbit Configuration
http://jackrabbit.apache.org/jackrabbit-configuration.html#JackrabbitConfiguration-Securityconfiguration



Next steps would be to configure WebDAV with MS Office, setup access, configure db file system and play with hadoop.

More info coming.

jboss + jasper report server

Use Case

Setup jasper report server on jboss.

Solution

Download JBoss (jboss-5.1.0.GA), Jasper Server (jasperserver-ce-3.7.1-bin.zip). Installation is pretty straightforward, if follow this guide: http://jasperserver.sourceforge.net/docs/3-7-0/JasperServer-CE-Install-Guide.pdf

By default, Jasper Server uses MySQL / PostgreSQL to keep internal data. Good post about how to marry JasperServer & Oracle could be found here: http://stage.jasperforge.org/plugins/espforum/view.php?group_id=112&forumid=102&topicid=54994

It's strange, but I wasn't able to get running JBoss 6.xx and Jasper Server 3.7.xx..