Page Type of a class name not found exception - kentico

I am new to Kentico and going through the Kentico 12 MVC Training Course using the MedioClinic sample project. On running the MVC project for live site I am getting the below error. Could someone please help me with this.
Server Error in '/Kentico12_MedioClinic' Application.
Page type with 'MedioClinic.HomeSection' class name not found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CMS.DocumentEngine.DocumentTypeNotExistsException: Page type with 'MedioClinic.HomeSection' class name not found.
Source Error:
Line 38: {
Line 39: var query = DocumentHelper.GetDocuments();
Line 40:
Line 41: // Loads the latest version of documents as preview mode is enabled
Line 42: if (SiteContext.IsPreviewEnabled)
Source File: C:\Users\A0808038\Desktop\Kentico\training-kentico-k12-master\training-kentico-k12-master\Business\Services\Query\DocumentQueryService.cs Line: 40
Thanks in Advance

From the admin area go to edit the page type "MedioClinic.HomeSection" and click on the vertical tab "Code" then from there click on generate code, so those are saved physically on the /CMS/Old_App_code folder from the WebApp solution.
Copy that generated file to your MVC project, add the correct using to your class and that should fix the issue.

Related

Custom page Error doesn't work. (in production always return code 500)

So i'm working on a project and i wanted to make custom error page like 404 500 ...
So i read on symfony documentation that all i have to do is composer twig-pack, then add the error404.html.twig in this tree directory \templates\bundles\TwigBundle\Exception. To finish I have to change my .env in prod to see my beauty error page.
But when i try to type a wrong url expecting to get my 404, instead, i got a 500 (the basic error page from symfony).
I checked my logs and i found that i got this Critical Error :
[2021-07-14T08:35:15.194689+00:00] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET https://micro59/dejifosd"" at C:\wamp\www\Projects\micropro\vendor\symfony\http-kernel\EventListener\RouterListener.php line 136 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET https://micro59/dejifosd\" at C:\\wamp\\www\\Projects\\micropro\\vendor\\symfony\\http-kernel\\EventListener\\RouterListener.php:136)\n[previous exception] [object] (Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): No routes found for \"/dejifosd/\". at C:\\wamp\\www\\Projects\\micropro\\vendor\\symfony\\routing\\Matcher\\Dumper\\CompiledUrlMatcherTrait.php:70)"} []
[2021-07-14T08:35:15.229712+00:00] php.CRITICAL: Uncaught Error: Symfony\Bridge\Twig\Extension\RoutingExtension::getPath(): Argument #1 ($name) must be of type string, null given, called in C:\wamp\www\Projects\micropro\var\cache\prod\twig\d5\d51256555fdd9ed9db40150aba9ba2f8325c04e57ae45e60937191a29447ddd2.php on line 37 {"exception":"[object] (TypeError(code: 0): Symfony\\Bridge\\Twig\\Extension\\RoutingExtension::getPath(): Argument #1 ($name) must be of type string, null given, called in C:\\wamp\\www\\Projects\\micropro\\var\\cache\\prod\\twig\\d5\\d51256555fdd9ed9db40150aba9ba2f8325c04e57ae45e60937191a29447ddd2.php on line 37 at C:\\wamp\\www\\Projects\\micropro\\vendor\\symfony\\twig-bridge\\Extension\\RoutingExtension.php:46)"} []
[2021-07-14T08:35:15.232242+00:00] request.CRITICAL: Uncaught PHP Exception TypeError: "Symfony\Bridge\Twig\Extension\RoutingExtension::getPath(): Argument #1 ($name) must be of type string, null given, called in C:\wamp\www\Projects\micropro\var\cache\prod\twig\d5\d51256555fdd9ed9db40150aba9ba2f8325c04e57ae45e60937191a29447ddd2.php on line 37" at C:\wamp\www\Projects\micropro\vendor\symfony\twig-bridge\Extension\RoutingExtension.php line 46 {"exception":"[object] (TypeError(code: 0): Symfony\\Bridge\\Twig\\Extension\\RoutingExtension::getPath(): Argument #1 ($name) must be of type string, null given, called in C:\\wamp\\www\\Projects\\micropro\\var\\cache\\prod\\twig\\d5\\d51256555fdd9ed9db40150aba9ba2f8325c04e57ae45e60937191a29447ddd2.php on line 37 at C:\\wamp\\www\\Projects\\micropro\\vendor\\symfony\\twig-bridge\\Extension\\RoutingExtension.php:46)"} []
Aaaaaaaand thats where i'm stuck. I try many things (Composer update, Clear cache...) but nothing change. If someone would have the kindness to help me that would be much appreciate it.
The class & method in the error message, RoutingExtension::getPath(), defines a Twig function - path(). Your error404.html.twig file uses that function but doesn't have the required first parameter ('name', the route name) - or the value that is being passed to it, is null.
How to Customize Error Pages has a simple error-page template, and has a sample path/route-name {{ path('homepage') }}.
You can get a list of the routes you have available so far with bin/console debug:router - it must be known to the framework, or it will throw an error about an unknown route.
It also has a .yaml you can use to make the error pages available in development (your controller is fine, this would be a bit cleaner and easier - and would only be available in development because of the path within the config/ directory is only read when your APP_ENV variable is 'dev').
If you have not already, composer require debug-pack and any errors - including on your '/error404' page will show a 'big friendly error page', should also add a lot of useful information - often including showing the file and line in the twig template.
In this particular instance, because of the type of error, it can't as it's deep in the Twig library internals (and comes from the PHP type-system, not an error found directly by Symfony or Twig) - but it will have a link in the stack trace to show the compiled twig template (in a randomly named file in ./var/cache/dev/twig/../.......php) and it shows where in the twig template it's calling the ->getPath(); - so you'll be able to track it down in the actual .twig file (it adds comments for the line number within the template to help).

How to write an html from a remote function using writeDump or writeOutput?

I am coming from Adobe Coldfusion and I'm trying to debug a component in Lucee by writing values to the output. Normally what I do is:
component Sample {
remote Void function spotCheck() {
writeDump(1234);
writeOutput("<br>Test");
return
}
Then hit the page to HTTP://localhost/sample/Sample.cfc?method=spotCheck
But it does not work. I updated the function to have a returnformat="text", but then the output is plain text with HTML tags in its text form. I tried setting it to "html" instead of text but then I get the error below:
This page contains the following errors:
error on line 20 at column 17: xmlParseEntityRef: no name
Below is a rendering of the page up to the first error.
I'm probably doing it the wrong way and I'm happy to learn the Lucee way of how to easily inspect values of variables inside a component function.
PS: I don't have/use step by step debugger.

Windows 10 >= 1809 issues with jacob and Word ComObject

we have an old legacy app which uses Java version 1.6 update 45 (jdk-6u45-windows-i586.exe) and Jacob.dll 1.8 (jacob_18.zip), and which cannot be updated :(
Everything was working fine till the latest Windows 10 1809 Update. Since then the comobject behavior seems to have changed and causes an error as well as that the word document cannot be saved anymore. I also tried 19H1 but got the same error.
I could reproduce the issue in java with following code, of course you have to import the Jacob.dll:
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Variant;
import com.jacob.com.Dispatch;
ActiveXComponent oWord = new ActiveXComponent("Word.Application");
oWord.setProperty("Visible", new Variant(true));
Dispatch documents = oWord.getProperty("Documents").toDispatch();
String str_file = "C:/temp/test.rtf";
Dispatch doc = Dispatch.invoke(documents, "Open", Dispatch.Method,
new Object[]{str_file},
new int[1]).toDispatch();
The error I get is:
Exception in thread "main" com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: Open
Description: An unknown COM error has occured.
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:384)
at com.jacob.com.Dispatch.invoke(Dispatch.java:267)
at Main.main(Main.java:21)
When I click on the Dispatch errors I only get that it is not a valid line number in com.jacob.com.Dispatch
I know it is not the best day not updating the legacy app itself, but what can I say, it is as it is.
Any ideas what might have changed in Windows >= 1809 or how it can be solved without touching the app?
Thanks
Stephan
Edit:
Dispatch oDocument = Dispatch.call(documents, "Open", str_file).toDispatch(); leads to the same error
I should mention that Word opens, but I am not able to save the file and that the return value is an error
OK, the error is the same which is covered in this post:
Exception from Word.ApplicationClass.Activedocument all of a sudden
So it seems to be a bug in >=1809 and for the moment the only fix is to change/play with the regional settings

Can't add media on Orchard v.1.10.1.0

I did a setup of an Orchard v.1.10.1.0 with the default recipe and can't add media. The Javascript console shows this error:
GET https://website.azurewebsites.net/Media/Default/_Profiles/1338a03e/abbfa561/header.png?v=636100967487424883 404 (Not Found)
Uncaught TypeError: deepestChildPath.contains is not a function
This is a known bug in Orchard 1.10. You should be able to fix it by changing line 385 in Orchard.Web/Modules/Orchard.MediaLibrary/Scripts/media-library.js
to var separator = deepestChildPath.indexOf('/') > -1 ? '/' : '\\';
as shown in the GitHub history.

XPages Custom Error Page - get error message and line

I'm trying to generate a custom error page for my xpages. I googled a lot of solutions and so far I get an error page telling me, that an error occured.
But I can't get the information what exactly happened (in this case the error is, that an "doc" has to be saved, but i named the variable "docs" just to get error).
All I do is:
var errObj = requestScope.error;
output = errObj.getCause().getErrorPropertyId();
output = errObj.getCause().getComponentId();
As soon as I try to call getExpressionText() I get an error 500.
How do I get the information, where the error happened (line number) and the variable that caused the error? - just like I do using the standard error page.
The error line and details are not easily accessible from requestScope.error. If you look at the source code for the latest release of Mark Leusink's Debug Toolbar, you'll see he's parsing the stack trace to get the details.
However, you can access all the relevant information using the underlying Java class for the SSJS exception - com.ibm.jscript.InterpretException using getErrorLine(). The getLocalizedMessage() method gets the error detail that usually starts "Script interpreter error". The getExpressionText() method retrieves the line that threw the error.
If you take a look at the XPages OpenLog Logger project I put on OpenNTF, that's what I use to log full details to OpenLog. http://www.openntf.org/Internal/home.nsf/project.xsp?action=openDocument&name=XPages%20OpenLog%20Logger
You can see the source code of the OpenLogPhaseListener which uses those methods here: https://github.com/paulswithers/openlogjava/blob/master/OpenLogJava/WebContent/WEB-INF/src/com/paulwithers/openLog/OpenLogPhaseListener.java
Even if you're not a Java expert, from use of SSJS the key parts should be understandable. Line 84 captures uncaught exceptions - when XPages routes to the default error page. That uses the methods I mentioned.
Lines 98 to 105 are the ones that log out all the details if you just use a catch block, passing OpenLogBean.addError(e, this) where e is the error object and this is the component the error occurs on. error.getError() in the Java code retrieves that error object. To get the typeahead in SSJS you'll need to use catch(e:com.ibm.jscript.InterpretException) I believe.
I haven't tested this, I've just working back from what I used for the project on OpenNTF.
Have a look at this XSnippet by Tony McGuckin: http://openntf.org/XSnippets.nsf/snippet.xsp?id=custom-error-page-cw-cause-and-stacktrace-information. It uses the following to output details on the error:
var output = requestScope.error.toString()+"\n\n";
if(requestScope.error instanceof com.ibm.xsp.exception.XSPExceptionInfo){
var codeSnippet = requestScope.error.getErrorText();
var control = requestScope.error.getErrorComponentId();
var cause = requestScope.error.getCause();
output += "In the control : " + control + "\n\n";
if(cause instanceof com.ibm.jscript.InterpretException){
var errorLine = cause.getErrorLine();
var errorColumn = cause.getErrorCol();
output += "At line " + errorLine;
output += ", column " + errorColumn + " of:\n";
}else{
output += "In the script:\n";
}
output += codeSnippet;
}
return output;
For now I've dealt with this problem by using the Debug Toolbar and the OpenLog Database.
If an error occurs the user only gets a custom error page (using the example of the Debug Toolbar) with the information, that something went wrong. So he does not have to bother with any other problems or even the Stack Trace. But at the same moment he gets the error page, the error is logged in our Log-Database with all informations needed (like line, exact error message etc.).
I've also implemented an "Report this problem" Link-Button to create a new E-Mail containing important information about the session the user is currently in.

Resources