Controller Route not found in production environment - shopware

The problem: I am currently working on a custom plugin for Shopware 6 with the development template (https://github.com/shopware/development) and testing it on localhost.
The goal is to use my plugin for our online shop which runs on the production environment (https://github.com/shopware/production)
My problem is that my plugin works exactly like I want on localhost, but not anymore if I upload it to our production environment.
Example: I wrote a new API Controller that introduces a new Route, which does basically the same as the SyncController does but with a little extra logic.
* #Route("/api/v{version}/_action/my-extension/sync",
* name="api.action.my-extension.sync",
* methods={"POST"}
* )
The entry in my services.xml:
<service id="MyExtension\Api\Controller\CustomSyncController" public="true">
<argument type="service" id="Shopware\Core\Framework\Api\Sync\SyncService"/>
<argument type="service" id="serializer"/>
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
</service>
The entry in my routes.xml:
<import resource="../../Api/Controller" type="annotation" />
As I understand it, that should be sufficient to let Shopware 6 know what my Route is and I should be able to send my POST Request to this Route.
Everything works fine on localhost.
My question:
What steps do I have to take to use this plugin on our production environment, because I always get this message on production:
{"errors":[{"code":"0","status":"404","title":"Not Found","detail":"No route found for \u0022POST \/api\/v3\/_action\/my-extension\/sync\u0022"}]}
What I tried to make it work:
just ZIP the folder custom/plugins/MyExtension and upload my plugin to production.
upload my plugin to localhost, run ./psh.phar administration:build, download the folder from localhost, ZIP this folder and upload it to production.
upload my plugin to localhost, run ./psh.phar administration:build and ./psh.phar storefront:build, download the folder from localhost, ZIP this folder and upload it to production.
After uploading my plugin also start the script "build-administration.sh" and "build-storefront.sh" on our production environment.
Currently I am lost, because I can´t understand what steps are necessary to get the same results in the production environment that I get on localhost.

Meybe you try this in your routes.xml.
<import resource="../../Api/Controller/**/*.php" type="annotation" />
Also the routes.xml file must be located in src/Resources/config/routes.xml in your plugin.
Also you didn't mentioned the installation of the plugin, so you also have to install and activate it.

Related

How to fix error "ANCM In-Process Handler Load Failure"?

I'm setting up the first site in IIS on Windows Server 2016 Standard.
This is a NET Core 2.2 application. I cannot get the site to show.
I am getting this error:
HTTP Error 500.0 - ANCM In-Process Handler Load Failure
What can I change to clear this error and get my site to display?
My application is a dll.
I tested my application on the server through the Command Prompt with
dotnet ./MyApp.dll
it displays in the browser but only on the server itself with (localhost:5001/).
Using this method the site cannot be accessed from any other server.
When I set up the site through IIS, I get the In-Process error both on the server and from servers attempting to access the site.
At first I was receiving the Out-Process error. Something I read said to add this (hostingModel="inprocess") to my web.config
so I did but now I receive the In-Process error.
The site works fine when installed on my development server.
The Event Viewer shows this error for "IIS AspNetCore Module V2":
Failed to start application '/LM/W3SVC/2/ROOT', ErrorCode '0x8000ffff'.
This is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="RemoteOnly"></customErrors>
<identity impersonate="false" password="****" userName="****" />
</system.web>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" hostingModel="inprocess" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
<environmentVariables />
</aspNetCore>
</system.webServer>
</configuration>
I had the same issue in .Net core 2.2. When I replace
web.config:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
to
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
then it works fine.
Note: The same solution also works for .Net core 2.2 and other upper versions as well.
Open the .csproj file and under Project > PropertyGroup > AspNetCoreHostingModel, change the value “InProcess” to “OutOfProcess”.
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
Sometimes this is because multiple applications may be using same Application Pool
In such cases first application will work and other won't work
Solution is to create new application pool for each application.
I had the same error.
According to Microsoft(https://dotnet.microsoft.com/download/dotnet-core/current/runtime), We should install the 'ASP.NET Core Hosting Bundle' in our hosting server.
'The ASP.NET Core Hosting Bundle includes the .NET Core runtime and ASP.NET Core runtime. If installed on a machine with IIS it will also add the ASP.NET Core IIS Module'
After I did, The 'AspNetCoreModuleV2' installed on my server and everything works well. It didn't need to change your 'web.config' file.
For more info, in web.config, set
stdoutLogEnabled="true"
then check the logs folder. In my case it had nothing to do with project, publishing or hosting settings - it was my fault for not copying a file essential to my app. The error was simply "Could not find file "D:\Development\IIS Hosting Test\filename.ext"
For my particular issue it was the site permissions in IIS.
I edited the permissions to "Everyone" and it worked. I got the information from this page: https://github.com/aspnet/AspNetCore/issues/6111
I belive that IISExpress got messed up along the way.
Try the following:
'Clean Solution' from VS
Got to the solution folder and delete the .vs folder from there.
Build and run.
I faced with the same issue today, installing the following package on server is fixed the issue for me. If you have any previous version of Windows Hosting Bundle already installed on the server, you install the new one without restarting the server.
ASP.NET Core 3.1 Runtime (v3.1.11) - Windows Hosting Bundle
In my case updating .net core sdk works fine.
You can get this if you try to access the site using a IIS url but Visual Studio is setup to use IISExpress
See also
ASP.Net Core 1.0 RC2 : What are LAUNCHER_PATH and LAUNCHER_ARGS mentioned in web.config?
Long story short, the web.config is changed by Visual Studio when you switch between IIS and IISExpress. If you use an IIS url when it's setup to use IISExpress then the aspNetCore processPath will be wrong
Also, it's not uncommon to copy web.config files. You could get the same error if you don't change the processPath
I fixed this here Asp.Net Core Fails To Load - you need to specify that the program uses an in process or out of process model.
I changed my CreateWebHostBuilder to:
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var builder = WebHost.CreateDefaultBuilder(args);
if (env == EnvironmentName.Staging || env == EnvironmentName.Production)
builder.UseIIS();
builder.UseStartup<Startup>();
return builder;
}
PS. I set ASPNETCORE_ENVIRONMENT in my .pubxml deployment profile by adding:
<PropertyGroup>
<EnvironmentName>Staging</EnvironmentName>
</PropertyGroup>
For me it was because I had ASPNETCORE_ENVIRONMENT environment variable being defined 2 times in my app - one in web.config and another - in applicationhost.config
In my case just adding MVC into Startup.cs Please follow into image. I am trying to add dependency injection then showing this problem. I think it will be helpful.
Follow this Image: https://i.stack.imgur.com/ykw8P.png
Delete the 'hosting Model ="in process"' section in web config.
Example:
<aspNetCore processPath="dotnet" arguments=".\WebAPICore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
to
<aspNetCore processPath="dotnet" arguments=".\WebAPICore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
I'm also getting "HTTP Error 500.0 - ANCM In-Process Handler Load Failure"
Except in my case...Everything was running great until I got the Blue Screen of Death.
I have a solution with two startup projects. One is an API (that comes up) and the other is a WebApp(which gets the error). Both are .NET Core 3.1..also VS2019.
First I tried setting a break point in Main() of program.cs...it never got this far.
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
On a hunch...I Looked at the NuGet packages installed.
I uninstalled and (re)installed
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation(3.1.6)
...and now its working again.
In case anyone else cannot find a solution to this here was my scenario:
I recently started a new project using .NET 5, and everything was working. Then I upgraded from Preview 5 to 7 and all of a sudden my IIS Express would no longer work. The fix for me was to simply repair Visual Studio:
.
This happened to me when I switched form debugging in IIS Express to IIS. I inspected Event Viewer > Application log, and found the following error there:
Executable was not found at '...\bin\Debug\netcoreapp3.1\%LAUNCHER_PATH%.exe'
I then found the solution to that in the following thread.
I basically needed to replace web.config entry with hard-coded name of the application:
<aspNetCore processPath="dotnet" arguments=".\ProjectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
I get that error when i try to get data from the ViewModel as List<> and my data is coming as IEnumerable format.
Before u guys update your vs2019 or delete some files,u should better to check it out that option.
For me it was caused by different web.config files for development and deployment :
development: <aspNetCore requestTimeout="23:00:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" startupTimeLimit="3600" hostingModel="InProcess">
deployment : <aspNetCore requestTimeout="23:00:00" processPath=".\Nop.Web.exe" arguments="" forwardWindowsAuthToken="false" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" startupTimeLimit="3600" hostingModel="InProcess">
In my case, I put app_name.exe back from my backup folder to bin\debug, and boom it worked.
If you don't have a backup folder that contains exe so don't worry publish your web app / web API and copy from there
No previous answers worked for me. In my case the "processPath" inside "aspNetCore" tag was pointing to a non-existing folder. A colleague told me that when any value in the web.config is wrong the app doesn't start and emerge this weird error.
In my case, after updating to .Net 6 and using a self contained application I started seeing this error.
I could manually set the module to AspNetCoreModule and the application would run in IIS but I knew this was just a work around since AspNetCoreModuleV2 should be used with .Net 6 applications
I had the following line in the ConfigureServices method:
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
Removing the compatibility version resolved my issue.
services.AddMvc();
This is a temporary problem caused by changes in folder or host settings while the application was running.
Most solutions provided here are working because they are indirectly triggering a restart. eg: Changing web.config will trigger a process cleanup and restart for that app.
Solution: Is restart the application process
If the problem still persist after the restart then check EventViewer to see the actual problem, a persistent problem usually means your application has a bug.
I tried changing aspnetCoreModuleV2 to aspnetCoreModuleV2, which worked, but it was a hassle to change every time I published it in Visual Studio.
After testing, I found that I could change the application pool default Settings for IIS to enable 32-bit applications in general.
But I haven't tested it on a 32-bit computer, it should be OK.
See Screenshot.
Fixing all project build errors, would simply fix this issue & the application will load.
Change platform target to Any CPU.

Azure function multiple output binding Extensions error

I'm developing an Azure function through the portal,
My function is an HttpTrigger with httpResponse.
I add a TableStorage output binding and install its Extension (everything is fine).
I add a SendGrid output binding and install its Extension (the extension installer give me a message saying "it takes longer than expected" and seems to fail. Afterward, my function is broken.
I tried creating my bindings in reverse order (SendGrid then TableStorage). It now fails on TableStorage installation.
Any way to resolve this issue?
Thanks
It's a known issue that sometimes filesystem for Consumption plans reacts slow, e.g during extension installation with many file I/O operations.
The first suggestion is to delete the extensions and retry.
Stop Function app.
In portal, Platform features> App Service Editor.
Right click on bin folder and extensions.csproj, Delete.
Start Function app.
Delete existing output bindings and add them again to install extensions.
If this doesn't work, try to manually install the extensions.
Stop Function app.
In portal, Platform features> App Service Editor.
Right clik on the blank under WWWROOT, New File extensions.csproj then add content below.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<WarningsAsErrors />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SendGrid" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.0.*" />
</ItemGroup>
</Project>
Press Ctrl+Shift+C to open console, or click the second button Open Console from the bottom on the sidebar.
Input dotnet build extensions.csproj -o bin --no-incremental --packages D:\home\.nuget and wait for the command to finish.
Start Function app.

Web Deploy package throws ERROR_SITE_DOES_NOT_EXIST when deployed

After creating a WDP from an aspnet solution, the [project name].deploy.cmd file returns this error when executed:
Error Code: ERROR_SITE_DOES_NOT_EXIST
More Information: Site 'freedomstoreusa.azurewebsites.net' does not exist. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SITE_DOES_NOT_EXIST.
Error count: 1.
My objective is to deploy the package to this site as if it were publishing to azure from visual studio 2017. What is causing this issue, what can resolve it and what are some alternatives to packaging and deploying a website?
Here are my settings in the package wizard:
what can resolve it and what are some alternatives to packaging and deploying a website?
I build and package the web application project, and use MSDeploy.exe to deploy the web application, which works fine on my side.
Command:
TestSite.SetParameters.xml
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="{app name}" />
</parameters>
I came here with the same problem but the image in the question and the answer from Fei Han solve my problem I was creating a File System Package not a Web Deploy Package which will create App.SetParameters.xml and the App.zip in the selected folder it also will ask for the app name an then you can use that auto generated file for the param -setParamFile:

Cant Run Java FX Executable Jar or Native Bundle

I have created a java fx application on Netbeans 7.3.1 with fxml,hibernate. It works fine when run in Netbeans and when run the jar file from dist folder. Database operations are just fine. But I want export the app to another system in a portable form. So i created the native bundle using the tools Wix and Inno 5. But the produced app doesnt work in my own syntem or another system. Shows Exception while runnig application. I checked several times by changing the db ip address as localhost, 127.0.0.1 and my my physical ip. but no working.
My java version is Java 7 update 40 (jdk1.7.0_40)
This is the link for the screenshot showing error : http://i.imgur.com/popokhh.jpg
my build.xml contains
<target name="-post-jfx-deploy">
<fx:deploy width="${javafx.run.width}" height="${javafx.run.height}"
nativeBundles="all"
outdir="${basedir}/${dist.dir}" outfile="${application.title}">
<fx:application name="${application.title}" mainClass="${javafx.main.class}"/>
<fx:resources>
<fx:fileset dir="${basedir}/${dist.dir}" includes="*.jar"/>
</fx:resources>
<fx:info title="${application.title}" vendor="${application.vendor}"/>
</fx:deploy>
</target>
And my hibernate cfg file contains
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/sample?zeroDateTimeBehavior=convertToNull</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<mapping resource="entity/Sample.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Is there any extra configuration for the application to work independently??
I got it fixed...
All i need to do was include the lib folder in the build... My bad.

IIS WebDeploy using MS Build Fails with error MSB4044 -ConcatFullServiceUrlWithSiteName task

In setting up a Jenkins deployment job, I kept running into this error when trying to deploy a Visual Studio 2012 Web project via the command line.
error MSB4044: The "ConcatFullServiceUrlWithSiteName" task was not given a value for the required parameter "SiteAppName"
For reference, here are the parameters that I used:
/p:Configuration=Release /t:Rebuild /p:VisualStudioVersion=11.0 /p:PublishProfile="DeployToDevServer"
/p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish
/P:AllowUntrustedCertificate=True /p:MSDeployPublishMethod=WMSvc
/p:MsDeployServiceUrl=https://devmachine.server.com:8172/MsDeploy.axd
/p:username=domainhere\adminuserhere /p:password=adminpasshere
Note: It would deploy just fine if I chose Publish... from inside the project.
After much googling, and finally comparing a project that would deploy with the one that wouldn't, I finally figured it out after I opened the .csproj files with a text editor and compared them.
In the project that worked, I found this section:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
And it had this line:
<DeployIisAppPath>Default Web Site/sitenamehere</DeployIisAppPath>
I added this same line to the non-working project, changed the sitename, and it worked.
Hope this helps someone else.
You could pass this DeployIisAppPath as parameter to Jenkins, like this:
p:DeployIisAppPath=Default Web Site/sitenamehere
This would allow you to have different sitenames on different machines. While in your example (with CSPROJ modification) you would be obliged to have one IIS site name on all target machines

Resources