I am trying to create a SAVE Method for mailmessage, It is throwing the below error:
An unhandled exception of type 'System.Reflection.TargetParameterCountException' occurred in mscorlib.dll
Additional information: Parameter count mismatch.
Below is the Overriden Method:
_sendMethod.Invoke(
Message,
BindingFlags.Instance | BindingFlags.NonPublic,
null,
new object[] { _mailWriter, true },
null);
The extension method dosen't supports .NET framework 4.5 above versions.
So parameter count exceptions will occur.. The Same extension method is working fine in .NET Framework 4.0 below
Related
I am working on local live staging in Liferay 7.1, in which I have one custom field in Web content. When I export those web content to local live, I want to check that custom field as result I would be export that web content.
So for that, I am extending doExportStagedModel in BaseStagedModelDataHandler as below.
#Component(immediate = true,service = {StagedModelDataHandler.class})
public class Demo extends BaseStagedModelDataHandler<JournalArticle> {
// All the stuff
#Override
protected void doExportStagedModel(
PortletDataContext portletDataContext, JournalArticle article)
throws Exception {
// overridden stuff
}
// Other stuff
}
When I am deploying this, I got below exception.
2018-11-20 04:04:12.669 ERROR The setJournalCreationStrategy method
has thrown an exception java.lang.IllegalArgumentException: argument
type mismatch
2018-11-20 04:04:12.850 ERROR The
setJournalFeedExportImportContentProcessor method has thrown an
exception java.lang.IllegalArgumentException: argument type mismatch
Does anybody having idea how can I do this proper way on this?
I would like to send a binary file via an appended MVCResourceCommand I coded for the native journal portlet. But the program is unable to use the OutputStream provided by the resource request.
IOUtils.copy( input, response.getPortletOutputStream() );
Considering:
The code works perfectly on StrutsActions
In custom portlets, it also works
In StrutsActions:
IOUtils.copy( input, response.getOutputStream() );
However, the code throws an IllegalStateException, saying that the writer is being used when I call response.getOutputStream().
I know we can not mix these two
The code is not attempting to do so
I wonder if Liferay is doing something with that request before it reaches my extension of BaseMVCResourceCommand, this is specifically for that native portlet.
I checked the preview feature for a webcontect item, but its URL is for the view mode.
The URL is created from a portlet:resourceURL tag inserted through a JSP fragment and the command is in its own OSGi module.
For sure, the URL is correct and the command logs that it was hit, but the exception is thrown afterwards.
The portlet I am trying to change is the:
"com_liferay_journal_web_portlet_JournalPortlet"
Any thoughts?
PS: I know about the Servlet and Portlet ResponseUtils. but they also eventually try getting the stream, leadin to the same exception.
#Component( immediate = true,
property = {
"javax.portlet.name=" + JOURNAL, "mvc.command.name=/command"
},
service = MVCResourceCommand.class )
public class Resource extends BaseMVCResourceCommand {
#Override
public void doServeResource( ResourceRequest request, ResourceResponse response ) throws PortletException {
try {
response.getPortletOutputStream();
}
catch ( Exception e ) {
throw new PortletException( e );
}
}
}
Caused by: java.lang.IllegalStateException: Unable to obtain OutputStream because Writer is already in use
at com.liferay.portlet.MimeResponseImpl.getPortletOutputStream(MimeResponseImpl.java:75)
Update:
It seems this is the source of my issues (PortletURLImpl), still looking for a solution though:
if (lifecycle.equals(PortletRequest.RESOURCE_PHASE)) {
_copyCurrentRenderParameters = true;
}
When the URL is created it comes with all sources of garbage from the render phase. Including an MVCPath
Is there mongodb mapping converter for generic message.
No argument constructor not available for generic message.
.11:47:30.937 [http-nio-9080-exec-1] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.messaging.MessageHandlingException: error occurred in message handler [messageHandler]; nested exception is org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate org.springframework.messaging.support.GenericMessage using constructor NO_CONSTRUCTOR with arguments ] with root cause
java.lang.NoSuchMethodException: org.springframework.messaging.support.GenericMessage.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104)
at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:61)
at org.springframework.data.convert.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:83)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:251)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:231)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readValue(MappingMongoConverter.java:1186)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.access$200(MappingMongoConverter.java:78)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:1134)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:1097)
Also I am trying following config of mongotemplate
Please advise if correct
public MongoTemplate messagingMongoTemplate() throws Exception {
MongoTemplate mongoTemplate=null;
try {
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory);
MappingContext mappingContext = new MongoMappingContext();
MappingMongoConverter mappingMongoConverter = new MappingMongoConverter(dbRefResolver,mappingContext);
CustomConversions customConversions = new CustomConversions(Arrays.asList(new MongoDbMessageBytesConverter()));
mappingMongoConverter.setCustomConversions(customConversions);
mongoTemplate=new MongoTemplate(mongoDbFactory,mappingMongoConverter);
Starting with version 3.0 it is recommended to use ConfigurableMongoDbMessageStore as that provides more options for customization, including a Converter for Message.
Out-of-the-box Spring Integration provides MongoDbMessageBytesConverter, which has become public since 4.2.10 and is used by default if there is no any external customization for the ConfigurableMongoDbMessageStore.
Swift 3 has migrated my code and changed:
context.deleteObject(myManagedObject)
to
context.delete(myManagedObject)
this is compiling fine (XCode 8b3) but at runtime complaining that the context does not have a function/selector delete(managedObject)
Here is the runtime error:
[NSManagedObjectContext delete:]: unrecognized selector sent to instance
My code is very basic:
func delete()
{
let appDel: AppDelegate = UIApplication.shared().delegate as! AppDelegate
if let context: NSManagedObjectContext = appDel.managedObjectContext
{
context.delete(exerciseData)
appDel.saveContext()
}
}
Why is it no longer working?
Thanks
Greg
From the Xcode 8 beta 3 - Release Notes
Known Issues in Xcode 8 beta 3 – Swift Compiler
Attempting to use NSManagedObjectContext's delete(:) method may result in calling the UIKit-added delete(:) method on NSObject instead (part of the UIResponderStandardEditActions category) if the argument is optional (including ImplicitlyUnwrappedOptional). (27206368)
Workaround: Manually unwrap the optional value using if let or !.
You need to check if this holds true in your case.
I'm trying to output information from my database to an Excel File using ASP.Net 5. In my controller I have two methods for this.
public void ExportData()
{
var data = new[]{
new{ Name="Ram", Email="ram#techbrij.com", Phone="111-222-3333" },
new{ Name="Shyam", Email="shyam#techbrij.com", Phone="159-222-1596" },
new{ Name="Mohan", Email="mohan#techbrij.com", Phone="456-222-4569" },
new{ Name="Sohan", Email="sohan#techbrij.com", Phone="789-456-3333" },
new{ Name="Karan", Email="karan#techbrij.com", Phone="111-222-1234" },
new{ Name="Brij", Email="brij#techbrij.com", Phone="111-222-3333" }
};
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=Contact.xls");
System.Web.HttpContext.Current.Response.AddHeader("Content-Type", "application/vnd.ms-excel");
WriteTsv(data, System.Web.HttpContext.Current.Response.Output);
System.Web.HttpContext.Current.Response.End();
}
public void WriteTsv<T>(IEnumerable<T> data, TextWriter output)
{
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T));
foreach (PropertyDescriptor prop in props)
{
output.Write(prop.DisplayName); // header
output.Write("\t");
}
output.WriteLine();
foreach (T item in data)
{
foreach (PropertyDescriptor prop in props)
{
output.Write(prop.Converter.ConvertToString(
prop.GetValue(item)));
output.Write("\t");
}
output.WriteLine();
}
}
I am forced to use System.Web because I have no idea how to export an excel file using ASP.Net 5, thus I'm currently using dnx451. I deleted dnxcore50 from my project.json in order to use System.Web.
However when calling the top method, I get the following error:
NullReferenceException: Object reference not set to an instance of an object.
on
System.Web.HttpContext.Current.Response.ClearContent();
The original example of this code used:
Response
Instead of:
System.Web.HttpContext.Current.Response
I cannot use just use Response because it uses Microsoft.AspNet.Http.HttpResponse instead of System.Web
Using System.Web.HttpResponse also doesn't work because it gives the following error:
An object reference is required for the non-static field, method, or property
This is my first web application and this problem has caused me to grind into a halt. Can anyone help me?
You can't use System.Web. One of the goals of ASP.Net Core was to remove the dependency on System.Web. Since ASP.Net Core is does not depend on System.Web the HttpContext et al. won't be initialized and hence NRE. You can use IHttpContextAccessor to get HttpContext in ASP.Net Core and access the Response from there.