ZF2 project not working on virtual host - apache

I have a project which is in zf2.
It runs properly on all other systems other than mine.I have checked the virtual host is running properly for other projects on my system.
when I hit xyx.loc it redirects properly but when I hit xyz.loc/user it gives error
An error occurred
An error occurred during execution; please try again
later.
Though I have enable error reporting.
I am not able to figure out whether its apache error or php error or zf2 error or something else.
The project uses ZF\Apigility
The same folder works on other systems very well.

This is the default error template message. ZF2 is catching any exceptions and hiding them from you due to the configuration settings.
Ensure you have the following configuration.
'view_manager' => [
'display_not_found_reason' => true,
'display_exceptions' => true,
],

Related

Error connecting to SQL Server from Razor Pages

I am trying to convert my very basic website from straight HTML to Razor Pages. My main resources have been Adam Freeman and Mike Brind. So far I have created a small foundation and now am trying to run a query against my database in Index.cshtml. If I comment out the query, the application will compile and run (that is to say it will display the home page). When I try to include the query I get a runtime error when trying to load the home page:
An unhandled exception occurred while processing the request.
SqlException: Cannot open database "Alpha" requested by the login. The login failed.
InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call.
Alpha.Pages.Pages_Index.ExecuteAsync() in Index.cshtml
#foreach (YearSummary s in Model.YearSummaries) {
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
An error occurred using the connection to database 'Alpha' on server '(localdb)\MSSQLLocalDB'.
fail: Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred while iterating over the results of a query for context type 'Alpha.Data.AlphaContext'.
I'm assuming this has something to do with my connection string.
appsettings.json
"AllowedHosts": "*",
"ConnectionStrings": {
"AlphaConnection": "Server=(localdb)\MSSQLLocalDB;Database=Alpha;MultipleActiveResultSets=true"
}
Program.cs
builder.Services.AddDbContext(options => {
options.UseSqlServer(builder.Configuration.GetConnectionString("AlphaConnection"));
});
Index.cshtml
#foreach (YearSummary s in Model.YearSummaries) {
I've played around with the connection string, with no luck. I really don't know where to go from here.
I have uploaded my code to GitHub: https://github.com/JB45424/Alpha
Thank you for any assistance.
Have you updated the database after the database migration? If the database is not updated, problems like this can occur.
I cloned your code and ran it directly and I also encountered your error. But after I install the Microsoft.EntityFrameworkCore.Tools NuGet package and run the following commands to migrate and update the database, the program works fine:
Add-Migration InitialCreate
Update-Database
Helpful link: Test the Asp.Net Core MVC app.
Test Result:
Is this the effect of your page loading normally?

Yii logs showing exception for wp-login.php, however, I don't have WordPress

I am using Yii 1.x, Yii internal log file is showing an exception for wp-login.php, however, I don't have WordPress installed on my server. (I get this message on my local as well)
XXXX/XX/XX XX:XX:XX [error] [exception.CHttpException.404] exception 'CHttpException' with message 'Unable to resolve the request "wp-login.php".' in /var/www/html/framework/web/CWebApplication.php:286
Stack trace:
#0 /var/www/html/framework/web/CWebApplication.php(141): CWebApplication->runController('wp-login.php')
#1 /var/www/html/framework/base/CApplication.php(180): CWebApplication->processRequest()
#2 /var/www/html/index.php(18): CApplication->run()
#3 {main}
REQUEST_URI=/wp-login.php
Can anyone tell me why I am receiving such error?
This is log for 404 Not Found error. So this only means that someone is trying to access /wp-login.php URL in your domain. WordPress is the most popular CMS and internet is full of bots which searches WordPress installation on every server/domain and tries to brute-force login form. So you should not worry about it - if you don't have a WordPress installation, then bot definitely will not be able to login into it. :)
But it may be good idea to exclude 404 HTTP errors from regular application logs - bots will generate hundreds of such logs in your app, and usually you want to ignore it (as opposed to regular logs).
[
'class' => 'CFileLogRoute',
'levels' => 'error, warning',
'except' => [
'exception.CHttpException.404',
],
],

Datasource not working in JBoss 7.2

