I have a simple CXF RS bundle deployed in Fuse 4.2 that works fine upon initial installation. But, when I update or re-install the bundle, the REST service in no longer accessible.
I tried a various configurations and found that using cxf-extension-osgi was the issue...
from this...
<import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"/>
to this...
<import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
Also, I updated the address to be non-relative...ending up with this configuration (that works after bundle restarts, etc)
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
<jaxrs:server id="testService" address="http://localhost:9000/">
<jaxrs:serviceBeans>
<ref bean="testBean" />
</jaxrs:serviceBeans>
</jaxrs:server>
Any idea what is causing this issue when using cxf-extension-osgi? Also, what is the trade-off when using cxf-extendsion-http-jetty instead (functional, performance, etc)?
thanks
Sorry, it seems to be error in cxf/servicemix integration. The problem is, cxf tries to register service under the address that is already used (by older version of this service).
Both REST and SOAP services are unaccessible after bundle restart/update. Restart of whole servicemix. Hovewer, when business logic is in other bundle, and the bundle with SOAP/REST service contains only interface, restart is needed only when interface has changed.
We were fighting with this error long, but unfortunatelly without effort.
I just tested this in Fuse 4.3.0-fuse-03-00 and it seems to work fine. The related issue below must have addressed my issue as well...
https://issues.apache.org/jira/browse/CXF-2947
Related
I have an .NET Core 2 powered API that I would like to add Hangfire to. The project is already using NLog to log to a MySQL database and it works fine, but when I try to setup and use Hangfire I get the following error:
Method not found: 'Hangfire.Logging.ILog Hangfire.Logging.LogProvider.GetCurrentClassLogger()'.
The Hangfire dashboard works, but I get that error when trying to enqueue my first job like this:
BackgroundJob.Enqueue(() => Console.WriteLine("Fire-and-forget"));
I have read the Hangfire documentation over at:
http://docs.hangfire.io/en/latest/configuration/configuring-logging.html
and it says:
Starting from Hangfire 1.3.0, you are not required to do anything, if your application already uses one of the following libraries through the reflection (so that Hangfire itself does not depend on any of them). Logging implementation is automatically chosen by checking for the presence of corresponding types in the order shown below.
That list includes NLog, so apparently I am doing something wrong.
In my csproj I have:
<PackageReference Include="Hangfire" Version="1.6.19" />
<PackageReference Include="Hangfire.MySqlStorage" Version="1.0.5" />
<PackageReference Include="MySql.Data" Version="8.0.11" />
<PackageReference Include="NLog" Version="4.5.3" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.5.2" />
In Startup.cs and ConfigureServices I have:
services.AddHangfire(config => config.UseStorage(new MySqlStorage(appSettings.GetConnectionString("HangfireConnectionString"))));
and in Configure I have:
loggerFactory.AddNLog();
env.ConfigureNLog("nlog.config");
app.UseHangfireDashboard();
app.UseHangfireServer();
My nlog.config contains:
<target name="database" xsi:type="Database" dbProvider="MySql.Data.MySqlClient.MySqlConnection, MySql.Data" connectionString="server=localhost;Database=nlog;user id=root;password=;SslMode=none;">
and it does log to the MySQL database without Hangfire, so that seems to be working.
Looking at the Nlog documentation at:
https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2
They seem to add NLog in Program.cs instead of Startup.cs, so I tried that approach as well, but I still get the same error.
Looks like the Hangfire.MySqlStorage library was the root cause of this error. After changing to Hangfire.MySql.Core everything works great without any changes being made to NLog.
I am working on a mule project where all my configurations are stored in a central repository, and at run-time am downloading the configuration and deploying it.
<script:component doc:name="Script">
<script:script engine="groovy">
<![CDATA[
String endpnt = reqUrl.prepareFile(requestUrl);
message.setProperty('endpnt', endpnt,org.mule.api.transport.PropertyScope.INVOCATION);
message.setProperty('port', reqUrl.getPort(),org.mule.api.transport.PropertyScope.INVOCATION);
]]>
</script:script>
</script:component>
The above script downloads the file and makes an entry in mule-deploy.properties against config.resources. I have already set redeployment.enabled=true, but still the endpoint is not available to consume, Please help
Redeployment doesn't work on mule-deploy.properties, here is the ticket I reported for that.
I would like to change the log directory from MULE_HOME/logs to MULE_HOME/logs/apps. The only place I have found that refers to a file path is in MULE_HOME/conf/wrapper.conf. Editing the wrapper.logfile does allow me to relocate the mule_ee.log file, which seems to be the Mule application log, but I'd like to include Mule application logs there, too. If I create an application called FOO and deploy it to the runtime environment, it will create a file called MULE_HOME/logs/mule-app-FOO.log, but changing the location seems to be difficult short of completely messing things up writing custom log4j2 XML files.
If you have Mule version 3.6+, then it is recommended to use log4j2.xml instead of log4j.xml.... Using log4j2 you can change the path and get your application log ... a simple example would be :-
<RollingFile name="RollingFile" fileName="${env:MULE_HOME}/logs/${sys:CustomapplicationName}.log"
filePattern="${env:MULE_HOME}/logs/${sys:CustomapplicationName}-%d{yyyy-MM-dd}-%i.log"> <!-- CustomapplicationName is set at mule-app.properties or in VM argument in Run As Configure as -DCustomapplicationName=Log4j -->
<PatternLayout>
<pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="120 KB" />
</Policies>
<DefaultRolloverStrategy max="1" />
</RollingFile>
Just put this above code in your log4j2.xml in src/main/resource folder
Here in above you can see that, you have configured your path of your log files by mentioning here:-
<RollingFile name="RollingFile" fileName="${env:MULE_HOME}/logs/apps/${sys:CustomapplicationName}.log"
filePattern="${env:MULE_HOME}/logs/apps/${sys:CustomapplicationName}-%d{yyyy-MM-dd}-%i.log">
where ${sys:CustomapplicationName} is the System variable set in mule-app.properties as following :-
CustomapplicationName=yourApplicationName
Right way is to have log4j properties / xml file for FOO application and have that define the desired path for FOO application log. This way will ensure mule_ee.log is not messed up and at the same time other applications too will have their own log files which will be easy to manage and easy to introspect specific application log in case of errors / exceptions
Define location in log4j.properties file.
I try to use Azure Table Storage for the persistence of timeout data and I experience an error on environments other than my local development machine.
My local machine is creating the timeout tables on Azure and is able to poll timeout data successfully. But, if I host the same software on premise on another server it failed to fetch the timeouts. I receive the following error:
2015-02-12 09:43:50,638 [10] WARN NServiceBus.Timeout.Hosting.Windows.TimeoutPersisterReceiver - Failed to fetch timeouts from the timeout storage
System.NullReferenceException: Object reference not set to an instance of an object.
at NServiceBus.Timeout.Hosting.Windows.TimeoutPersisterReceiver.Poll(Object obj) in c:\BuildAgent\work\1b05a2fea6e4cd32\src\NServiceBus.Core\Timeout\Hosting\Windows\TimeoutPersisterReceiver.cs:line 88
at System.Threading.Tasks.Task.Execute()
It seems that the TimeoutPersister is null at the point it wants to fetch data from it.
I host NServiceBus using the NServiceBus.Host. My endpoint configuration looks like this:
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
{
public void Customize(BusConfiguration configuration)
{
configuration.UsePersistence<AzureStoragePersistence>();
configuration.EndpointName("MyEndpoint");
configuration.UseTransport<RabbitMQTransport>()
.DisableCallbackReceiver();
configuration.DisableFeature<Sagas>();
configuration.ScaleOut().UseSingleBrokerQueue();();
}
}
And my app.config contains:
<connectionStrings>
<add name="NServiceBus/Transport" connectionString="host=myrabbitmqserver;virtualhost=myhost;username=me;password=secret" />
</connectionStrings>
<AzureTimeoutPersisterConfig ConnectionString="DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=myaccouuntkey;" TimeoutManagerDataTableName="TimeoutManager" TimeoutDataTableName="TimeoutData" />
Does anyone have any idea what I am doing wrong or can anyone point me in the right direction investigating what the problem can be?
Update 1
It seems that the NServiceBus.Azure assembly is not loaded on the other machines. So azure persistence features are not initialized resulting in NullReferenceException when using the TimeoutPersister.
Update 2 After some NServiceBus debugging I noticed that an exception was thrown when extracting the types from the NServiceBus.Azure.dll assembly. It is unable to load the referenced assembly Miscrosoft.Data.Services.Client.dll 5.6.0.0. This assembly is indeed not in the bin folder. The present version is 5.6.3.0. The NServiceBus.Azure NuGet package supports versions >= 5.6.0.0 < 6.0.0.0, but somehow it's still expecting version 5.6.0.0. It still feels weird that it is working on my development machine? Maybe there are some old versions of the Microsoft.Data.Services.Client.dll installed on my machine as part of the Azure SDK, which are found during the assembly loading.
Update 3
I indeed had somewhere at my system the older 5.6.0 version available. Downgrading the Microsoft.Data.xxx packages to version 5.6.0 solved the issue for now. Does anyone have the same issues using 5.6.3 versions and found a solution for that?
Update 4
Since 2015-02-13 a new version of NServiceBus.Azure is released and now it requires Microsoft.Data.Services.Client version 5.6.2.0. I am still not able to use the 5.6.3 version. Adding a assembly binding redirect will not help either.
The binding redirect must be added to the NServiceBus.Host.exe.config instead of the app.config. Pretty annoying because visual studio automatically updates the app.config.
Information from Yves Goeleven:
The reason is that default load behavior of the CLR is at the process level, which includes the host config, once the host is loaded we actively switch over to the appdomain level (using topshelf) from then on it uses the endpoint's config...
But if the CLR needs to resolve the reference prior to the switch to the appdomain, you will have to put the redirect at the host level (and at the endpoint level I guess)
It should work with 5.6.3 version. Try adding assembly bindingRedirect in the following way:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
</dependentAssembly>
I'm trying to to setup Memcached 2nd level caching. I've followed what documentation I could find, including downloading the project from SVN and looking at how it is configured in their test project, and ended up with this in my app.config.
<configuration>
<configSections>
<section name="memcache" type="NHibernate.Caches.MemCache.MemCacheSectionHandler,NHibernate.Caches.MemCache" />
</configSections>
<memcache>
<memcached host="xx.xx.xx.xx" port="11211" weight="10" />
</memcache>
</configuration>
However, when the MemCache provider code in NHibernate.Caches.MemCache calls configurationmanager.getsection("memcache"), null is returned, which causes it to error out.
I have three projects, .UI, .Core, and .Data - the app.config is for .UI and .Data is where SessionFactory gets built and the code that wants to load this configuration section is launched. .Data has the Nhibernate.Caches.Memcache reference, and I've tried adding it to .UI, however that did not solve the issue.
What is incorrect about this configuration? Or perhaps is it something about my project? Does anyone have any experience at all with NHibernate.Caches.MemCache? There is not much information about it to be found via Google.
The issue ended up being some corruption with my app.config. Everything was right, but it was not being loaded by the assembly. I deleted and re-added it, and then it worked fine.