A storage mechanism has already been configured for this application - asp.net-mvc

I am getting this error whenever my S#arp Architecture attempts to start and this is an problem with SQL Server (for example: SQL Server is not runing), after I start SQL Server and hit refresh, I get this error:
A storage mechanism has already been configured for this application

NHibernateSession.Init() or InitStorage() is being called more than once. You're probably calling it every request, it's supposed to be called only once at startup.

In an old application I have to maintain, this happened when the application start had issues. So I just had to recycle the application pool in IIS.

Try to add this line before calling NHibernateSession.Init() to clear any previous initiation.
try{ NHibernateSession.Reset(); } catch { }

Related

Dynamic connection to DB in grails

Iam using two data sources in grails application one is local db and the other is remote.
When am running the application if any one of the DB is not accessible then the application is not running .
I don't want this to happen I want to run the application atleast the home page where no database connection is required.
Please help me on this scenario that how to configure my application ..
Well the straight answer is NO. you can not get your application up unless your datasources have successfully loaded. Whenever there is any problem in making the datsource, an exception is thrown and the execution of the application is stopped, it is assumed that the application may not be able to work properly if there is error in creating datasources.
But you can have a work around by loading the datasources dynamically from the bootstrap. You can follow the link to load hibernate datasource dynamically.
In this case you will not keep the datasource info in the Config but put them in a properties file and load them to load the datasource. You can also keep it in try-catch block to hamndle the exception.

How to deploy client-side service WSDLs

I have code using the SysOperationFrameworkService, and after a model-deploy or some other set of circumstances, many users get Function SysOperationDataContractInfo::newParameterInfo has been incorrectly called..
It's unable to be resolved with full-compile, sync, full CIL, deleting XPPIL files, deleting AUC/KTI, usage data, security (they're admin), refreshing caches (server &client), etc. and I have a ticket open with Microsoft and they're struggling.
I've narrowed the issue down to when the service group AxClient located in the AOT at \Service Groups\AxClient WSDL files get deployed to C:\Users\[User]\AppData\Local. Either those files existing there, or something happening when those files get deployed is needed.
Any idea how/what causes these files (AxClient.wsdl, etc) to be created? With a user who happens to be "working", I can close the client, delete all the files, open the client, and no files will exist...then I perform a SysOp process and those files get created during that process. With the non-working user, with same security on the same machine does it, the files don't get created.
I have found that the
"Function SysOperationDataContractInfo::newParameterInfo has been incorrectly called" has been throwed because of a possible bug in the kernel when calling the "dictMethod = new DictMethod(UtilElementType::ClassInstanceMethod, dictClass.id(), methodName);" in the SysOperationServiceController.getServiceOperation() method. In my case the new DictMethod was sometimes unable to get the method parameter from a superclass, causing the _parentMethodParameterName check fail in the SysOperationDataContractInfo.newParameterInfo.
So, I solved the issue just by doing an override of the super method where the parameter could not be retrieved and then just calling super(_parameter), then everything went well.
Have you tried axclicfg.exe -> connections -> refresh

When using Neo4j embedded in a tc-server instance database is not shut down cleanly

It appears that shutdown() is not being called properly on my embedded neo4j database when tc server is stopped (just running this within STS).
Here is the log message I see:
16:03:43.358 [localhost-startStop-1] INFO neo4j.xafactory - Non clean shutdown detected on log [/home/billy/target/data/graph.db/nioneo_logical.log.1]. Recovery started ...
INFO: Non clean shutdown detected on log [/home/billy/target/data/graph.db/index/lucene.log.1]. Recovery started ...
I searched the Spring forums and SO for similar issues and all I found was this post
However I don't think that is relevant here as Spring should be handling this when the context is shutdown.
<neo4j:config storeDirectory="target/data/graph.db"/>
<neo4j:repositories base-package="com.example.repository"/>
The XML Parser for this tag clearly registers the shutdown() destroy method on the bean.
private String handleStoreDir(Element element, ParserContext context, BeanDefinitionBuilder configBuilder) {
String storeDir = element.getAttribute("storeDirectory");
if (!hasText(storeDir)) return null;
BeanDefinitionBuilder graphDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(EmbeddedGraphDatabase.class);
graphDefinitionBuilder.addConstructorArgValue(storeDir);
graphDefinitionBuilder.setScope("singleton");
graphDefinitionBuilder.setDestroyMethodName("shutdown");
context.getRegistry().registerBeanDefinition(GRAPH_DATABASE_SERVICE, graphDefinitionBuilder.getBeanDefinition());
configBuilder.addPropertyReference(GRAPH_DATABASE_SERVICE, GRAPH_DATABASE_SERVICE);
return GRAPH_DATABASE_SERVICE;
}
Also don't be confused by my log message my DB is not actually in the webapps directory the path to the application on the app server is actually:
/home/billy/DevTools/springsource/vfabric-tc-server-developer-2.8.2.RELEASE/base-instance/wtpwebapps
Has anyone else encountered this issue, and figured out how to solve it? For my small example application it is not a big deal but it is not a message I want to see if I choose this technology for my production application.
Peter is right. This is not an issue with Neo4j or even with Spring Neo4j. Apparently when running a local developer copy of tc-server within STS and choosing to stop the server, STS hard kills it rather than sending a shutdown signal which would have otherwise caused a context destroyed event to be sent to the dispatcher servlet. Therefore the lifecycle events are never called on the Spring context and nothing gets cleaned up. This really should be an issue on the STS issue tracker. I will most likely follow up on this when I get a few moments.

