I'm writing a code that needs to be compatible with both Quarkus and Spring DI.
I am using both DI and Spring Boot Properties extensions, the Spring Boot Extension. It works fine, apparently, but the injection of any other object from the external dependency that was annotated as a bean doesn't get injected anywhere. Quarkus doesn't seem to recognize it.
Is this some kind of limitation with the Spring DI Extention?
I already tried to use the quarkus.index-dependency property and also tried to include the dependency structured as a Quarkus Extention, but it didn't work.
EDIT 1:
As stated by #Kolossus, adding the beans.xml resolved the DI issue, but i'm having another error related to the properties class:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: Found 3 deployment problems:
[1] Ambiguous dependencies for type com.properties.IntegrationProperties and qualifiers [#Default]
- java member: com.authorization.AuthenticationService#<init>()
- declared on CLASS bean [types=[com.authorization.AuthenticationService, java.lang.Object], qualifiers=[#Named(value = "authenticationService"), #Default, #Any], target=com.authorization.AuthenticationService]
- available beans:
- CLASS bean [types=[com.properties.IntegrationProperties, java.lang.Object], qualifiers=[#Default, #Any], target=com.properties.IntegrationProperties]
- PRODUCER METHOD bean [types=[com.properties.IntegrationProperties, java.lang.Object], qualifiers=[#Default, #Any], target=com.properties.IntegrationProperties produceIntegrationProperties(org.eclipse.microprofile.config.Config), declaringBean=io.quarkus.arc.runtime.config.ConfigPropertiesProducer]
Ambiguous dependencies in all the Injection Points for the properties class.
Adding the beans.xml to the dependency solved my problem. The problem with the properties class was that the class was annotated like this:
#Configuration
#ConfigurationProperties(prefix = "some-prefix")
public class IntegrationProperties
So Quarkus was creating 2 beans of the same type, one because of the #configuration and the other because of the #ConfigurationProperties.
I fixed it by adding #EnableConfigurationProperties(IntegrationProperties.class)
in another configuration class.
How do I subscribe to an event implemented in F# from a C# client?
I have the following code:
_dispatcher.SignInRequested += StartActivity(typeof(SignInActivity));
This line results in the following error:
Error CS0012 The type 'FSharpHandler<>' is defined in an assembly that
is not referenced. You must add a reference to assembly 'FSharp.Core,
Version=3.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I attempted to troubleshoot and found this:
However, I do not understand the answer. My events are defined under a namespace and not a module. Hence, me not understanding the reasoning of that discussion.
I then tried adding the following reference to my C# project:
FSharp.Core 4.0.0.1
and
FSharp.Core 3.1.2.5
However, I still receive the same error.
When managing Nuget packages, I do not see the version "3.3.1.0" listed as an option.
Implementation Details:
The signature of the signin event from the C# client is the following:
public event FSharpHandler<Unit> SignInRequested;
I actually declare the event as the following:
let signInRequested = new Event<_>()
Any suggestions?
You need to have a look at the CLIEventAttribute . Events declared from F# cannot be used from C# unless they are declared with this attribute.
I am new to unity dependency injection, and I'm using mvc and DI in my project. I used an interface ICUS and then created one class that is implements it.
When I resolve this class, I get the following error:
InvalidOperationException - The type iCUS does not have an accessible
constructor Resolution of the dependency failed, type =
"GG.Framework.Configuration.iCUS ", name = "(none)". Exception
occurred while: while resolving. Exception is:
InvalidOperationException - The type iCUS does not have an accessible
constructor.
At the time of the exception, the container was: Resolving
GG.Framework.Configuration.iCUS, (none)
Can anyone help with this please?
When attempting to run an ASP.NET MVC application which uses Castle Windsor, the following error occurs.
Server Error in '/' Application.
Inheritance security rules violated while overriding member:
'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'.
Security accessibility of the overriding method must match the
security accessibility of the method being overriden.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Inheritance security
rules violated while overriding member:
'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'.
Security accessibility of the overriding method must match the
security accessibility of the method being overriden.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[TypeLoadException: Inheritance security rules violated while
overriding member:
'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'.
Security accessibility of the overriding method must match the
security accessibility of the method being overriden.]
Castle.Windsor.WindsorContainer..ctor() +0
The assemblies Castle.Core.dll and Castle.Windsor.dll have been built off the source code available on github. The source code for the assemblies includes the file SecurityAssemblyInfo.cs which has the following source code:
// Sets up assembly level security settings
#if ! SILVERLIGHT
[assembly: System.Security.AllowPartiallyTrustedCallers]
#if DOTNET40
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level2)]
#endif
#endif
I have verified using ILSpy that the System.Security.AllowPartiallyTrustedCallers attribute is declared at the assembly on both files.
The web application is being run with <trust level="Medium" />.
I have been able to get a successful build + run of my mvc application by making the following changes to Castle.Core:
SecurityAssemblyInfo.cs:
Changed to only the following:
[assembly: System.Security.AllowPartiallyTrustedCallers]
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
ProxyGenerator.cs:
Changed three lines in ProxyGenerator::ProxyGenerator(IProxyBuilder):
if (HasSecurityPermission())
{
Logger = new TraceLogger("Castle.DynamicProxy", LoggerLevel.Warn);
}
becomes:
// if (HasSecurityPermission())
// {
// Logger = new TraceLogger("Castle.DynamicProxy", LoggerLevel.Warn);
// }
I have no idea what sort of consequences these might have. It would be nice if someone familiar with the SecurityRuleSets could chime in on the first part, and #Krzysztof Koźmic could advise me on why I had to comment out the trace logger.
I am getting this error while loggin into eventviewer. I am looging the exception in event viewer as well as rolling flat file. If i remove the eventviewer section then rolling flat file works perfectly, but only when i add this it gives the exception
{"Resolution of the dependency failed, type =
\"Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter\", name =
\"(none)\".\r\nException occurred while: while resolving.\r\nException
is: InvalidOperationException - The type TraceListener cannot be
constructed. You must configure the container to supply this
value.\r\n-----------------------------------------------\r\nAt the
time of the exception, the container was:\r\n\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl,LogWriter.default
(mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter,
(none))\r\n Resolving parameter \"structureHolder\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder
structureHolder,
Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider
instrumentationProvider,
Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator
updateCoordinator)\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,LogWriterStructureHolder.default
(mapped from
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,
(none))\r\n Resolving parameter \"traceSources\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(System.Collections.Generic.IEnumerable1[[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35]] filters,
System.Collections.Generic.IEnumerable1[[System.String, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
traceSourceNames,
System.Collections.Generic.IEnumerable1[[Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35]] traceSources,
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
allEventsTraceSource,
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
notProcessedTraceSource,
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
errorsTraceSource, System.String defaultCategory, System.Boolean
tracingEnabled, System.Boolean logWarningsWhenNoCategoriesMatch,
System.Boolean revertImpersonation)\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,General\r\n
Resolving parameter \"traceListeners\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(System.String
name,
System.Collections.Generic.IEnumerable1[[System.Diagnostics.TraceListener,
System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]] traceListeners,
System.Diagnostics.SourceLevels level, System.Boolean autoFlush,
Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider
instrumentationProvider)\r\n Resolving
System.Diagnostics.TraceListener,Event Log Trace Listener\r\n"}
I had the same problem and it was due to an error in my configuration file. I referenced trace listeners from my categorySources section which did not exist in my listeners section. I removed the categories and the mappings (i did not use them anyway) and then it worked. I guess you can validate your configuration file in the configuration console and then it will tell you what the problem is.
1 - Make sure you are referencing the correct DLLs
Microsoft.Practices.EnterpriseLibrary.Logging
Microsoft.Practices.EnterpriseLibrary.Common
2 - Make sure your configuration file is in the right location (in the same project or in a references project)
3 - Make sure your configuration file is correct. Editing it with the Enterprise Library Configuration Tool, nothing should be in red. Try expanding all trace listeners, categories, etc. The most common error is that one of the Special Categories is pointing to a non existing Listener.
I had a similar experience with ExceptionHanlder., I switched over to using Unity container directly after playing around with intro material re: logging.
I basically just copied the examples from the Help files and briefly wondered why it wasn't working and errored on Type Resolution; Could not resolve.
The answer was simple enough. I had only "played" with logging prior to switching to Unity container but the examples I was using/copying were using both Logging and Exception Handling injection.
Since I hadn't "played: with Exception Handling in 5.0, there were no entries for this in the configuration file, hence the reason why Unity could not resolve.
Solution: take 5 seconds to add the ExceptionHandling block into the config file using the tools and I was good to go and keep on "playing".
Unity needs the entries for each resolved block in the config file even if they are not Named / customised. This is rediculously obvious but easily overlloked if you are hacking away with example code for learning purposes.
I got this error because a database listener was set with a connection string that didn't exist.
To help diagnose, comment out the listener lines and then add them again one by one.
I got this error when moving the app to another server, and in my case, it was the initializeData field, which sets the path for the log file, was not valid, and it was not able to create the log file at startup.
When i edited and put a valid path for the log to be created, it worked ok.
Hope it helps someone.