ZF3 zend-cache error Unable to resolve service "FilesystemCache" to a factory - zend-framework3

I'm trying to use zend-cache with zend-rbac.
zend-rbac is ok, but when I try to add zend-cache I got this message:
Unable to resolve service "FilesystemCache" to a factory; are you certain you provided it during configuration?
My cache configuration at global.php is like this:
// Cache configuration.
'caches' => [
'FilesystemCache' => [
'adapter' => [
'name' => Filesystem::class,
'options' => [
// Store cached data in this directory.
'cache_dir' => './data/cache',
// Store cached data for 1 hour.
'ttl' => 60*60*1
],
],
'plugins' => [
[
'name' => 'serializer',
'options' => [
],
],
],
],
],
And in my RbacManagerFactory I'm calling it like this:
$cache = $container->get('FilesystemCache');
I already try to config FilesystemService in my module, like this:
'service_manager' => [
'factories' => [
\Zend\Cache\Storage\Adapter\FilesystemService::class => InvokableFactory::class,
],
],
But it didn't work
Do I need to config something more?
EDIT 2018-10-29
When I try to run the sample it gives this error:
[Mon Oct 29 12:06:13.097747 2018] [php7:warn] [pid 943] [client 127.0.0.1:48824] PHP Warning: file_put_contents(data/cache/module-config-cache.application.config.cache.php): failed to open stream: No such file or directory in /var/www/html/roledemo/vendor/zendframework/zend-modulemanager/src/Listener/AbstractListener.php on line 65
[Mon Oct 29 12:06:13.098593 2018] [php7:warn] [pid 943] [client 127.0.0.1:48824] PHP Warning: file_put_contents(data/cache/module-classmap-cache.application.module.cache.php): failed to open stream: No such file or directory in /var/www/html/roledemo/vendor/zendframework/zend-modulemanager/src/Listener/AbstractListener.php on line 65
[Mon Oct 29 12:06:13.112886 2018] [php7:error] [pid 943] [client 127.0.0.1:48824] PHP Fatal error: Method Zend\\View\\Helper\\HeadTitle::__toString() must not throw an exception, caught Zend\\I18n\\Exception\\ExtensionNotLoadedException: Zend\\I18n\\Translator component requires the intl PHP extension in /var/www/html/roledemo/module/Application/view/layout/layout.phtml on line 0
and I can't access any URL.
Could it be my php or apache version?

So I was missing some things, that's why it didn't work before:
Create data/cache folder and give it permission 775
Create public/img/captcha folder and give it permission 775
Add module Zend\Serializer and Zend\Cache to config/modules.config.php
Add the following to module/Login/config/module.config.php:
'rbac_manager' => [
'assertions' => [Service\RbacAssertionManager::class],
],
And, if you are following the text, not downloading the code:
Set $result as false in src/Service/RbacManager.php line 72

Related

Sbt cannot assembly due to the deduplicate of the file

