EventLog Production - event-log

I have a console application that is responsible for saving a record in the Windows Event Viewer, but it does not work on a clean machine, despite having already installed the .Net Framework.
Create an installer which is responsible for creating the route HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\MyLogEvent
When running the installed application, it does the whole process without throwing any errors, but it is not saving anything in the Event Viewer.
A strongname has already been added.
string origen = "ErrorGeneric";
EventLogEntryType severidad = EventLogEntryType.Error
if (!EventLog.SourceExists(origen))
{
EventLog.CreateEventSource(origen, "MyLogEvent");
while (!EventLog.SourceExists(origen))
{
Console.Write(".");
Thread.Sleep(1000);
}
}
EventLog log = new EventLog() { Source = origen };
log.WriteEntry(logString.ToString(), severidad);

I found the error, I needed to add the source to the installation, so that it was created in the windows registry

Related

Issue starting ROS launch-File using RQT Plugin push button

I implemented a RQT Plugin with several push buttons. The push button is supposed to start a ROS launch file. For some reason every time I start it I get the error message: Shutdown request received. Reason given for shutdown: [new node registered with same name]
Even though the launch file has only been started once. The launch file also works fine when it's started without the plugin.
This is my code sample for the implementation of the slot:
`
void PluginStartButtons::buttonPressedKameraStart(bool checked)
{
QProcess* k_process = new QProcess;
k_process->setProcessChannelMode(QProcess::MergedChannels);
QString command = "roslaunch neo_watch_launch thermal_rgb_camera.launch";
k_process->start(command);
system(qPrintable(command));
}
`
Do you have any idea why this error might occur?

Grails afterInsert hook issue with Hibernate 5.1 and PostgreSQL

In an existing Grails 3.1.15 application, recently upgraded to Hibernate 5.1, an odd issue with afterInsert (or other) hooks started to appear. After some hours of testing, I could track this down to Hibernate 5.1 + PostgreSQL combination - issue is not reproducible with H2. To reproduce, create a simple application consisting of 2 domain objects - an Audit trail and a User, as shown here:
class Audit {
Date dateCreated
String auditData
}
class User {
String name
String email
def afterInsert() {
new Audit(auditData: "User created: $this").save()
}
}
The code above works OK with Hibernate 4, however, if the application is upgraded to Hibernate5 plugin + Hibernate 5.1.x (tested with 5.1.0.Final and 5.1.5.Final) the above scenario will always lead to a ConcurrentModificationException when you attempt to save a new User instance. You can just use a scaffold controller to reproduce. Note this only happens with PostgreSQL as the data source - with H2 it would still work OK.
Now, according to GORM Docs (see chapter 8.1.3) one should use a new session when attempting to save other objects in beforeUpdate or afterInsert hooks anyway:
def afterInsert() {
Audit.withNewSession() {
new Audit(auditData: "User created: $this").save()
/* no exception logged, but Audit instance not preserved */
}
}
But this wouldn't really resolve the issue with PSQL. The exception is gone, the User instance is persisted, but the Audit instance is not saved. Again, this code would work OK with H2. To really avoid the issue with PSQL, you would have to manually flush the session in afterInsert:
def afterInsert() {
Audit.withNewSession() { session ->
new Audit(auditData: "User created: $this").save()
session.flush()
/* finally no exceptions, both User and Audit saved */
}
}
Question: is this a bug, or is this expected? I find it a bit suspicious that the manual flush is required in order for the Audit instance to be persisted - and even more so when I see it works without a flush with H2 and only seems to affect PostgreSQL. But I couldn't really find any reports - any pointers are appreciated!
For the sake of completeness, I tested with the following JDBC driver versions for PostgreSQL:
runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
runtime 'org.postgresql:postgresql:9.4.1208.jre7'
runtime 'org.postgresql:postgresql:42.0.0'
And for the upgrade to Hibernate 5.1, the following dependencies were used:
classpath "org.grails.plugins:hibernate5:5.0.13"
...
compile "org.grails.plugins:hibernate5:5.0.13"
compile "org.hibernate:hibernate-core:5.1.5.Final"
compile "org.hibernate:hibernate-ehcache:5.1.5.Final"

