Can't get config value from Akka ActorSystem - akka

When I print current config values using println(system.settings.config.root().values())
I got long list of values, cutted:
[SimpleConfigObject({"separator":":"}),
SimpleConfigObject({"home":"/usr/local/Cellar/typesafe-activator/1.3.10"}),
,
SimpleConfigObject({"country":{"format":"UA"},"dir":"/Users/sr/ScalaProjects/akka-http-test","home":"/Users/sr","language":"en","name":"sr"})]
I want to get value of "dir" key.
I try to do it like this:
system.settings.config.getValue("dir")
but got exception:
com.typesafe.config.ConfigException$Missing: No configuration setting
found for key 'dir'
How to get this key?

You might be missing accessing user before accessing dir.
system.settings.config.getConfig("user").getValue("dir")
Note that you are not printing the config keys when printing root().values(), therefore you cannot see the "user" key. You should be able to see the full config block by printing (e.g.)
println(system.settings.config.root().entrySet())

Related

AWS Redis (v 3.2.6): HMSET is not working

I'm getting the following error when I try to run HMSET.
I'm not sure what the message means?
No way to dispatch this command to Redis Cluster. Missing key.
HMSET ABC12340112163928690398 XYZ12340112163928690429 b'eyJuY2lfaWQiOiAi='
The field's value is not passed properly - remove the leading "b" (a Pythonic value?) and it should work, i.e.:
HMSET ABC12340112163928690398 XYZ12340112163928690429 'eyJuY2lfaWQiOiAi='

How can i user kettle connect to phoenix

I just set the config like that:
http://talat.uyarer.com/post/121179803796/how-to-connect-hbase-using-apache-phoenix-from
but it does not work, and it show me the error:
I never used apache-phoenix, but in front of this type of error I'd first check if the driver is in the lib (I guess it is), then on the database connection parameters on the left panel). According to the error, I'd start with the Advanced/Prefered Schema name, and the Option/Parameter with a parameter name you have to drill from the apache-phoenix documentation.

RegOpenKeyEx returns error code 5 (ERROR_ACCESS_DENIED)

