You have accessed an ActiveRecord class that wasn't properly initialized.

747 views
Skip to first unread message

Bhumip

unread,
May 26, 2009, 12:57:38 AM5/26/09
to Castle Project Users
I am working VS 2005 and .NET 2.0 and database Oracle 11g

Active Record is working on my local system when i deployed the system
on Server.

I have added [ActiveRecord] on top of the class but still error is
coming.


Following ERROR is coming

You have accessed an ActiveRecord class that wasn't properly
initialized. The only explanation is that the call to
ActiveRecordStarter.Initialize() didn't include

Please help me out i have deadline on Friday. My work is done but i
can not deploy on the Production server because of following ERROR.

John Simons

unread,
May 26, 2009, 5:20:56 AM5/26/09
to castle-pro...@googlegroups.com
Did u call ActiveRecordStarter.Initialize() as the first thing?


From: Bhumip <bhumi...@gmail.com>
To: Castle Project Users <castle-pro...@googlegroups.com>
Sent: Tuesday, 26 May, 2009 2:57:38 PM
Subject: You have accessed an ActiveRecord class that wasn't properly initialized.

Need a Holiday? Win a $10,000 Holiday of your choice. Enter now..

Bhumip

unread,
May 26, 2009, 5:58:48 AM5/26/09
to Castle Project Users
Hi John,

i have initialized in Global.asax and following is the code.

void Application_Start(object sender, EventArgs e)
{
Castle.ActiveRecord.Framework.IConfigurationSource source =
System.Configuration.ConfigurationManager.GetSection("activeRecord")
as Castle.ActiveRecord.Framework.IConfigurationSource;
System.Reflection.Assembly modelAssembly =
System.Reflection.Assembly.Load("ManilaPayroll.BAL");
Castle.ActiveRecord.ActiveRecordStarter.Initialize
(modelAssembly, source);

}

Some how it is work on my local machine it is not working on my
production machine where we have IIS 6.0 as web server.

Regards,

Bhumip


On May 26, 2:20 pm, John Simons <johnsimons...@yahoo.com.au> wrote:
> Did u call ActiveRecordStarter.Initialize() as the first thing?
>
> ________________________________
> From: Bhumip <bhumiph...@gmail.com>
> To: Castle Project Users <castle-pro...@googlegroups.com>
> Sent: Tuesday, 26 May, 2009 2:57:38 PM
> Subject: You have accessed an ActiveRecord class that wasn't properly  initialized.
>
> I am working VS 2005 and .NET 2.0 and database Oracle 11g
>
> Active Record is working on my local system when i deployed the system
> on Server.
>
> I have added [ActiveRecord] on top of the class but still error is
> coming.
>
> Following ERROR is coming
>
> You have accessed an ActiveRecord class that wasn't properly
> initialized. The only explanation is that the call to
> ActiveRecordStarter.Initialize() didn't include
>
> Please help me out i have deadline on Friday. My work is done but i
> can not deploy on the Production server because of following ERROR.
>
>       Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1f...

John Simons

unread,
May 26, 2009, 7:31:15 AM5/26/09
to Castle Project Users
Are you sure you've deployed all the assemblies including dependency
assemblies?

John

Bhumip

unread,
May 26, 2009, 7:38:44 AM5/26/09
to Castle Project Users
Hi John,

Following is the list of dlls in my bin folder.


Castle.ActiveRecord.dll

Castle.Components.Validator.dll

Castle.Core.dll

Castle.DynamicProxy.dll

Iesi.Collections.dll

log4net.dll

NHibernate.dll


Also Following is the ActiveRecordSection in web.config file

-----------------------------------------------------------
<configSections>
<section name="activeRecord"
type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler,Castle.ActiveRecord"/
>
</configSections>
<activeRecord isWeb="true">
<config>
<add key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.dialect"
value="NHibernate.Dialect.OracleDialect"/>
<add key="hibernate.connection.driver_class"
value="NHibernate.Driver.OracleClientDriver"></add>
<!--<add key="hibernate.connection.connection_string"
value="Data Source=ora11g;User ID=hrd1;Password=test123;"/>-->
<add key="hibernate.connection.connection_string" value="Data
Source=ora11g;User ID=phrd;Password=testtest;"/>
</config>

</activeRecord>
<connectionStrings>

--------------------------------------------------------------------------------------------

John Simons

unread,
May 26, 2009, 7:49:14 AM5/26/09
to Castle Project Users
Bhumip,

What version of Castle are you using (RC3 or trunk)?
Also, you say it works on your local machine, how about in another
developer machine?

John

Bhumip