I am struggling to resolve the issue but hard to pinpoint the issue regarding the Sbt.
When I assembly using sbt then it throw the error as below.
The entire of the contents is large so I just attached the part of that.
[error] (assembly) deduplicate: different file contents found in the following:
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-all/4.1.68.Final/netty-all-4.1.68.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-buffer/4.1.50.Final/netty-buffer-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-codec/4.1.50.Final/netty-codec-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-common/4.1.50.Final/netty-common-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-handler/4.1.50.Final/netty-handler-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-resolver/4.1.50.Final/netty-resolver-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.50.Final/netty-transport-native-epoll-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.50.Final/netty-transport-native-unix-common-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport/4.1.50.Final/netty-transport-4.1.50.Final.jar:META-INF/io.netty.versions.properties
I googled it and changed my assembly mergy strategy as below, but it didn't work.
As you can see, I added the case PathList("META-INF", _*) => MergeStrategy.discard to my code but the META-INF/* related errors were not disappear.
Any help will be appreciated.
Thanks.
assembly / assemblyMergeStrategy := {
case PathList("META-INF", _*) => MergeStrategy.discard
case "module-info.class" => MergeStrategy.discard
case "logback.xml" => MergeStrategy.discard
case PathList("mime.types") => MergeStrategy.last
case PathList("META-INF", xs # _*) => {
xs match {
case "services" :: _ :: Nil => MergeStrategy.concat
case _ => MergeStrategy.discard
}
}

I am getting lsapi:error and it is causing 503 error

The following error is being triggered:
[Wed Oct 19 00:46:51.328670 2022] [lsapi:error] [pid 8996:tid 47089191048960] [client 193.111.60.5:0] [host] Error receiving response header (lsphp is killed?): ReceiveResponseHeader: receive pkg hdr failed: ReceivePkgHdr: nothing to read from backend (LVE ID 1001), check http://docs.cloudlinux.com/mod_lsapi_troubleshooting.html
I added memory limit 4095M which solve this error

Empty S3 remote log files in Airflow 2.3.2

I configured remote S3 logging with the following variables:
- name: AIRFLOW__LOGGING__REMOTE_LOGGING
value: 'True'
- name: AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER
value: 's3://my-airflow/airflow/logs'
- name: AIRFLOW__LOGGING__REMOTE_LOG_CONN_ID
value: 'my_s3'
- name: AIRFLOW__LOGGING__LOGGING_LEVEL
value: 'ERROR'
- name: AIRFLOW__LOGGING__ENCRYPT_S3_LOGS
value: 'False'
So far the log files are created with the DAG and task path with the name attempt=1.log or similar but always with 0 bytes size (empty). When I try to see the logs from Airflow I get this message (I'm using the KubernetesExecutor):
*** Falling back to local log
*** Trying to get logs (last 100 lines) from worker pod ***
*** Unable to fetch logs from worker pod ***
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Audit-Id': 'f3e0dd67-c8f4-42fc-945f-95dc42e8c2b5', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'Date': 'Mon, 01 Aug 2022 13:07:07 GMT', 'Content-Length': '136'})
HTTP response body: b'{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"name must be provided","reason":"BadRequest","code":400}\n'
Why are my logs files empty?

load .yml file in R

I am trying to use config.yml in R. But whenever I load the file using
my config file looks like this
default:
dataconnection:
driver: 'ODBC Driver 11 for SQL Server'
server: 'server'
uid: 'Username'
pwd: 'password'
port: 1433
database: 'Data_Science'
rsconnect:
dataconnection:
driver: 'FreeTDS'
server: 'server'
uid: 'username'
pwd: 'password'
port: 1433
database: 'Data_Science'
Code:
config <- config::get(file = "C:/Users/Samuel.Golomeke/Documents/Data Science/Codes/R codes/SQL_Server_shiny_connect/config")
I keep getting the following warning message:
Warning message:
In readLines(con) :
incomplete final line found on 'C:\Users\Samuel.Golomeke\Documents\Data Science\Codes\R codes\SQL_Server_shiny_connect\config.yaml'"
why is that?
Make sure the last line in the config.yaml file has a blank line with no whitespace (space, tab, etc).

Nlog System.ArgumentException: LayoutRenderer cannot be found:

I encountered issue using NLog when I want to render asp.net related info into my database. Here is the internal logging for NLog.
2017-07-16 03:08:06.5485 Debug ScanAssembly('NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=')
2017-07-16 03:08:06.5796 Debug Start auto loading, location:
2017-07-16 03:08:06.5796 Debug Auto loading done
2017-07-16 03:08:06.6036 Error Error parsing layout aspnet-request-method will be ignored. Exception: System.ArgumentException: LayoutRenderer cannot be found: 'aspnet-request-method'. Is NLog.Web not included?
at NLog.Config.Factory`2.CreateInstance(String name)
at NLog.Layouts.LayoutParser.ParseLayoutRenderer(ConfigurationItemFactory configurationItemFactory, SimpleStringReader sr)
2017-07-16 03:08:06.6115 Error Error parsing layout aspnet-request-method will be ignored. Exception: System.ArgumentException: LayoutRenderer cannot be found: 'aspnet-request-method'. Is NLog.Web not included?
at NLog.Config.Factory`2.CreateInstance(String name)
at NLog.Layouts.LayoutParser.ParseLayoutRenderer(ConfigurationItemFactory configurationItemFactory, SimpleStringReader sr)
2017-07-16 03:08:06.6115 Debug --- NLog configuration dump ---
2017-07-16 03:08:06.6115 Debug Targets:
2017-07-16 03:08:06.6276 Debug Rules:
2017-07-16 03:08:06.6276 Debug logNamePattern: (:All) levels: [ Debug Info Warn Error Fatal ] appendTo: [ ]
2017-07-16 03:08:06.6276 Debug logNamePattern: (:All) levels: [ Debug Info Warn Error Fatal ] appendTo: [ ]
2017-07-16 03:08:06.6276 Debug --- End of NLog configuration dump ---
2017-07-16 03:08:06.6456 Info Found 24 configuration items
2017-07-16 03:08:06.6966 Info Found 24 configuration items
2017-07-16 03:08:06.7085 Debug Targets for LicenseServer.Utility.Log by level:
2017-07-16 03:08:06.7085 Debug Trace =>
2017-07-16 03:08:06.7085 Debug Debug =>
2017-07-16 03:08:06.7225 Debug Info =>
2017-07-16 03:08:06.7225 Debug Warn =>
2017-07-16 03:08:06.7225 Debug Error =>
2017-07-16 03:08:06.7225 Debug Fatal =>
I am avoiding doing configuration on xml file. so I took programmatic configuration approach. which is working fine totally except it is giving issue when I put 'aspnet-request-method' and any other aspnet related layouts. I installed NLog.Web and NLog.Extend but it is still not working. below is my code on setting up configuration :
public static class Log
{
public static Logger _logger { get; set; }
public static void Init()
{
InternalLogger.LogFile = #"D:\Nlog.txt";
InternalLogger.LogLevel = LogLevel.Debug;
var config = new LoggingConfiguration();
var db_target = new DatabaseTarget();
db_target.DBProvider = #"MySql.Data.MySqlClient.MySqlConnection, MySql.Data";
db_target.ConnectionString =
$#"server={DBConfig._server};database={DBConfig._dbname};userid={DBConfig._username};password={DBConfig
._password};";
db_target.DBHost = DBConfig._server;
db_target.DBDatabase = DBConfig._dbname;
db_target.DBUserName = DBConfig._username;
db_target.DBDatabase = DBConfig._password;
db_target.CommandText = #"INSERT INTO error_log(system, module, action, content) VALUES(#activityid, #request, #logger, #ip)";
db_target.Parameters.Add(new DatabaseParameterInfo("#activityid", new NLog.Layouts.SimpleLayout("${activityid}")));
db_target.Parameters.Add(new DatabaseParameterInfo("#request", new NLog.Layouts.SimpleLayout(#"${aspnet-request-method}")));
db_target.Parameters.Add(new DatabaseParameterInfo("#logger", new NLog.Layouts.SimpleLayout("${logger}")));
db_target.Parameters.Add(new DatabaseParameterInfo("#ip", new NLog.Layouts.SimpleLayout("${aspnet-request-method}")));
db_target.KeepConnection = true;
var rule = new LoggingRule("*", LogLevel.Debug, db_target);
config.LoggingRules.Add(rule);
config.LoggingRules.Add(rule);
LogManager.Configuration = config;
_logger = LogManager.GetCurrentClassLogger();
}
}
Please note, you need to install NLog.Web (ASP.NET non-core) or NLog.Web.AspNetCore and for ASP.NET Core you need in your nlog.config
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>

Resources