I am having trouble opening a registry key with the RegOpenKeyEx function. The particular program I am writing installs fonts onto a computer, and they must be added to the registry to remain installed after a reboot. I am brand new to using the registry, so I have been looking much up, but I have run into a problem. Here is an example that shows the arguments I am sending to RegOpenKeyEx:
int main() {
HKEY key;
long code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts", 0, KEY_ALL_ACCESS, &key);
if(code != ERROR_SUCCESS) {
std::cout << code << std::endl;
return 1;
}
RegCloseKey(key);
return 0;
}
The function returns 1 (ERROR_INVALID_FUNCTION). However, the following does work, and returns 0:
HKEY key;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_ALL_ACCESS, &key);
I do not know how to proceed, so any help would be greatly appreciated.
EDIT: I confirmed with regedit that the key does exist. It seems that if the second argument to RegOpenKeyEx is anything other than NULL, it returns error code 2.
EDIT 2: I have tried multiple solutions, including using the TEXT() function on the subkey and changing the access rights to KEY_SET_VALUE, but I still get the same error. I also tried using RegCreateKeyEx. Strangely, I still get error code 2, though sometimes I get error code 122 (ERROR_INSUFFICENT_BUFFER).
EDIT 3: I changed the error handling so it directly uses the return value of the function instead of GetLastError(). I now get error code 5 (ERROR_ACCESS_DENIED).
According to Microsoft docs:
https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyw
The RegOpenKey function uses the default security access mask to open a key. If opening the key requires a different access right, the function fails, returning ERROR_ACCESS_DENIED. An application should use the RegOpenKeyEx function to specify an access mask in this situation.
So this probably means that you actually don' have access to the key.
Following links in the page above, I found this: https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-key-security-and-access-rights
that says:
To view the current access rights for a key, including the predefined keys, use the Registry Editor (Regedt32.exe). After navigating to the desired key, go to the Edit menu and select Permissions.
For the key that I had personnally had trouble with, I had the following:
Since I'm not there, I can't access it ... (Even though I'm an admin, maybe it requires admin rights)
If it's a one-system issue, you can just change it in regedit.
If you need it for a software you're making, you'll have to find another way, maybe a script that needs to request admin rights.
For what ever its worth, I was having the same problems of getting error code = 5, Access is denied.
Within the HKEY_LOCAL_MACHINE area, I was attempting to use the Regcreatekeyex, and RegOpenKeyEx and related functions to open and
write data to the HKEY_LOCAL_MACHINE area registry --- and had no success. So I tried using the HKEY_CURRENT_USER area, and now I'm
having success in openning and writing data to the HKEY_CURRENT_USER area registry, with verifible success I'm seeing success,
even thought I'm not writing data in the area that I would of liked to. It sounds like the HKEY_LOCAL_MACHINE area is kinda off limits.
The HKEY_LOCAL_MACHINE pseudo key handle points to the key named \Registry\Machine which serves as one of mounting points for registry hives. I doubt you can open this key, or enumerate its subkeys, via standard Windows API, such as RegOpenKeyEx. Maybe, native APIs (NtOpenKey) would work.
You can create a subkey under the HKEY_LOCAL_MACHINE key by calling the RegLoadKey function. If you need to enumerate such subkeys, you can look at values under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\hivelist; value names tell you the registry path – those beginning with \Registry\Machine are the subkeys of HKEY_LOCAL_MACHINE.
HKEY_USERS probably shows the same behavior.

Qt/C++ getting OS proxy settings

I need to retrieve the proxy settings on Windows. They have been set by an admin, so they reside in the registry at locations:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings
ProxySettingsPerUser = 0x00000000 (0)
This entry is giving the information whether the proxy settings need to be read from HKCU(ProxySettingsPerUser=1) or HKLM(ProxySettingsPerUser=0).
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings
ProxyEnable = 0x00000001 (1)
ProxyServer = Host:Port
When I try to read them directly, the default value/string is returned (i.e. not the actual contents of the variable):
Code:
#define HKLM_INTERNET_SETTINGS_KEY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"
//[...]
QSettings regHKLM( HKLM_INTERNET_SETTINGS_KEY, QSettings::NativeFormat );
QString read = regHKLM.value( "ProxyServer", "default" ).toString();
logDebug(QString("ProxyServer %1").arg(read));
Other entries in the same location, such as CodeBaseSearchPath = "CODEBASE" or WarnOnIntranet = 0x00000001 (1), can be read without a problem.
THe second approach tried was to read the proxy settings by using the MSDN functions ::WinHttpGetIEProxyConfigForCurrentUser and ::WinHttpGetProxyForUrl. The code is working fine when trying to read HKCU settings (given both manually host-port or as pac file). But when the settings need to be retrieved from HKLM, the following error is returned:
ERROR_WINHTTP_AUTODETECTION_FAILED
12180
Returned by WinHttpDetectAutoProxyConfigUrl if WinHTTP was unable to discover the URL of the Proxy Auto-Configuration (PAC) file.
Is there another approach to retrieving the HKLM proxy settings?
If the approaches described above should have worked, is there a special condition/privilage that needs to be fulfilled before the settings can be read? (in the first approached, the application already has elevated the privilage level to maximum possible, and the manifest file is set to level "asInvoker")
Best regards,
Kornrade

Structure Saved in a Session Variable

The ReportInfo is a structure. The structure works fine on one web page but I am trying to use it on another web-page. Here is where I saved the ReportInfo structure to the Session Variable
Session["ReportInfo"] = reportInfo;
On the other web-page, I re-created the Structure and then assign the session variable to it, like this...
reportInfo = (ReportInfo)(Session["ReportInfo"]);
I get the following run-time error:
System.InvalidCastException was unhandled by user code
Message="Specified cast is not valid."
Source="App_Web_-s8b_dtf"
How do I get the ReportInfo structure out of the Session variable to use again?
Have you checked the value of Session["ReportInfo"]? Perhaps it's null or some other unsavory value? Also, I assume reportInfo in the second page is of type ReportInfo?