I have this issue with sitecore that started happening recently. Whenever i try to add a new item using a template, I get the following error. Could someone help me why this is happening.
Could not resolve type name: Sitecore.Buckets.Pipelines.UI.AddFromTemplate.SelectItem (method: Sitecore.Configuration.Factory.CreateType(XmlNode configNode, String[] parameters, Boolean assert)).
Stack Trace:
[Exception: Could not resolve type name: Sitecore.Buckets.Pipelines.UI.AddFromTemplate.SelectItem (method: Sitecore.Configuration.Factory.CreateType(XmlNode configNode, String[] parameters, Boolean assert)).]
Sitecore.Diagnostics.Error.Raise(String error, String method) +138
Sitecore.Configuration.Factory.CreateType(XmlNode configNode, String[] parameters, Boolean assert) +428
Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert) +67
Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +141
Sitecore.Pipelines.Processor.Parse(XmlNode node) +401
Sitecore.Pipelines.PipelineFactory.GetProcessors(String pipelineName) +376
Sitecore.Pipelines.PipelineFactory.GetPipeline(String pipelineName) +74
Sitecore.Web.UI.Sheer.ClientPage.Start(String processor, NameValueCollection parameters) +94
Sitecore.Shell.Framework.Items.Start(String pipelineName, Item item) +273
Sitecore.Shell.Framework.Dispatcher.Dispatch(Message message, CommandContext context) +193
Sitecore.Shell.Applications.ContentManager.ContentEditorForm.HandleMessage(Message message) +1874
Sitecore.Shell.Framework.Commands.MessageCommand.Execute(CommandContext context) +168
Sitecore.Web.UI.Sheer.ClientPage.OnPreRender(EventArgs e) +612
Sitecore.Shell.Applications.ContentManager.ContentEditorPage.OnPreRender(EventArgs e) +25
System.Web.UI.Control.PreRenderRecursiveInternal() +113
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4297
Related
When I try to edit a personalisation rule on a component, I'm getting the following error:
In my browser's network tab, I can see that a request is being made to the following URL:
/sitecore/shell/-/xaml/Sitecore.Shell.Applications.Rules.RulesEditor.aspx?hdl=584EB7FC4C5D4AD6A9A21EED4F48D2AA
The response is a YSOD, which contains the following stack trace:
[InvalidOperationException: element is null]
Sitecore.Shell.Applications.Rules.RulesEditor.RulesEditorPage.Edit(String uid, String name, String control, String parameters) +727
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +160
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101
Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.ExecuteAjaxMethod(AjaxMethodEventArgs e) +72
Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.Sitecore.Web.UI.XamlSharp.Ajax.IIsAjaxEventHandler.HandleMethodEvent(AjaxMethodEventArgs e) +33
Sitecore.Web.UI.WebControls.AjaxScriptManager.DispatchMethod(Control control, String parameters) +319
Sitecore.Web.UI.WebControls.AjaxScriptManager.Dispatch(String clientId, String parameters) +303
Sitecore.Web.UI.XamlSharp.Ajax.AjaxContinuationProcessor.Invoke(PipelineArgs args) +370
Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume(PipelineArgs args, Pipeline pipeline) +225
Sitecore.Pipelines.Pipeline.Resume() +38
Sitecore.Pipelines.Pipeline.DoStart(PipelineArgs args) +115
Sitecore.Pipelines.Pipeline.Start(PipelineArgs args, Boolean atomic) +169
Sitecore.Web.UI.WebControls.ContinuationManager.RunPipelines() +306
Sitecore.Web.UI.WebControls.ContinuationManager.OnPreRender(EventArgs e) +307
System.Web.UI.Control.PreRenderRecursiveInternal() +88
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +883
The following message is written to the Sitecore log when the error occurs:
2019-05-10T09:22:48 PID[8228] Error 8816 09:22:48 ERROR Application error.Exception: System.Web.HttpUnhandledExceptionMessage: Exception of type 'System.Web.HttpUnhandledException' was thrown.Source: System.Webat System.Web.UI.Page.HandleError(Exception e)at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)at System.Web.UI.Page.ProcessRequest()at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)at System.Web.UI.Page.ProcessRequest(HttpContext context)at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)Nested ExceptionException: System.Reflection.TargetInvocationExceptionMessage: Exception has been thrown by the target of an invocation.Source: mscorlibat System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)at Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.ExecuteAjaxMethod(AjaxMethodEventArgs e)at Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.Sitecore.Web.UI.XamlSharp.Ajax.IIsAjaxEventHandler.HandleMethodEvent(AjaxMethodEventArgs e)at Sitecore.Web.UI.WebControls.AjaxScriptManager.DispatchMethod(Control control, String parameters)at Sitecore.Web.UI.WebControls.AjaxScriptManager.Dispatch(String clientId, String parameters)at Sitecore.Web.UI.XamlSharp.Ajax.AjaxContinuationProcessor.Invoke(PipelineArgs args)at Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume(PipelineArgs args, Pipeline pipeline)at Sitecore.Pipelines.Pipeline.Resume()at Sitecore.Pipelines.Pipeline.DoStart(PipelineArgs args)at Sitecore.Pipelines.Pipeline.Start(PipelineArgs args, Boolean atomic)at Sitecore.Web.UI.WebControls.ContinuationManager.RunPipelines()at Sitecore.Web.UI.WebControls.ContinuationManager.OnPreRender(EventArgs e)at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Control.PreRenderRecursiveInternal()at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)Nested ExceptionException: System.InvalidOperationExceptionMessage: element is nullSource: Sitecore.Clientat Sitecore.Shell.Applications.Rules.RulesEditor.RulesEditorPage.Edit(String uid, String name, String control, String parameters)
We're using Sitecore.NET 9.0.0 (rev. 171002), running as an Azure app service.
Any thoughts?
So, it turns out the problem was that the "App_Browsers" folder was missing on the server. I replaced this folder, restarted the web app and the problem seems to be fixed.
In my controller, i am doing a validation check in if block using a validator class.
Since validation code is not complete yet i just want to test that if
validation was successful the response should be 201(Success).
For this i am mocking the behaviour of validator object to return true
i.e its valid.
The problem is even if i have mocked the validator object behaviour to not enter if block so it doesn't throw validation Exception, its actually entering and throwing exception. That means mocking hasn't worked. I know its bad to assume the method implementation for testing, but i want to know why its not working.
myController.class
#RestController
#RequestMapping("/v1/api")
public class myController {
#Autowired
private RequestService requestService;
#Autowired
RequestValidator validator;
#PostMapping(value = "")
#ResponseStatus(code = HttpStatus.CREATED)
public #ResponseBody
BaseResponse<Response> create(#RequestBody Request<Data> request){
if(!validator.isValidRequestObject(request))
{
throw new RuntimeException("invalid request");
}
Response data = requestService.submitData(request);
BaseResponse<Response> response = new BaseResponse<Response>();
response.setData(data);
response.setMessage("Created Successfully");
return response;
}
ControllerTest.class
#RunWith(SpringRunner.class)
#SpringBootTest
#AutoConfigureMockMvc
public class ControllerTest {
#Autowired
private MockMvc mockMvc;
#Autowired
Request<Data> request;
#MockBean
RequestService service;
#MockBean
RequestValidator validator;
ObjectMapper mapper = new ObjectMapper();
#Test
public void createTest() throws Exception {
when(validator.isValidRequestObject(request)).thenReturn(true);
when(service.submitData(request)).thenReturn(null);
this.mockMvc.perform(post("/v1/api")
.content(mapper.writeValueAsString(request))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isCreated());
}
If i remove the throw new exception line, test passes.
i assume that since i have mocked validator behaviour in myController
that should not enter if block and hence not throw Exception.
But its entering the if block and throwing exception defying the mocked behaviour.
I am writing a SoapHandler to intercept SOAP calls. I'm testing whether its an incoming or outgoing soap message as follows:
public class MySoapHandler implements SOAPHandler<SOAPMessageContext> {
private static Logger logger = Logger.getLogger(MySoapHandler.class);
#Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if(isRequest)logger.debug("isRequest=true");
else logger.debug("isRequest=false");
When I submit the soap request I see "isRequest=true" occur twice, first when the soap request is received, and then again just before the soap response is sent. I was expecting to see "isRequest=false" the second time.
Can anyone shed some light?
Boolean needs to be boolean:
public class MySoapHandler implements SOAPHandler<SOAPMessageContext> {
private static Logger logger = Logger.getLogger(MySoapHandler.class);
#Override
public boolean handleMessage(SOAPMessageContext context) {
boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if(isRequest)logger.debug("isRequest=true");
else logger.debug("isRequest=false");
I am trying to make a simple REST Service with .NET 4.0 that uses ninject to inject any dependencies for the service.
This is what my service looks like currently:
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class ReportService
{
private readonly ReportManager _reportManager;
public ReportService(ReportManager reportManager)
{
_reportManager = reportManager;
}
[WebInvoke(UriTemplate = "GetReports", Method = "GET")]
public List<ReportDTO> GetReports()
{
var reports = _reportManager.GetReports();
return reports.ToList();
}
}
This is my global.asax:
public class Global : NinjectHttpApplication
{
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("ReportService", new NinjectWebServiceHostFactory(), typeof(ReportService)));
}
protected override IKernel CreateKernel()
{
return new StandardKernel(new ServiceModule());
}
}
And my ServiceModule:
public class ServiceModule : NinjectModule
{
public override void Load()
{
Bind<IFRSDbContext>().To<FRSDbContext>().InRequestScope();
Bind<IDatabaseFactory>().To<DatabaseFactory>().InRequestScope();
Bind<IUnitOfWork>().To<UnitOfWork>().InRequestScope();
Bind<IReportRepository>().To<ReportRepository>();
Bind<ReportManager>().ToSelf();
Bind<ReportService>().ToSelf();
}
}
I keep getting the following exception when I try to run my service:
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: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +222
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253
[HttpException (0x80004005): Object reference not set to an instance of an object.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9079228
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
EDIT
I've updated to the most current version of my Service.. I am using Ninject 2.3 and Ninject.Extensions.Wcf 2.3 from here but am still having no luck.. what am I doing wrong? I've followed everything from the WcfTimeService example except that I am using a REST service and not a .svc Wcf service...
You shouldn't call Application_Start. Instead override OnApplicationStarted
After downloading the sources of Ninject.Web.Common and Ninject.Extensions.Wcf I was able to track down the issue.
In order to get this to work without a *.svc file you need to call the Application_Start() method of the NinjectHttpApplication at the end of the Application_Start() in Global.asax.cs file, like so:
public class Global : NinjectHttpApplication
{
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
Application_Start(); // added call
}
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("ReportService", new NinjectWebServiceHostFactory(), typeof(ReportService)));
}
protected override IKernel CreateKernel()
{
return new StandardKernel(new ServiceModule());
}
}
Without doing this, the Kernel never gets created and therefore that is what causes the NullReferenceException. After I did this everything started working perfectly.
I have a method that performs an asynchronous service call. I call this class by passing in the callback.
public void GetRights(EventHandler<GetRightsCompletedEventArgs> callback)
{
ServiceClient client = new ServiceClient();
client.GetRightsCompleted += new EventHandler<GetRightsCompletedEventArgs>(callback);
client.GetRightsAsync();
}
GetRights(GetRightsCallback);
I'm creating tests with MSTest, and I've mocked the containing class (IGetRightsProxy) in Moq. How can I invoke the callback when this method is called in the test?
GetRightsForCurrentUserCompletedEventArgs results =
new GetRightsCompletedEventArgs(
new object[] { new ObservableCollection<Right>()}, null, false, null);
Mock<IGetRightsProxy> MockIGetRightsProxy = new Mock<GetRightsProxy>();
One way of doing what I want is to extend the class like this:
class MockGetRightsProxy : IGetRightsProxy
{
public void GetRights(EventHandler<GetRightsCompletedEventArgs> callback)
{
// Create some args here
GetRightsCompletedEventArgs args = new GetRightsCompletedEventArgs(
new object[] { new ObservableCollection<Right>() }, null, false, null);
callback(null, args);
}
}
I was looking for ways to invoke the callback in Moq, but this works, too.
You want to be looking at Moq's Callback() extension on your mock;
Mock<IGetRightsProxy> mock = new Mock<IGetRightsProxy>();
mock.Setup(x => x.GetRights(It.IsAny<EventHandler<GetRightsCompletedEventArgs>>())
.Callback<EventHandler<GetRightsCompletedEventArgs>>(
callback => callback(mock.Object, new GetRightsCompletedEventArgs())
);
When the code under test calls GetRights() on the IGetRightsProxy mock the actual EventHandler<GetRightsCompletedEventArgs> it passes in will subsequently be passed into Moq's Callback() method.
Note: Type inference will work on the generic applied to Callback() but I find in these cases it is a bit more readable to explicitly define the type being passed into the method.