unread,
May 26, 2009, 8:33:16 AM5/26/09
to Castle Project Users
John,

I am using Castle RC3. It is working on other Developer machine as
well.

The other thing you might want to know that on my local machine i have
IIS 5.0 web server but production server is IIS 6.0 web server.

I have googling so many times since last two days to resolve this
problem.

So many people have such issue but can not find concrete resolution.

Bhumip

Bhumip

unread,
May 27, 2009, 12:33:21 AM5/27/09
to Castle Project Users
Any body who faced such issue in the past and resolved it Please help
me out.

I hope end result of this thread would be concrete solution of this
problem.

Please share your thoughts. I may help to resolve this problem.

Thanks,

Bhumip

Markus Zywitza

unread,
May 27, 2009, 3:17:45 AM5/27/09
to castle-pro...@googlegroups.com
And what about

ManilaPayroll.BAL.dll

which is the assembly you are trying to load for initialization?

2009/5/26 Bhumip <bhumi...@gmail.com>:

Bhumip

unread,
May 27, 2009, 4:54:27 AM5/27/09
to Castle Project Users
Hi Markus,

"ManilaPayroll.BAL.dll" business access layer where i put all my
business logic of payroll system.

Thanks,

Bhumip

On May 27, 12:17 pm, Markus Zywitza <markus.zywi...@gmail.com> wrote:
> And what about
>
> ManilaPayroll.BAL.dll
>
> which is the assembly you are trying to load for initialization?
>
> 2009/5/26 Bhumip <bhumiph...@gmail.com>:

Bhumip

unread,
May 27, 2009, 5:12:55 AM5/27/09
to Castle Project Users
I am trying to deploy my application under sub domain (virtual
directory) of my root application.

1) Root application there is following nhibernate section in
web.config

<configSections>

<section name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/
>
</configSections>
<nhibernate>

<add key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"/>

<add key="hibernate.dialect" value="NHibernate.Dialect.OracleDialect"/
>

<add key="hibernate.connection.driver_class"
value="NHibernate.Driver.OracleDataClientDriver"></add>

<add key="hibernate.connection.connection_string" value="Data
Source=ora11g;User ID=test123;Password=test123;"/>

</nhibernate>

2) My current application which I want to configer under root
application have following ActiveWriter Section

<configSections>
<section name="activeRecord"
type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler,Castle.ActiveRecord"/
>
</configSections>

<activeRecord isWeb="true">
<config>

<add key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.dialect"
value="NHibernate.Dialect.OracleDialect"/>
<add key="hibernate.connection.driver_class"
value="NHibernate.Driver.OracleClientDriver"></add>
<add key="hibernate.connection.connection_string" value="Data
Source=ora11g;User ID=test123;Password=test123;"/>

</config>
</activeRecord>

I do not know exactly but because of web.confing inheritance of root
application may create this kind of error.

??????????????????

Markus Zywitza

unread,
May 27, 2009, 9:43:54 AM5/27/09
to castle-pro...@googlegroups.com
I don't know ASP.NET to well: Is Global.asax executed for an
application in a virtual directory? Please do some logging there to
verify that ActiveRecord is really initialized.

-Markus

2009/5/27 Bhumip <bhumi...@gmail.com>:

Bhumip

unread,
May 28, 2009, 2:07:46 AM5/28/09
to Castle Project Users
Hi Markus,

Each ASP.NET application has one Global.asax (Mandatory) file.

In which application_start, session_start, session_end,application_end
methods are existed.

Application_Start method executes first when application first time
run. (Only one time execute)

So I have initialized whole assembly (which contains all classes which
inherits ActiveRecord class).

====================================================

Now about problem

Problem is resolved.

I have removed following section from my current application. This
section is inherited by asp.net from root application web.config which
I described earlier. So Castle might not find which
“hibernate.connection.provider” use while initializing the
ActiveRecord. Even following section is under < activeRecord><config>
section.


====================================================
<add key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.dialect"
value="NHibernate.Dialect.OracleDialect"/>
<add key="hibernate.connection.driver_class"
value="NHibernate.Driver.OracleClientDriver"></add>
<add
key="hibernate.connection.connection_string" value="Data
Source=ora11g;User ID=test123;Password=test123;"/>
=====================================================

Thanks,

Bhumip
On May 27, 6:43 pm, Markus Zywitza <markus.zywi...@gmail.com> wrote:
> I don't know ASP.NET to well: Is Global.asax executed for an
> application in a virtual directory? Please do some logging there to
> verify that ActiveRecord is really initialized.
>
> -Markus
>
> 2009/5/27 Bhumip <bhumiph...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages