When i am trying to start the Spring Boot application in the Eclipse IDE, observed the below error
Name for argument type [java.lang.String] not available, and parameter name information not found in class file either
Below is the error stack for reference:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Name for argument type [java.lang.String] not available, and parameter name information not found in class file either.
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at org.springframework.test.web.servlet.TestDispatcherServlet.service(TestDispatcherServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
Solution :
This is because compiler is not able to store method parameter names while generating the class files. you can enable this compiler option in eclipse IDE by following the below steps:
Go to – Project properties –> Java compiler -> enable / check “Project specific settings” -> enable/check “Store information about method parameters(usable via reflection)”
Here is the apex working code to create/delete the file attachments (Content document).
For storing the file attachments, below are the listed objects used.
ContentDocumentLink
ContentDocument
ContentDocumentVersion
Here is the sample code for reference
Step-1: Create a Contentversion record in the Salesforce final ContentVersion contentVersionRecord = new ContentVersion(Title=’filename’, PathOnClient =’filename.pdf’, VersionData = bodyBlob); insert contentVersionRecord;
Note: The above code will create a record in Salesforce as ContentDocument and ContentVersion.
Here the ContentDocument is the parent record and ContentVersion is the child record.
Step-2: using the below line of code, will get the content document id contentVersionRecord = [SELECT Id, Title, ContentDocumentId FROM ContentVersion WHERE Id = :contentVersionRecord .Id LIMIT 1];
Step-2: using the below line of code, will get the content document id contentVersionRecord = [SELECT Id, Title, ContentDocumentId FROM ContentVersion WHERE Id = :contentVersionRecord .Id LIMIT 1];
Step-3: Next step is to create a ContentDocumentLink record (junction record), which will associate the file to a particular record
Below are the steps to delete the attachment file from the Salesforce
The below code will delete the ContentDocumentLink delete [SELECT Id from ContentDocumentLink where contentDocument.Title = ‘sample.zip’ and LinkedEntityId = ’00GDR000008UulH2AS’];
The below code will delete the Contentversion delete [SELECT id from ContentVersion where Title = ‘sample.zip’];
The below code will delete the Content Document delete [SELECT Id from ContentDocument where Title = ‘sample.zip’];
Note – If we delete the content document then ContentDocumentVersion and ContentDocumentLink will be deleted automatically.