Reputation: 53
some times in Neo4jClient I got this error. I try to investigation whats the problem but I don't found any reason. Does any one have the same problem or can help me?
Thanks
{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":" at
Neo4jClient.GraphClient.Neo4jClient.IRawGraphClient.ExecuteGetCypherResults[TResult](CypherQuery query) in D:\temp\9517fa3\Neo4jClient.Shared\GraphClient.cs:line 919\r\n at
Mandarim.Storage.Neo4j.Manager.ManagerBase1.GetNodesRelatedOrderBy(String match, String id, String relationNodeType, String propertyOrderBy, Int32 skip, Int32 take, Direction direction,
Boolean distinct, Expression
1 where) in P:\Desenvolvimento\branchs\builder-3.0\Mandarim.Storage.Neo4j\Manager\ManagerBase.cs:line 2105\r\n at
Mandarim.Storage.Neo4j.Manager.ManagerBase1.GetNodesRelatedOrderBy(String id, Labels labelin, Labels labelout, String relationTypes, String propertyOrderBy, Int32 skip, Int32 take, Boolean
distinct, Expression
1 where, Direction direction) in P:\Desenvolvimento\branchs\builder-3.0\Mandarim.Storage.Neo4j\Manager\ManagerBase.cs:line 900\r\n at
Mandarim.Factory.Base.FactoryBase1.GetNodesRelatedOrderBy(String id, Labels labelin, Labels labelout, String relationTypes, String propertyOrderBy, Int32 skip, Int32 take, Boolean distinct,
Expression
1 where, Direction direction) in P:\Desenvolvimento\branchs\builder-3.0\Mandarim.Factory\Base\FactoryBase.cs:line 177\r\n at
PackDocs.Services.Storage.MandarimStorageServices1.GetNodesRelatedOrderBy(String id, Labels labelin, Labels labelout, String propertyOrderBy, Int32 skip, Int32 take, Boolean distinct,
Expression
1 where, Direction direction, RelationTypes[] relationNodeType) in P:\Desenvolvimento\branchs\builder-3.0\Packdocs.Services.Storage\MandarimStorageServices.cs:line 292\r\n
at Mandarim.PackDocs.Services.ManagerObjects.ManagerProject.GetProjects(Int32 skip, Int32 take, String orderby, CreatedState state) in
P:\Desenvolvimento\branchs\builder-3.0\PackDocs.Services\ManagerObjects\ManagerProject.cs:line 116\r\n at PackDocs.OWIN.Services.Host.Controllers.ProjectsController.GetProjects(Int32
skip, Int32 take, String orderby, CreatedState state) in P:\Desenvolvimento\branchs\builder-3.0\Packdocs.OWIN.Services.Host\Controllers\v2\ProjectsController.cs:line 103\r\n at
lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[]
methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken
cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at
System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at
System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at
System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"}
Update
ContainerBuilder _builder = new ContainerBuilder();
_builder
.Register<ITransactionalGraphClient>(context =>
{
try
{
var neo4jUri = GetNeo4jSettingValue("neo4jUri");
var user = GetNeo4jSettingValue("neo4jUser");
var pwd = GetNeo4jSettingValue("neo4jPassword");
ITransactionalGraphClient graphClient = new GraphClient(new Uri(neo4jUri), user, pwd);
graphClient.Connect();
graphClient.JsonConverters.Add(new DictionaryConverter());
graphClient.JsonConverters.Add(new DateTimeConverter());
graphClient.JsonConverters.Add(new CommonDeserializerMethods());
return graphClient;
}
catch (Exception e)
{
Trace.TraceError(e.ToString());
throw e;
}
}).SingleInstance();
_container = _builder.Build();
Get Instance
try
{
_myGraphClient = _myGraphClient ?? AutofacNeo4j.Container.Resolve<ITransactionalGraphClient>();
if (_myGraphClient != null && !_myGraphClient.IsConnected)
_myGraphClient.Connect();
return _myGraphClient;
}
catch (Exception e)
{
Trace.TraceError(e.ToString());
_myGraphClient = _myGraphClient ?? AutofacNeo4j.Container.Resolve<ITransactionalGraphClient>();
_myGraphClient.Connect();
return _myGraphClient;
}
My query:
MyGraphClient.Cypher
.Match(match).Where((T a) => a.UUID == id)
.With("b")
.CurrentUser(CurrentUsername)
.WhereReadClause("b", GetDomainsClause("b"), CurrentUsername, CurrentRole, direction)
.Return(b => b.As<T>()).Results;
Second exception:
Neo4jClient.Transactions.TransactionManager.EnqueueCypherRequest(String commandDescription, IGraphClient graphClient, CypherQuery query) in D:\temp\9517fa3\Neo4jClient.Full\Transactions\TransactionManager.cs:line 229
at Neo4jClient.GraphClient.PrepareCypherRequest[TResult](CypherQuery query, IExecutionPolicy policy) in D:\temp\9517fa3\Neo4jClient.Shared\GraphClient.cs:line 871
at Neo4jClient.GraphClient.d__881.MoveNext() in D:\temp\9517fa3\Neo4jClient.Shared\GraphClient.cs:line 967
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()
at Mandarim.Storage.Neo4j.Manager.ManagerBase`1.d__113.MoveNext() in P:\Desenvolvimento\branchs\builder-3.0\Mandarim.Storage.Neo4j\Manager\ManagerBase.cs:line 2067
Upvotes: 0
Views: 339
Reputation: 53
The problem occurs when we use async api with multi-transaction here. The [TreadStartic] on Neo4jClient code don't work very well with async method... so I change to use AsyncLocal.
More information can get here: https://github.com/Readify/Neo4jClient/pull/209
Upvotes: 0