Undefined property: View::$Js - cakephp

Getting this. Site works fine locally, but up on production server I get this error.
cakephp verion 1.3
Production: php 5.3.3-7+squeeze7
Dev: 5.3.3-7+squeeze3
Notice (8): Undefined property: View::$Js [APP/views/layouts/default.ctp, line 31]
Code | Context
include - APP/views/layouts/default.ctp, line 31
View::_render() - CORE/cake/libs/view/view.php, line 736
View::renderLayout() - CORE/cake/libs/view/view.php, line 494
View::render() - CORE/cake/libs/view/view.php, line 440
Controller::render() - CORE/cake/libs/controller/controller.php, line 909
ErrorHandler::_outputMessage() - CORE/cake/libs/error.php, line 458
ErrorHandler::missingComponentFile() - CORE/cake/libs/error.php, line 415
Object::dispatchMethod() - CORE/cake/libs/object.php, line 112
ErrorHandler::__construct() - CORE/cake/libs/error.php, line 125
Object::cakeError() - CORE/cake/libs/object.php, line 201
Component::_loadComponents() - CORE/cake/libs/controller/component.php, line 216
Component::init() - CORE/cake/libs/controller/component.php, line 78
Controller::constructClasses() - CORE/cake/libs/controller/controller.php, line 483
CakeErrorController::__construct() - CORE/cake/libs/error.php, line 52
ErrorHandler::__construct() - CORE/cake/libs/error.php, line 90
Object::cakeError() - CORE/cake/libs/object.php, line 201
Component::_loadComponents() - CORE/cake/libs/controller/component.php, line 216
Component::init() - CORE/cake/libs/controller/component.php, line 78
Fatal error: Call to a member function writeBuffer() on a non-object in /var/www/website.local/views/layouts/default.ctp on line 31
Line 31 is
echo $this->Js->writeBuffer(array('cache'=> true));
I have in app_controller.php
<?php
class AppController extends Controller {
var $helpers = array('Html','Form','Session','Js','Javascript');
var $components = array(
'Session',
'RequestHandler',
'DebugKit.Toolbar'
);
}
?>

It looks like you are missing a component file:
ErrorHandler::missingComponentFile() - CORE/cake/libs/error.php, line 415
You may want to explore that error first, and then see if it fixes your other issue.

Related

Impossible to invoke endpoint with sagemaker

I am using aws sagemaker to invoke the endpoint :
payload = pd.read_csv('payload.csv', header=None)
>> payload
0 1 2 3 4
0 setosa 5.1 3.5 1.4 0.2
1 setosa 5.1 3.5 1.4 0.2
with this code :
response = runtime.invoke_endpoint(EndpointName=r_endpoint,
ContentType='text/csv',
Body=payload)
But I got this problem :
ParamValidationError Traceback (most recent call last)
<ipython-input-304-f79f5cf7e0e0> in <module>()
1 response = runtime.invoke_endpoint(EndpointName=r_endpoint,
2 ContentType='text/csv',
----> 3 Body=payload)
4
5 result = json.loads(response['Body'].read().decode())
~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
312 "%s() only accepts keyword arguments." % py_operation_name)
313 # The "self" in this scope is referring to the BaseClient.
--> 314 return self._make_api_call(operation_name, kwargs)
315
316 _api_call.__name__ = str(py_operation_name)
~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
584 }
585 request_dict = self._convert_to_request_dict(
--> 586 api_params, operation_model, context=request_context)
587
588 handler, event_response = self.meta.events.emit_until_response(
~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/client.py in _convert_to_request_dict(self, api_params, operation_model, context)
619 api_params, operation_model, context)
620 request_dict = self._serializer.serialize_to_request(
--> 621 api_params, operation_model)
622 prepare_request_dict(request_dict, endpoint_url=self._endpoint.host,
623 user_agent=self._client_config.user_agent,
~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/validate.py in serialize_to_request(self, parameters, operation_model)
289 operation_model.input_shape)
290 if report.has_errors():
--> 291 raise ParamValidationError(report=report.generate_report())
292 return self._serializer.serialize_to_request(parameters,
293 operation_model)
ParamValidationError: Parameter validation failed:
Invalid type for parameter Body, value: 0 1 2 3 4
0 setosa 5.1 3.5 1.4 0.2
1 setosa 5.1 3.5 1.4 0.2, type: <class 'pandas.core.frame.DataFrame'>, valid types: <class 'bytes'>, <class 'bytearray'>, file-like object
I am just using the same code/step like in the aws tutorial .
Can you help me to resolve this problem please?
thank you
The payload variable is a Pandas' DataFrame, while invoke_endpoint() expects Body=b'bytes'|file.
Try something like this (coding blind):
response = runtime.invoke_endpoint(EndpointName=r_endpoint,
ContentType='text/csv',
Body=open('payload.csv'))
More on the expected formats here.
Make sure the file doesn't include a header.
Alternatively, convert your DataFrame to bytes, like in this example, and pass those bytes instead of passing a DataFrame.

