Enterprise Search for CS 2.1 thows securityexception error

rated by 0 users
This post has 10 Replies | 4 Followers

Top 25 Contributor
Posts 1,138
Points 35,955
MVPs
J-O Eriksson Posted: Wed, Aug 16 2006 11:08 AM

Couldn't find a forum for ES under the Add-ons forum group so I am posting my question here.

I have installed ES for CS 2.1 at one of my hosters. Running CS 2.1 on ASP .NET 2.1. I believe I have installed and configured it correctly, it seems that the jobs are running and all.

But in the eventlog I get errors like these

System.TypeInitializationException: The type initializer for 'Lucene.Net.Store.FSDirectory' threw an exception. ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c571934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.IO.Path.GetTempPath()
at Lucene.Net.Store.FSDirectory..cctor()
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.EnvironmentPermission
The Zone of the assembly that failed was:
MyComputer
--- End of inner exception stack trace ---
at Lucene.Net.Store.FSDirectory.GetDirectory(String path, Boolean create)
at ᐁ.ᐁ()
at ᐁ.ᐄ()
That made me wonder if ES is working under medium trust? Can anyone confirm, or are there suggestions to what could be wrong?
J-O

J-O Eriksson's blog
Top 25 Contributor
Posts 2,115
Points 27,605
MVPs
Are you on a shared host?  What I knwo from ES is it tries to index your site in file based manner on file system so probably you need more permissions for your blog (I guess RDC/RDP access is required).
  • | Post Points: 20
Top 10 Contributor
Posts 5,292
Points 49,195
CS Developers
It looks like it is trying to access some temp files but they are outside the application area, so under medium trust, it will throw an error.  I will see if there is any way to override where the temporary files should go.
  • | Post Points: 5
Top 10 Contributor
Posts 5,292
Points 49,195
CS Developers

From the looks if it, you need to specify a new lock directory for Lucene (basically, where it just does some work).

Create a folder for Lucene to use, then in the root web.config, you can create a new appSetting entry with the key "Lucene.Net.lockDir" and set it to the path of the folder.  I'd guess that you might need to set the full path and won't be able to just do "~/luceneTempFolder".

  • | Post Points: 20
Top 25 Contributor
Posts 1,138
Points 35,955
MVPs

Thanks I'll try that!

But wouldn't be the same problem if I need to use a full path for the lock dir for Lucent? I'll try and get back about the results

J-O

J-O Eriksson's blog
  • | Post Points: 20
Top 10 Contributor
Posts 5,292
Points 49,195
CS Developers
No, the problem doesn't have anything to do with using the full path, the problem is that right now, it is trying to write to a folder that is outside of the application's directory tree.  Under medium trust, an application can only edit its own folder or folders within its own area.  When it goes outside of that, it throws a security exception.  So as long as you tell lucene to use a folder that is within the application's own area, it will work fine.
  • | Post Points: 5
Top 25 Contributor
Posts 1,160
Points 70,210
CS Developers

The lucene jobs should really be run under the Jobs Service, not under the web.  The Optimize job is very sensative to applicaiton restarts, and should not be run under the web jobs service...  it does a nice job of filling up your hard drive Smile

Dan

  • | Post Points: 20
Top 25 Contributor
Posts 1,138
Points 35,955
MVPs
DanBartels:

The lucene jobs should really be run under the Jobs Service, not under the web. 

I don't know what you mean by that. If you mean Jobs Service as in a Windows Service, then it's out of the question for me since I run this on a shared hosting and I can't install Windows Services there.

Going back to the things Ken suggested I also found http://www.dotlucene.net/documentation/RunningDotLuceneonaShared.html confirming what Ken had said, and also showing that the key should be: Lucene.Net.lockdir instead of Lucene.Net.lockDir.

But it still seems to generate the same errror:

System.TypeInitializationException: The type initializer for 'Lucene.Net.Store.FSDirectory' threw an exception. ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.IO.Path.GetTempPath()
at Lucene.Net.Store.FSDirectory..cctor()
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.EnvironmentPermission
The Zone of the assembly that failed was:
MyComputer
--- End of inner exception stack trace ---
at Lucene.Net.Store.FSDirectory.GetDirectory(String path, Boolean create)
at ᐁ.ᐁ()
at ᐁ.ᐄ()

 What I have now it the following in web.config:

<add key="Lucene.Net.lockdir" value="D:\inetpub\communityserver\CSSearch\" />

At the top of CS.config I have:

<Search path = "D:\inetpub\communityserver\CSSearch\" iFilterExtensions = "doc,txt,htm,html,rtf,pdf,xml,xls,ppt" SearchAcrossSettingsBoundaries="false" />

[UPDATE}

The pipes chars in the paths above is something that CS or tinyMCE does, it should've been backslashes

[/UPDATE]

J-O

J-O Eriksson's blog
  • | Post Points: 5
Top 25 Contributor
Posts 1,138
Points 35,955
MVPs
Any suggestion on how I could continue troubleshooting?
J-O

J-O Eriksson's blog
  • | Post Points: 20
Top 25 Contributor
Posts 1,160
Points 70,210
CS Developers

The Enterprise Search Jobs were not designed to be run in a shared hosting environemnt, They likely require full trust, but are also too fragile to handle applicaiton restarts...  Applicaiton restarts while the jobs are running, will cause posts to not get indexed (ever) by your site...  Further applicaion restarts during the optimization job, will cause lucene to leave all of its temporary index files in your index directory, and it will not be able to clean them up...  and finally, Lucene.NET.dll uses a "lot" of ram...

If you have to do shared hosting, then you should consider building your lucene index offline, and just uploading the index files to your web server....  Doing this on a daily basis, based off your nightly SQL backup is probably your best bet.

Dan

  • | Post Points: 20
Top 25 Contributor
Posts 1,138
Points 35,955
MVPs
OK Dan, thanks! I'll look into building the index offline.
J-O

J-O Eriksson's blog
  • | Post Points: 5
Page 1 of 1 (11 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com