Db4O - DatabaseFileLockedException when restarting server

I am developing VAADIN using Db4O for storage. Normally, I love the fact that I can change the source code, save it, and voi-lá: the server gets automatically restarted and I can see the changes in the browser.
But always when I restart the tomcat server I get a DatabaseFileLockedException. My workaround is to stop the server, and start it again. But doing this manually every 1 minute is annoying.
INFO:
I am using the client server configuration, but the VAADIN application itself is the DB4O server (other applications get connected to it):
ServerConfiguration serverConfig = Db4oClientServer.newServerConfiguration();
//Configure server...
ObjectServer server = Db4oClientServer.openServer(serverConfig, DBFILE, PORT);
server.grantAccess(...); //GRANT ACCESS TO OTHER APPLICATIONS
//LOCAL USE ONLY:
private ObjectContainer client = server.openClient();
//PS.: I never close the client locally. Can that be a problem?
Does someone know how to get rid of this?
Thanks in advance.
Hmm, do you even close the server. Otherwise the db4o server will keep running and produce this exception.
Is there some 'shutdown'-callback in VAADIN? Thats usually the place to close the db4o server. When you close the server all local and remote client connections will be shut down aswell or will throw an exception when accessing them the next time.

Starting a windows service fails with error 1053

I have a windows service that is failing to start, giving an error "Error 1053: The service did not respond to the start or control request in a timely fashion".
Running the service in my debugger works fine, and if I double click on the the service .exe on the remote machine a console window pops up and continues to run without problem - I can even see log messages showing me that the program is processing everything the way it should be.
The service had been running fine previously, though this is my first time, personally, trying to deploy it with the most recent changes made to the program. I've evaluated those changes and cant figure out how they might cause this problem, particuarly since everything runs fine when not started as a service.
The StartRoutine() method of the service impelmentation is empty, so should be returning in a "timely fashion".
I've checked the event logs on the computer, and it doesn't give any additional information other than it didn't hear back from the service in the 30 second requisite time frame.
Since it works on my machine, and as a double-clicked executable, how would I go about figuring out why it fails as a service?
Oh, and it's .NET 2.0, so it shouldn't be affected by the 1.1 framework bug that exhibited this symptom (http://support.microsoft.com/kb/839174)
The box is a windows server 2003 R2 machine running SP2.
This is a misleading error. It's probably an unhandled exception.
Empty your OnStart() handler then try this in your constructor...
public MainService()
{
InitializeComponent();
try
{
// All your initialization code goes here.
// For instance, my exception was caused by the lack of registry permissions
;
}
catch (Exception ex)
{
EventLog.WriteEntry("Application", ex.ToString(), EventLogEntryType.Error);
}
}
Now check the EventLog on your system for your Application Error.
Could be a number of things and it might help to get a stack trace on the machine exhibiting the problem. There are a number of ways to do this but the point is that you have to see where this is failing in the code.
You can do this with remote debugging, but a simple thing might be to just log to the event logger, or file log if you have that. Literally, putting "WriteLine("At class::function()") throughout portions of the code to see if you've made it there.
This will at least get you looking in the right direction (which ultimately is the code).
Update:
See Microsoft's How to Debug Windows Services article for details in troubleshooting startup problems using WinDbg.
This related question details nice ways to debug services that are written in .NET.
I agree with Scott, the easiest way to find out what's happening is to put some traces in the start-up code (maybe it doesn't even come to your start-up code).
If this doesn't help, you can post your code here so others can take a look.
perhaps lacking some dependence, try this :
- deregister your service
- register again
If fail at register means that lack an module.
If the StartRoutine is empty, you are probably starting it somewhere else.
IIRC you need to fire off a worker thread, and then return from StartRoutine.
One of the problems which may lead to this error is if windows service which needs to be deployed consists of some error i.e it may be simple authorization error or anything as in my case I have referenced some folders and files for logging which were not existing, but when provided the right path of those file and folders it solved my problem.
I ran through every post on this particular subject and none of the responses solved the problem, so I'm adding this response in case this helps someone else. Admittedly this only applies to a new service, not this specific case.
I was writing a File listening service. As a console app, it worked perfectly. When I ran it as a service, I got the same error as above. What I didn't know (and many of the MSDN articles about services conveniently leave out) is that you need to have your class executed from within ServiceBase.Run( YourClassName());. Otherwise, your app executes and immediately terminates and because it terminated, you get the error above even if no error or exception occurred. Here is a link to an article about this. It actually discusses setting up your app for dual use - Console app and service: Create a combo command line / Windows service app
I had that issue and the source of my problem was config file. I edited it in notepad and notepad added one special character which cause service not to run properly because config file was ruined. I saw that special character in notepadd++ and after delete it, service started to run successfully as previous did.
In my case, the correct .NET framework was not installed on the server that I was installing the Windows service on.
One other reason is If you copy the DLL in 'debug' mode to installation folder this issue will come.What you need to do is Run the project in 'Release' mode copy the DLL or directly form Release folder rather than Debug folder,,and copy that DLL in to installation folder,it will work.You can see the reduction in size of DLL ,it will not contain any debug symbols and like that

Resources