CakePHP 3: SQLSTATE[HY000]: General error: 10 disk I/O error

I'm serving CakePHP 3.x based sites off a Network Load Balanced (NLB) IIS 10 cluster. The php files reside on an external DFS share. When run with debug enabled, CakePHP throws the following error:
2017-08-16 13:45:39 Error: Fixture creation for "requests" failed "SQLSTATE[HY000]: General error: 10 disk I/O error"
2017-08-16 13:45:39 Warning: Warning (512): Fixture creation for "requests" failed "SQLSTATE[HY000]: General error: 10 disk I/O error" in [\\MY.DOMAIN.COM\WEBAPPS\Sites\some_site\vendor\cakephp\cakephp\src\TestSuite\Fixture\TestFixture.php, line 306]
Request URL: /
Client IP: 10.1.2.250
Trace:
Cake\Error\BaseErrorHandler::handleError() - CORE\src\Error\BaseErrorHandler.php, line 146
Cake\TestSuite\Fixture\TestFixture::create() - CORE\src\TestSuite\Fixture\TestFixture.php, line 306
DebugKit\Model\Table\RequestsTable::ensureTables() - ROOT\vendor\cakephp\debug_kit\src\Model\Table\LazyTableTrait.php, line 56
DebugKit\Model\Table\RequestsTable::initialize() - ROOT\vendor\cakephp\debug_kit\src\Model\Table\RequestsTable.php, line 52
Cake\ORM\Table::__construct() - CORE\src\ORM\Table.php, line 290
Cake\ORM\Locator\TableLocator::_create() - CORE\src\ORM\Locator\TableLocator.php, line 212
Cake\ORM\Locator\TableLocator::get() - CORE\src\ORM\Locator\TableLocator.php, line 179
Cake\ORM\TableRegistry::get() - CORE\src\ORM\TableRegistry.php, line 110
DebugKit\ToolbarService::saveData() - ROOT\vendor\cakephp\debug_kit\src\ToolbarService.php, line 172
DebugKit\Routing\Filter\DebugBarFilter::afterDispatch() - ROOT\vendor\cakephp\debug_kit\src\Routing\Filter\DebugBarFilter.php, line 139
Cake\Event\EventManager::_callListener() - CORE\src\Event\EventManager.php, line 426
Cake\Event\EventManager::dispatch() - CORE\src\Event\EventManager.php, line 391
Cake\Http\ActionDispatcher::dispatchEvent() - CORE\src\Event\EventDispatcherTrait.php, line 78
Cake\Http\ActionDispatcher::dispatch() - CORE\src\Http\ActionDispatcher.php, line 100
Cake\Http\BaseApplication::__invoke() - CORE\src\Http\BaseApplication.php, line 83
Cake\Http\Runner::__invoke() - CORE\src\Http\Runner.php, line 65
Cake\Routing\Middleware\RoutingMiddleware::__invoke() - CORE\src\Routing\Middleware\RoutingMiddleware.php, line 62
Cake\Http\Runner::__invoke() - CORE\src\Http\Runner.php, line 65
Cake\Routing\Middleware\AssetMiddleware::__invoke() - CORE\src\Routing\Middleware\AssetMiddleware.php, line 88
Cake\Http\Runner::__invoke() - CORE\src\Http\Runner.php, line 65
AssetCompress\Middleware\AssetCompressMiddleware::__invoke() - ROOT\vendor\markstory\asset_compress\src\Middleware\AssetCompressMiddleware.php, line 56
Cake\Http\Runner::__invoke() - CORE\src\Http\Runner.php, line 65
Cake\Error\Middleware\ErrorHandlerMiddleware::__invoke() - CORE\src\Error\Middleware\ErrorHandlerMiddleware.php, line 81
Cake\Http\Runner::__invoke() - CORE\src\Http\Runner.php, line 65
Cake\Http\Runner::run() - CORE\src\Http\Runner.php, line 51
Cake\Http\Server::run() - CORE\src\Http\Server.php, line 90
require - ROOT\webroot\index.php, line 37
[main] - ROOT\index.php, line 16
IIS has full write permission to the project root folder (on the network share). The fact that CakePHP error log has captured the above info. proves it. So this is definitely not about file / folder permissions.
What's could be the cause of this error and how to fix?
Thank you.