JavaMail crashes after build/deploy on Glassfish 4

My current project includes using of a JavaMail for confirming an user email. The problem I have is that, using eclipse, every time I build & deploy my web application on the local Glassfish server the JavaMail crashes with the following exception:
Severe: java.lang.SecurityException: Access to default session denied
at javax.mail.Session.getDefaultInstance(Session.java:333)
at utils.MailService.sendEmailSSL(MailService.java:58)
And here the code snipped where I'm obtaining the session and which is throwing the above exception:
Session session = Session.getDefaultInstance(
props,
new javax.mail.Authenticator(){
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(usr, pwd);
}
});
The workaround I've found so far is restarting Glassfish and after that JavaMail functions properly again. The problem is it is very annoying and time consuming doing a restart even after the smallest change in my code.
My question: Is there a possibility to reset only the JavaMail service and bind this with the build event?
Off course any other suggestions are welcome too :)
If you can avoid using Session.getDefaultInstance. Use Session.getInstance and fix some of the common mistakes.

FTP timing out on Heroku

Using Apache Commons FTPClient in a Scala application works as expected on my local machine, but always times out when running on Heroku. Relevant code:
val ftp = new FTPClient
ftp.connect(hostname)
val success = ftp.login(username, pw)
if (success) {
ftp.changeWorkingDirectory(path)
//a logging statement here WILL print
val engine = ftp.initiateListParsing(ftp.printWorkingDirectory)
//a logging statement here will NOT print
while (engine.hasNext) {
val files = engine.getNext(5)
//do stuff with files
}
}
By adding some loggings I've confirmed the client is successfully connecting, logging in, and changing the directory. But stops when trying to begin retrieving files (either via the above paged access or unpaged with ftp.listFiles) and throws a connection time out exception (after about 15 minutes).
Any reason the above code works fine locally but not on Heroku?
Turns out FTP has two modes, active and passive, and Apache-Commons' FTPClient defaults to active. Heroku's firewall presumably doesn't allow active FTP (which is why this was functioning properly locally but not once deployed) - changing to passive mode by adding ftp.enterLocalPassiveMode() resolved the issue.

InteropServices.COMException when running WatiN tests

When I run WatiN tests on our build server they all throw this InteropServices.COMException:
MyTestClassName.MyTestMethodName:
System.Runtime.InteropServices.COMException : Creating an instance of the COM component with CLSID {0002DF01-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 80004005.
I get the same result wether I run them through TeamCity or I run them manually on the server as an administrator using NUnit GUI (2.5).
This is some sample code:
[TestFixture]
public class MyTestClassName
{
private string pageUrl;
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
pageUrl = ConfigurationManager.AppSettings["SiteURL"] + "/Pages/MyPage.aspx";
Settings.MakeNewIeInstanceVisible = false;
}
[Test]
public void MyTestMethodName()
{
using (var ie = new IE(pageUrl))
{
ie.SelectList(new Regex(#"^*DropDownList1*$")).Option("TheOption").Select();
ie.SelectList(new Regex(#"^*DropDownList2*$")).Option("AnOption").Select();
ie.SelectList(new Regex(#"^*DropDownList3*$")).Option("OtherOption").Select();
}
}
}
Any ideas what it can be?
/Joakim
Try running Visual Studio as Administrator.
I also meet the same problem but more strange for me.
I've got a server only for "UI testing" and for many application de WatiN test runs without any problem.
This error only happens for one application and only in CruiseControl (with nant) but not when runing the test with NUnitGUI...
I Finnaly found a solution this morning: I replaced all my call new IE(); to new IE(true) WatiN release note And didn't get the error anymore.
Another fix is to "Enable Protected mode in IE" like described here
Every time IE.Quit was called by WatiN IE would stop responding and then try to recover. Run as admin fixed the problem for me.
Another comment says:
Try running Visual Studio as Administrator
It is actually NUnit that needs to be run as administrator (at least in Windows 7), but the thinking is correct.
I think that the select list is not yet fully loaded and ready, and this is another symptom of the same problem described in this question:
Access denied error ( Visual Studio and WatiN )