When I create a datasource, a service restart is required to make it work, regardless of the method used to create it (standalone.xml, JBoss CLI, JBoss Administration Console). Attached is the procedure I have written for my team (exported from our Wiki space). The datasource gets created successfully, but when I test the connection, I get this:
From JBoss Administration Console
Unknown error
Unexpected HTTP response: 500
Request
{
"address" => [
("subsystem" => "datasources"),
("data-source" => "dsMyApp")
],
"operation" => "test-connection-in-pool"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => "JBAS010440: failed to invoke operation: JBAS010442: failed to match pool. Check JndiName: java:/dsMyApp",
"rolled-back" => true,
"response-headers" => {"process-state" => "reload-required"}
}
From JBoss CLI
JBAS010440: failed to invoke operation: JBAS010442: failed to match pool. Check JndiName: java:/dsMyApp
If I restart the JBoss server, the datasource works fine (server, port, username and password are all correct).
Any thoughts?
Thank you
The Quick Answer: YES, restarting makes a reload and then activates the datasource
I suggest you doing a reload with jboss-cli (It´s the quickest way)
I´ve created all my datasources with jboss-cli and I always need to
perform this action to allow them to work. After the reload, the datasource connection can be tested.
/opt/wildfly/bin/jboss-cli.sh --connect --controller=192.168.119.116:9990 --commands="reload --host=master"
Hope it helps

How to fix PDO sqlsrv connection timeout in Laravel?

developer!
I'm using Laravel framework and I need to connect to MS SQL 2014 Express database. I've made all the proper configurations in .env (and I even tried tried to put connection parameters straight away to the database.php config) but on the first request i'm always getting timeouted with error:
PDOException in Connector.php line 55:
SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]TCP Provider: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
After the timeout I always get this php fatal:
FatalErrorException in Connector.php line 55
Invalid handle returned.
As a dev tools I'm using XAMPP, and when I'm restarting apache server, sometimes I can establish connection successfully, but only in 1 out of 20-30 tries.
Laravel is using PDO driver, so i tried to use sqlsrv_connect() - and it worked! No errors, everything is fine.
Can somebody help me configure PDO to work? Laravel only uses PDO driver, so I can't just switch to sqlsrv_connect.
I had this problem running on my local machine. I restarted the laravel server and ensured that the ms sql localdb was running and the problem resolved it self.
I had the same error.
After removing the
host // DB_HOST entries from your .env-File and from your config/database.php it worked for me.
What I did for connection are
Installed the correct version of sqlsrv dlls.
Updated doctrine dbal package in Laravel.
My database configuration is below
'sqlsrv3' => [
'driver' => 'sqlsrv',
'host' => '<host-name>',
'database' => '<database-name>',
'username' => '<your-username>',
'password' => '<your-password>',
]
After one day of search in this problem, I found that the problem in DB_PORT, when pass port number 1433 the problem happen, so leave it empty, if you change it in .env, change it like this:
DB_CONNECTION=sqlsrv
DB_HOST=YourHostName
DB_PORT=
DB_DATABASE=YourDBName
DB_USERNAME=YourDBUser
DB_PASSWORD=YourDBPassword
DB_TRUST_SERVER_CERTIFICATE=true
Or if you change it on config/database.php, change it like this:
'sqlsrv' => [
// ...
'port' => env('DB_PORT', null), // <<<< see here
],
Try it :)
Had the same error, turns out it was my password that was wrong. Do confirm you have the right values.
DB_HOST={youservername}.database.windows.net
DB_DATABASE={dbname}
DB_USERNAME={username}
DB_PASSWORD={yourpassword}
DB_PORT=1433
If it doesn't fix do reset the password and try again

Is it possible to redirect error messages to browser window in Resin 4?

In case of compilation error Resin shows a simple page with the only message:
Server Error
The server is temporarily unavailable due to an internal error. Please
notify the system administrator of this problem.
And all significant information I should seek in the log file.
Is it possible to redirect somehow all error diagnostics to the browser window?
Try setting <development-mode-error-page/> tag to true. In later versions of Resin the value is externalized into resin.properties:dev_mode
http://caucho.com/resin-4.0/reference.xtp#developmentmodeerrorpage