Connectionmanager connect returning fatal error instead of redirect in CakePHP 3

I'm working in CakePHP 3.4
In my component, I'm checking if database connection could be installed or not. If database connection couldn't be established, redirect user to Installation plugin to setup database configuration.
This is how I'm checking in my component.
<?php
namespace Installer\Controller\Component;
use Cake\Controller\Component;
use Cake\Controller\ComponentRegistry;
use Cake\Datasource\ConnectionManager;
use Cake\Core\Configure;
use Cake\Filesystem\File;
/**
* Install component
*/
class InstallComponent extends Component
{
public function installationCheck()
{
// connection to the database
try {
$db = ConnectionManager::get('default');
if(!$db->connect()) { // line 23
return $this->redirect(['plugin' => 'Installer', 'controller' => 'Install', 'action' => 'index']);
}
} catch (Exception $e) {
}
return true;
}
}
But when database connection failed, Instead of redirecting user, it gives fatal error as
Connection to database could not be established: SQLSTATE[HY000]
[1045] Access denied for user 'user'#'host' (using password: YES)
Stack Trace
⟩ Cake\Database\Connection->connect ROOT/plugins/Installer/src/Controller/Component/InstallComponent.php, line 23
⟩ Installer\Controller\Component\InstallComponent->installationCheck APP/Controller/AppController.php, line 65
⟩ App\Controller\AppController->beforeRender CORE/src/Event/EventManager.php, line 414
⟩ Cake\Event\EventManager->_callListener CORE/src/Event/EventManager.php, line 391
⟩ Cake\Event\EventManager->dispatch CORE/src/Event/EventDispatcherTrait.php, line 78
⟩ Cake\Controller\Controller->dispatchEvent CORE/src/Controller/Controller.php, line 610
⟩ Cake\Controller\Controller->render APP/Controller/PagesController.php, line 61
⟩ App\Controller\PagesController->display CORE/src/Controller/Controller.php, line 440
⟩ Cake\Controller\Controller->invokeAction CORE/src/Http/ActionDispatcher.php, line 119
⟩ Cake\Http\ActionDispatcher->_invoke CORE/src/Http/ActionDispatcher.php, line 93
⟩ Cake\Http\ActionDispatcher->dispatch CORE/src/Http/BaseApplication.php, line 78
⟩ Cake\Http\BaseApplication->__invoke CORE/src/Http/Runner.php, line 65
⟩ Cake\Http\Runner->__invoke CORE/src/Routing/Middleware/RoutingMiddleware.php, line 59
⟩ Cake\Routing\Middleware\RoutingMiddleware->__invoke CORE/src/Http/Runner.php, line 65
⟩ Cake\Http\Runner->__invoke CORE/src/Routing/Middleware/AssetMiddleware.php, line 88
⟩ Cake\Routing\Middleware\AssetMiddleware->__invoke CORE/src/Http/Runner.php, line 65
⟩ Cake\Http\Runner->__invoke CORE/src/Error/Middleware/ErrorHandlerMiddleware.php, line 92
⟩ Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke CORE/src/Http/Runner.php, line 65
⟩ Cake\Http\Runner->__invoke ROOT/vendor/cakephp/debug_kit/src/Middleware/DebugKitMiddleware.php, line 52
⟩ DebugKit\Middleware\DebugKitMiddleware->__invoke CORE/src/Http/Runner.php, line 65
⟩ Cake\Http\Runner->__invoke CORE/src/Http/Runner.php, line 51
⟩ Cake\Http\Runner->run CORE/src/Http/Server.php, line 80
⟩ Cake\Http\Server->run ROOT/webroot/index.php, line 37
If you check the definition for the ConnectionManager::get() method you'll see that it either returns a connection object or throws a MissingDatasourceConfigException. So you might need to wrap your code in a try catch block:-
public function installationCheck()
{
try {
$db = ConnectionManager::get('default');
// connection to the database
if (!$db->connect()) {
return $this->redirect(['plugin' => 'Installer', 'controller' => 'Install', 'action' => 'index']);
}
} catch (\Exception $e) {
}
return true;
}

InvalidArgumentException in SQLiteConnector.php: Database (storage/database.sqlite) does not exist

