While porting MVC3 application to Mono I'm receiving this error:
System.InvalidProgramException
Invalid IL code in System.Web.Security.MembershipProviderCollection:.ctor (): method body is empty.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.
Exception stack trace:
at System.Web.Security.Membership..cctor () [0x00010] in C:\cygwin\sources\mono\mcs\class\System.Web\System.Web.Security\Membership.cs:105
MembershipProviderCollection
public static MembershipProviderCollection Providers
{
get
{
return Membership.providers;
}
}
It works as expected under .Net but not the mono 3.0.1 compiler. How can I fix or work around this?
This issue can be solved by removing the reference to System.Web, adding a reference to Mono's internal System.Web.ApplicationServices, and then re-adding the System.Web reference. Not a clue in the world why this doesn't work without first removing System.Web, but it doesn't.
Related
I have a java project written using spring-cloud-function and deployed in aws-lambda.
I am trying to return a custom exception with some fields in the exception message body, something like"
{
reason: <exception reason>
code: <error code>
<some other fields>
}
#ExceptionHandler, that is generally used in spring boot doesn't seem to work here.
I can return the exception in the required format by creating a class for building the exception message in required format but in that case the error code will always be 200 since it will not be an exception object per se. Instead it will be my custom error object.
Is there a way I can set this up so that the above required format of exception object is returned and correct error code can be returned too?
Thanks in advance
First, the exception has nothing to do with Spring Boot. It's part of spring-web, so yes it would not work here since s-c-function is a general purpose framework, where the same function could be deployed and triggered via web, streaming, aws-lambda etc. .
Now, yes we had a problem returning JSON error (as you show) or object that represents the same, but that was fixed. So please update s-c-function to 3.2.3.
I'm just using NewRelic error trapping for my coldbox application. From OnException method, I'm just sending the error struct to log the error.
My code in onexception method
public function onException(event,rc,prc){
NewRelic.logError( prc.exception.getExceptionStruct());
}
The logerror() method resides in NewRelic.cfc and contains the following code
public boolean function logError(
required struct exception
) {
var cause = arguments.exception;
var params = {
error_id = createUUID(),
type: arguments.exception.type,
message: arguments.exception.message
};
writeDump(this.newRelic);
this.newRelic.noticeError(cause, params);abort;
return true;
}
So while error, I'm gettig the following error.
The noticeError method was not found.
You can see that, the noticeError() method is there in the object, but it is overloaded with arguments.
I'm using the same code for NewRelic error trapping in another coldfusion project without any frameworks.
Calling error.cfm through Cferror tag, and the code in error.cfm as follows
<cfset Application.newRelic.logError( variables.error )>
And in NewRelic.cfc, the logerror() method contains the same code as in the coldbox application. But it is logging errors in NewRelic without any issues.
This is the method I need to notice errors and log it in NewRelic.
noticeError(java.lang.Throwable, java.util.Map)
So I just thought to get the classname of the first argument Cause through the following code from both applications within logError() in NewRelic.cfc, to get the difference.
writeDump(cause.getClass().getName());
I'm getting
coldfusion.runtime.ExceptionScope for Coldbox application
and
coldfusion.runtime.UndefinedVariableException for normal coldfusion application
The cause argument is not throwable from coldbox application. So how to get the original error struct from coldbox application? and make it throwable to fix the noticeError method was not found issue.
The change in the underlying class happens when ColdBox duplicates the error object with CFML's duplicate() method. I doubt that ColdFusion behavior is documented anywhere, but I don't see an easy way to get around it right now other than creating your own instance of a java.langException and populating it with the details of the original error.
If you want to modify the ColdBox core code, this happens here:
https://github.com/ColdBox/coldbox-platform/blob/master/system/web/context/ExceptionBean.cfc#L43
I have entered this ticket for the ColdBox framework for us to review if we can stop duplicating the error object in future versions of the framework.
https://ortussolutions.atlassian.net/browse/COLDBOX-476
Update: Adam Cameron pointed out this ticket in the Adobe bug tracker that details this behavior in the engine. It was closed as "neverFix".
https://bugbase.adobe.com/index.cfm?event=bug&id=3976478
I've just started digging into the new ASP.NET 5 by creating a test single page application with the OAuth login. I already know that I can use IdentityServer3 for that purpose and it seems pretty nice. I've found a post by Dominick Baier which is explaining how to set up the IdentityServer3. However, the post seems to be out of date or the identity server itself isn't working with the latest version of the ASP.NET 5 (which is beta7 at the moment).
The problem is, when I try to configure the IdentityServer in the Startup.cs I got an error from VS telling me that IApplicationBuilder has no extension method called UseIdentityServer. And this seems to be true, since in the IdentityServer3 source code they have this extension method declared for IAppBuilder (not IApplicationBuilder).
Here is my code (Startup.cs):
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Add MVC to the request pipeline.
app.UseMvc();
var options = new IdentityServerOptions
{
Factory = new IdentityServerServiceFactory()
};
app.UseIdentityServer(options);
}
And the error (on the last line) is
'IApplicationBuilder' does not contain a definition for 'UseIdentityServer' and the best extension method overload 'UseIdentityServerExtension.UseIdentityServer(IAppBuilder, IdentityServerOptions)' requires a receiver of type 'IAppBuilder'
Obviously, if I change the parameter type in the Configure method to IAppBuiler, it'll throw a runtime error because the dependency injection will not be able to inject that type. Even if it would, I'd lose the UseMvc() extension method.
So could you point me in the right direction please?
Perhaps I'm just missing something tiny but crucial here.
Thanks in advance!
I'm starting to use Spring integration and I don't know how to resolve this situation if it's possible.
I would like to 'catch' automatically every Exception who could happend in the service activators of my application and send this errors to a dedicated queue.
Gateway is not a solution because I need some custom code so I have to use service activator elements if I have correctly understood the principle.
I thought that something like would be ok:
<jms:outbound-channel-adapter channel="errorChannel"
connection-factory="jmsConnectionFactory" destination="oneErrorQueue"/>
That is not working. I don't know if errorChannel is used by spring integration for putting the errors in indeed.
thank you, It seems to work.
I've put the transformer listening to the error-channel of the inbound component starting the flow and it gets the MessagingException when an error happens in service activator. Now the problem is that this error doesn't arrive to my queue. I let you see the code:
<jms:message-driven-channel-adapter
channel="input-channel" concurrent-consumers="1"
max-concurrent-consumers="3" connection-factory="jmsConnectionFactory"
transaction-manager="jtaTransactionManager" destination="myQueue" error-channel="myErrorChannel"/>
<transformer input-channel="myErrorChannel" output-channel="create-error-channel" ref="errorTransporter" method="transform"/>
<jms:outbound-channel-adapter channel="create-error-channel"
connection-factory="jmsConnectionFactory" destination="creationErrorQueue" extract-payload="true"/>
...
And the transformer:
public class ErrorTransporter {
#Transformer
public Message<CreateCustomerOrder> transform(MessagingException exception) {
return (Message<CreateCustomerOrder>) exception.getFailedMessage();
}
}
Thanks in advance for helping!
Add an error-channel attribute to the inbound component that starts the flow
error-channel="myErrorChannel"
when an upstream component (such as your service invoked by the service-activator) throws an exception, the inbound component will put an error message on the error channel. The payload of that message is a MessagingException that has two properies:
failedMessage
cause
So, on your error flow, add a transformer...
<int:transformer input-channel="myErrorChannel"
output-channel="toJmsChannel"
expression="payload.failedMessage"
followed by your jms outbound channel adapter.
I'm using Castle Windsor for IoC. It's been working great, but all of a sudden every time I try to run my application, it fails during a ResolveAll call:
var resolved = container.ResolveAll<IValidator>();
It throws this exception:
System.ArgumentException occurred
Message=The number of generic arguments provided doesn't equal the arity of the generic type definition.
Parameter name: instantiation
Source=mscorlib
ParamName=instantiation
StackTrace:
at System.RuntimeType.MakeGenericType(Type[] instantiation)
at Castle.MicroKernel.Handlers.DefaultGenericHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired) in c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\MicroKernel\Handlers\DefaultGenericHandler.cs:line 51
InnerException:
The really odd thing is that it's been working great up until today. If I roll back to a version before it started doing this, even back to last week, I still get this error. I've tried rebooting, etc. Has anyone seen this before?
EDIT:
Here's how I'm registering the IValidator ones:
private void registerFromAssembly(IWindsorContainer container, Assembly assembly)
{
container.Register(
AllTypes.FromAssembly(assembly)
.BasedOn<IValidator>()
);
}
Here's how I'm registering the IPresenterResolver service:
container.Register(
Component.For<IPresenterResolver>()
.ImplementedBy<CommandLineArgumentPresenterResolver>()
);
I have to remove both of these to get the application to run now.
I had to download the Castle Windsor source code so I could debug it at the source of the failure. It turns out that I was incorrectly including some generic base type services where I was only expecting non-generic concrete implementations. I had to change my registration code to this to make it work:
private void registerFromAssembly(IWindsorContainer container,
Assembly assembly)
{
container.Register(
AllTypes.FromAssembly(assembly)
.BasedOn<IValidator>()
.Unless(type => type == typeof(FluentValidatorWrapper<>))
.Unless(type => type == typeof(PassEverythingValidator<>))
);
}
In this case FluentValidatorWrapper is a generic base type I use to build type-specific validators and PassEverythingValidator is a generic type that my validation logic manually instantiates when it can't find a type-specific validator. These shouldn't have been included in the container.
I made a note on the Castle Windsor mailing list that if the concrete type information had been included in the exception, it would have been easier to debug.