Seam with Postgresql. NullPointerException until I drop and re-create table - seam

On local dev environment. Periodically (a few times per day) my Client table seems to get 'corrupted' and my ClientList.xhtml page crashes with a cryptic null pointer exception. It sometimes happens when I edit a client, but I don't know how exactly to recreate the problem. I fix it by dropping and recreating the table. My question is what could be happening that is fixed by dropping and recreating the table?
setup is Seam 2 and postgresql 9.0.4. Basic seam-gen generated crud forms.

Please post the following so we can help:
Stack trace for the NullPointerException
Source code for the Client entity
Data from the problem Client record (if you know it)

Related

ASP.NET Connection loss handling

How would you go about and handle lost data from a sql connection loss on a ASP.NET application.
Lets say your running an algorithm adding and removing certain roles. A midst it, the connection to the SQL database is lost. And because the connection is not there, wont even be able to backtrack the steps done. The whole state is lost, leaving the database in an error nous condition.
Would you set the IIS Rapid Fail Protection to shut the site down upon 1 exception and manually force the function to run again (after connection have been fixed).
Or how is the professional way of handling it, i am quite new to it. Maybe there's something i do not know of it (such as iis maybe trying to rerun it/caching)
(Using entity framework)
This is not a coding problem in its own way, it is more of a question of best practice handling data loss with sql database on asp.net
You need to do batch SQL Operations inside a SQL Transaction. So that whatever the error, a rollback happens. This is a built-in SQL feature and nothing special needs to be done.
Once you start a SQL Transaction, a Commit is issued only when all operations succeed. The default behavior is normally Rollback in case of all other non-success scenarios.
If you're encountering issues with any specific logic, post the code snippet and we're glad to help.

How to get more info on NHibernate's Illegal attempt to associate a collection with two open sessions

Our project has been using NHibernate with success for quite some time. However, in the last months of new development we managed to make a change that gives us lots of:
NHibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
This shows up on our test server. It does not/hardly happen on our development systems.
Question: Is there a way to find some more info about this exception. It would help if we knew e.g. which Collection is giving the problem.
We tried NHibernate Profiler but that does not give that type of information.
Thanks, Willem
NHibernate uses (by default) log4net for logging.
You can configure it, set the DEBUG level for the root logger, and you'll get all the possible information about the inner workings of NHibernate related to the error.
Of course, you can also get a stack trace of your own code, figure which calls are causing the exception, and post them here.

LINQ to SQL Stored Procedure. Exception says it times out but it is not timing out

Website using .NET Framework v3.5, SQL Server 2008, written in C#
I have a stored procedure which I have added to my DBML by dragging it across from the server explorer.
In it's properties it returns Auto-generated type.
The procedure takes < 1 second to run from within SQL Mgmt Studio for all inputs.
However from the code for 1 particular input (which takes < 1 second in the Mgmt studio) it hangs and then throws:
System.Data.SqlClient.SqlException: Timeout expired.
This didn't always happen for this one input! It used to also work fine when called from the code. The last time it didn't work I deleted and re-added the same stored procedure to the DBML. This "fixed" it, and that input ran fine and in the same time as all the others. However this is not an adequate fix! It has happened again and I can't keep deleting and re-adding as required.
I made no changes to the data that's being returned during the point at which it was "fixed", so I can't think what the problem could be. Any help on this would be much appreciated!
Exception says it times out but it is
not timing out
If it says it's timing out, it's timing out. The only question is "why"?
Run a SQL Server Profiler trace against your database and see what query is actually going to the server. It's possible that another query is being issued too. It's possible there is another transaction interfering in your production scenario.
It turns out that this is parameter sniffing - this is explained in another post: Executing stored proc from DotNet takes very long but in SSMS it is immediate
Also, be sure that the stored procedure is not being held up inside of a transaction, waiting for another process to complete. I just ran across this with a Linq to Sql stored procedure being called multiple times within a transaction. It gave me a timeout expired error and I just realized it was waiting for a previous call to complete, and thus timing out.

Object reference not set to an instance of an object-datacontext

I am trying to publish asp.net mvc site on remote server I am getting the error as shown in figure. Any idea
I solved it the problem was that in the designer file connection name was different then that of web.config. Once both name are same it started running fine.
Any chance you could post a larger scale of the image, the stack trace is very tricky to read.
As a guess, it looks like the exception is being raised in the database context area of code - possibly Entity Framework??
First, have a look at the Models.EvloetDatabaseContext constructor - is there anything in there that might cause the null reference exception?
You could put some Trace.WriteLine calls in that method and use a tool such as DebugView to see how many of those messages are being sent out. I use his often when debugging issues on a client's server.

LINQ-to-SQL retrieving data from a different query!

I have a web application that uses LINQ-to-SQL. It has a very strange issue, where a LINQ command retrieves the data that is supposed to be returned by another, totally different query that runs in a different thread. What could be the cause of this?
Specifically, a user accesses the application from his machine, opening a certain page. At the same time, another user accesses a different page from his (different) machine. One of the queries throws an exception, while the other returns the data of the first one, which comes from a very different table!
The case is always reproducible, whenever we stress the application with these two users. I've checked but I don't see any shared variables of any kind. What else could the problem be? What should I be looking for?
Your help is really appreciated.
Sounds like a connection is being reused. Make sure not to cache those and always create and release them properly, such as in this sample.
You sure this isn't a session issue rather than a linq issue? Data requested from one asp.net session but passed over to another sounds like something's getting mixed up there.

Resources