I recently started exploring Laravel and I am aiming to build a simple website with basic CRUD functionalities. So the context here is that I want to be able to display a list of all entries within a page, but when I create that index page I am met with the following exception:
InvalidArgumentException in SQLiteConnector.php line 34:
Database (storage/database.sqlite) does not exist.
in SQLiteConnector.php line 34
at SQLiteConnector->connect(array('driver' => 'sqlite', 'database' => 'storage/database.sqlite', 'prefix' => '', 'name' => 'sqlite')) in ConnectionFactory.php line 61
at ConnectionFactory->Illuminate\Database\Connectors\{closure}()
at call_user_func(object(Closure)) in Connection.php line 868
at Connection->getPdo() in Connection.php line 736
at Connection->reconnectIfMissingConnection() in Connection.php line 621
at Connection->run('select * from "certificates"', array(), object(Closure)) in Connection.php line 342
at Connection->select('select * from "certificates"', array(), true) in Builder.php line 1515
at Builder->runSelect() in Builder.php line 1501
at Builder->get(array('*')) in Builder.php line 596
at Builder->getModels(array('*')) in Builder.php line 303
at Builder->get(array('*')) in Model.php line 646
at Model::all() in certificatesController.php line 15
at CertificatesController->index()
at call_user_func_array(array(object(CertificatesController), 'index'), array()) in Controller.php line 80
at Controller->callAction('index', array()) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(CertificatesController), object(Route), 'index') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(CertificatesController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\certificatesController', 'index') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
The solutions to similar questions asked on Stackoverflow didn't work for me. Basically, these are what are in my .env and config/database.php files right now:
.env
DB_CONNECTION=sqlite
DB_HOST=localhost
DB_PORT=8888
DB_DATABASE=storage/database.sqlite
config/database.php
'default' => env('DB_CONNECTION', 'sqlite'),
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
I'm running this locally (not Homestead) and I've been trying to change the different values several times (e.g. using an absolute path, switching port numbers between 3306 and 8888). Will really appreciate if someone can offer some advice on how to solve this :)
Thank you!
The error message says that there's no storage/database.sqlite please make sure that you create a empty text file in the storage folder and name it database.sqlite and then run php artisan migrate

FileNotOpenedError with Cloud storage on GAE

I am trying to write to a file in cloud storage from the remote api shell and am seeing the following:
s~appid> FILENAME = '/gs/test_bucket/test'
s~appid> writable_file = files.gs.create(FILENAME,
mime_type='application/octet-stream', acl='project-private')
s~appid> with files.open(writable_file, 'a') as f:
... f.write('[]')
...
---------------------------------------------------------------------------
FileNotOpenedError Traceback (most recent call last)
/Users/dhruvkaranmehta/Projects/getaround3/tools/g3/shell.pyc in <module>()
1 with files.open(writable_file, 'a') as f:
----> 2 f.write('[]')
3
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
__exit__(self, atype, value, traceback)
288
289 def __exit__(self, atype, value, traceback):
--> 290 self.close()
291
292 def write(self, data, sequence_key=None):
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
close(self, finalize)
282 request.set_filename(self._filename)
283 request.set_finalize(finalize)
--> 284 self._make_rpc_call_with_retry('Close', request, response)
285
286 def __enter__(self):
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
_make_rpc_call_with_retry(self, method, request, response)
395 def _make_rpc_call_with_retry(self, method, request, response):
396 try:
--> 397 _make_call(method, request, response)
398 except (ApiTemporaryUnavailableError,
FileTemporaryUnavailableError):
399
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
_make_call(method, request, response, deadline)
243 rpc.check_success()
244 except apiproxy_errors.ApplicationError, e:
--> 245 _raise_app_error(e)
246
247
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
_raise_app_error(e)
186 elif (e.application_error ==
187 file_service_pb.FileServiceErrors.FILE_NOT_OPENED):
--> 188 raise FileNotOpenedError()
189 elif (e.application_error ==
190 file_service_pb.FileServiceErrors.READ_ONLY):
FileNotOpenedError:
This seems weird since the file was just opened. I have also seen another scenario where opening a file in 'a' mode leads to a FinalizationError.
Any additional information will be greatly helpful.
Thanks!
For the first part, there's a feature request to support the files api from the remote api shell. Could you try the same using the interactive console (See Is there an interactive console for public/uploaded app engine apps?).
Regarding your second error the documentation states that:
You cannot open and write to a file that has already been finalized.

Resources