I've watched almost all tutorial series on your channel and I can say you are awesome at explaining, thanks a lot
@srit36527 жыл бұрын
Thanks Kaushik for yet another amazing tutorial. For the application to work correctly: 1. The Message class must have the default constructor along with the overloaded constructor. 2. It must have both getter and setter methods defined as JAXB internally uses the setter methods. If the setter methods are not used, you get empty Message elements on the page.
@saumitrabhardwaj29449 жыл бұрын
Excellent as always. Pray to have atleast one more video for this week.
@JaimePenagosGuitar7 жыл бұрын
Man, thanks! I had everything in place but i kept getting 500 Error without clue what the hell was happening. The tip at 5:25 was the key. Constructor without parameters!! Thank you very much.
@pushpendersharma6737 жыл бұрын
Why we are using empty constructor?
@moonshine47572 жыл бұрын
Did it work? I tried that, but still I'm getting internal error
@manisharora6199 жыл бұрын
Java Brains Thanks for the awesome tutorial kaushik.I am fond of your teaching. You are doing a great job.
@sameerkhnl16 жыл бұрын
If you are still getting the 500 error, you are likely using java 9 or higher. You need to add the following dependencies as these seem to be excluded from the new SDKs. javax.xml.bind jaxb-api 2.3.0 com.sun.xml.bind jaxb-core 2.3.0 com.sun.xml.bind jaxb-impl 2.3.0 javax.activation activation 1.1.1
@pucie_boi6 жыл бұрын
This worked! Also, make sure not to copy and paste this because you will get unrecognized characters. Type in manually.
@anunaiishan46935 жыл бұрын
Thanks a lot! I was running into trouble with the 500 errors but these dependencies fixed it.
@_ak_k5 жыл бұрын
This is really helpful! thank you so much!!!
@akshitkumar44853 жыл бұрын
worked! Thanks man
@themountains17012 жыл бұрын
first of all, i'm using java 8 and still faced this issue and even after adding these dependencies to my pom file, it's still showing the same error as it showed before using the @XmlRootElement annotation.
@ocherki4 жыл бұрын
So I tried all the different methods to solve the 500 error, including pom.xml dependencies from the comments and including @XmlAccessorType(XmlAccessType.FIELD) in Message class, tried to play with pom.xml settings, changed import packages for @XmlRootElement (jakarta, javax, com.sun...), checked the presence of an empty constructor, cleaned and rebuild the project. Nothing worked. The only thing worked for me is to change to APPLICATION_JSON, uncomment JSON support dependency in pom.xml and continue working with JSON format instead of XML.
@imparfait9944 жыл бұрын
Same to me, your solution worked! Thank you very much!
@thecodersbay81574 жыл бұрын
Thanks , for JSON RESPONSE it is working fine for me ... :)
@tarunverma45424 жыл бұрын
Thnx, working for me 2
@kristianshepherd61234 жыл бұрын
I've faced the same problem and after you wrote this post I recieved JSON, but I need XML. Have you solved the issue?
@thecodersbay81574 жыл бұрын
@@kristianshepherd6123 stackoverflow.com/questions/61630890/java-lang-nullpointerexception-at-jakarta-xml-bind-contextfinder-handleclasscast/61688539#61688539 This solved my problem..., hope it helps you
@kanavghai8873 жыл бұрын
i am using java 1.8, tomcat 10. despite adding jaxb-api 2.3.0, and adding the dependenices mentioned by Steven, I get error: SEVERE: MessageBodyWriter not found for media type=text/xml, type=class java.util.ArrayList, genericType=java.util.List. pls help!!
@Modern_revolution5 жыл бұрын
Thank you so much! Pls note that you need to restart the eclipse and restart the tomcat to get this work!
@vandanpatel33958 жыл бұрын
Note : If you run this inside Eclipse browser, it would just give you the plaintext. Please try running it on Chrome to get the XML format output. I learned it the hard way. I hope it helps.
@cruzcruz966 жыл бұрын
Thank you for that information! I was getting plaintext but running it ion Chrome worked.
@tatjanaandrjushina38605 жыл бұрын
Same here, thank you for the info
@nipunharjai22425 жыл бұрын
Oh god thank you so much! I've been trying to fix that 'problem' since a couple of hours now!
@Rhyzal_5 жыл бұрын
If you are seeing "XmlRootElement cannot be resolved to a type" -- For Java 9 and newer versions, javax.xml.bind was removed. To re-add it to your project, open the pom.xml and add the dependencies: javax.xml.bind jaxb-api 2.3.0 com.sun.xml.bind jaxb-core 2.3.0 com.sun.xml.bind jaxb-impl 2.3.0 javax.activation activation 1.1.1 *Note: This should NOT be nested inside the "" tag! (This was my mistake for an embarrassingly long time....)
@kakoiniksvoboden9 ай бұрын
Thank you!
@Punithavathy19 жыл бұрын
Awesome teacher you are. Thanks for uploading this video.
@ujjwalshrestha13179 жыл бұрын
Your tutorial is really amazing. Thanks for Sharing
@andrei-un3yr4 жыл бұрын
I am getting the error: MessageBodyWriter not found for media type=application/xml, type=class java.util.ArrayList, genericType=java.util.List. I've tried I think almost all the solutions from the comment section as well as some from stackoverflow, but still haven't been able to solve it :( EDIT: I've modified the default jersey version 3.0.0-M1 to 2.26 and now it seems to be working fine. In version 3.0.0, it uses jakarta(which I understand is the new name for JavaEE) whereas the 2.26 version uses java.ws.rs, like in the tutorial
@ReviewSutras4 жыл бұрын
I am getting the same error.
@jfkpami41945 жыл бұрын
Koushik, I am running JDK 13.0 and I am facing some issues with JAXB. Non of the dependencies that I have added to the pom.xml can solve my issue. Any help?
@r4riaz9 жыл бұрын
Thank you very much, Koushik. What else do you plan to explore next?
@nikunjgupta6075 жыл бұрын
Hi Kaushik ,Thank you for these amazing tutorials.Have you given answer of why no opt constructor is required . I have watched almost all videos of the rest .I did not found the answer. Could you please answer.Thanks
@lrm36426 жыл бұрын
MASTERPIECE !!! well done pal!!
@felipecabral94439 жыл бұрын
Brilliant again!! Congratulations!
@shinelil18 жыл бұрын
Thank you for your great tutorials!!
@photonpoint70869 жыл бұрын
Thanks in advance before the listening.
@jaganathgowda28068 жыл бұрын
Hello Koushik , first i would thank you for all your video Tutorials .... Which helped me a lot ... one more thing i had a doubt in Restfull PATCH method ... what is the difference between PUT & PATCH ... how to use it ....
@aleemfirnas13178 жыл бұрын
Great , commenting before starting. :)
@swapnasankar71303 жыл бұрын
No matter what i do, i continue to get this error message when i try this with XML response type. SEVERE: MessageBodyWriter not found for media type=application/xml, type=class java.util.ArrayList, genericType=java.util.List. The TEXT.PLAIN works well but the XML type does not work. I add this as the produces annotation in the code @Produces(MediaType.TEXT_XML) when i add the annotation for XmlRootElement to the Message class, it was unable to resolve, so i had to add the Maven dependency to my pom.xml , to get the javax.xml.bind.annotation.XmlRootElement javax.xml.bind jaxb-api 2.3.1 Can anyone help me move further?
@mohammedal-kahtani38647 жыл бұрын
you are great , many thanks for this video .
@amitrajawat_crish_07int9 жыл бұрын
In the message model, if I declare messages attributes as public instead of private(as depicted in video) I am getting error 500(Server Internal error) . On the contrary it should not cause any problem.@Kaushik: can anyone please edify me on this.
@srinivasmaheedhar41189 жыл бұрын
+amit rajawat Thats a good catch, many would have got this error...changing member variables to private does the job and solve Internal error 500 problem
@rockersdhaya8 жыл бұрын
+amit rajawat that solved the issue, thank u. But anyways if its public it shouldnt be a problem right? then why are we getting 500 error?
@kumarpushpam19958 жыл бұрын
@amit rawat thank bro
@arunodasamarasinghe94646 жыл бұрын
This worked for me. Thanks
@caliberservices36336 жыл бұрын
good catch
@JamesJ30t8 жыл бұрын
Interesting in the SOAP tutorial the JAXB worked automatically we only needed to use the JAXB annotations if we wanted to change the default element names. In REST we have to explicitly activate JAXB by annotating class in the return list.
@mechadroit8 жыл бұрын
I think I'm following. So if i were to use JDBC and I wanted to perform actions to say read a message. I would establish the connection and what not within my messageService.java class correct? I'm used to just dealing with regular java servlets not using RESTful so I'm a bit of a noob.
@ciaranwhyte40888 жыл бұрын
Yup, so instead of hard coding those two message instances you would most likely have some database connection instead. To handle that you could create another class to handle the database connection and tasks it needs to perform. Then create an instance of that database class and call its methods inside the getAllMessages() method. ...Something like that
@mechadroit8 жыл бұрын
Awesome. Thanks.
@samritijamwal4924 жыл бұрын
I am still getting HTTP Status 500 and no error message in console as well. I used @XmlAccessorType(XmlAccessType.FIELD) under @XmlRootElement. What to do more?
@thecodersbay81574 жыл бұрын
Try with the JSON response and uncomment the json part from pom.xml as well
@thecodersbay81574 жыл бұрын
For XML response , change the version of jersey to 2.3.1 in pom.xml as shown below: org.glassfish.jersey jersey-bom $2.3.1 pom import and change the import from jakarta to javax
@akankshajain27868 жыл бұрын
Ok, I am getting the results, But in the XML format returned, why is the data read in the sequence: Author, Created, Id, message. This format is not specified anywhere.
@abhishiekmahajan91034 жыл бұрын
Lovely Explanation
@miteshmanani9 жыл бұрын
A small Query here, how did you get the (plural) tag for the list of Messages ? that is no where specified as the part of XML schema definition or by any annotation or attribute of annotation. I can understand the tag (Singular) since it is the class name hence the JaxB API should be picking it up from the class name or the setter method.
@ChristianAltamiranoAyala8 жыл бұрын
+Java Brains thanks for the tutorials, I have a questions, Why it does not work when I do not add the empty constructor?.
@surabhigupta98148 жыл бұрын
Its written in the jersey documentation part that JAXB needs it. Refer this link: jersey.java.net/documentation/1.19.1/json.html#json.jaxb.approach.section
@pkkoniec9 жыл бұрын
In Chrome it works fine, but what's wrong with Safari? it only shows plain text.. any ideas? (intelliJ)
@Java.Brains9 жыл бұрын
Pkkoniec My guess is Safari doesn't honor the Content-Type header, and always assumes the content is HTML. So when it gets JSON or XML, it gets confused. That's why I chose Chrome to show the response in the tutorials. Pretty sure Firefox should work well too.
@PMPhotographyVideography9 жыл бұрын
+Java Brains So it cant render websites who deal with JSON data? Website creators have to deal with that?
@ramkethireddy94456 жыл бұрын
same for me,works in chrome but not in eclipse internal browser
@abhinavanand7364 жыл бұрын
Hey, I liked your video, but i want to prepare a web service that would be returning a response in xml as shown but along with soap tags so that it could be consumed over another application. Can you please suggest me how to do that?
@meriemkaroun76268 жыл бұрын
Answer : If you have 404 error : you should modify the web.xml. Add your package instead of the default one. org.webservice.messenger.ressources instead of org.webservice.messenger.messenger
@yiminggong65638 жыл бұрын
I did the same thing , but I still get this annoying 404 error.
@yiminggong65638 жыл бұрын
Finally, I fixed it. I just restart the eclipse and the Tomcat. Thank you a lot meriem :)
@haripramod299 жыл бұрын
It is showing the same internal 500 error even after xmlrootelement annotation. and in the console it is not even showing anything
@chiragshah57447 жыл бұрын
you must have to create default constructor than only it will creates an instance
@SanjuChougule6 жыл бұрын
@@chiragshah5744 Thanks...
@pushkarchauhan77766 жыл бұрын
Make sure your member variables are declared as private and not public
@catherinesharon5104 жыл бұрын
If you are getting the 500 error, I couldn't fix it with an XML Response, however the JSON response worked for me. I added the following dependencies to my POM file javax.xml.bind jaxb-api 2.3.1 org.glassfish.jaxb jaxb-runtime 3.0.0-M3 org.glassfish.jersey.media jersey-media-moxy I hope this helps someone out there. I am using Java v.13 with Jersey version 2.16
@SahilKaironVlogs3 жыл бұрын
hey. thank you so much. However I am not able to understand even after adding xml dependencies in pom.xml and adding xmlrootElement annotation, why we are not able to get the output in xml format. If you know the reason, please reply.
@ayanmukherjee31023 жыл бұрын
@@SahilKaironVlogs I am having the same problem, JSON works fine
@bhupendra_s2 жыл бұрын
I had to add or rather uncomment the following dependency for JSON. I'm still getting facing issue with xml. Getting same Internal error as others i.e. Internal Error 500 when I change media type to application_xml. org.glassfish.jersey.media jersey-media-json-binding I'm using eclipse Version: 2022-06 (4.24.0), java 1.8, apache 10.0, jersey version 3.1.0
@tejaaravind52718 жыл бұрын
really ur classes are awesome.Thank u so much...I am having small doubt what is the annotion to convert into json format
@raamch10 ай бұрын
Great tutorial
@vajahatalee9 жыл бұрын
Really nice work!
@guideg4250 Жыл бұрын
If you still getting an error for the annotation of @XmlRootElement, please add this dependencies in the POM.Xml. javax.xml.bind jaxb-api 2.3.1 org.glassfish.jaxb jaxb-runtime 3.0.0-M3 org.glassfish.jersey.media jersey-media-moxy
@yogeshdixit28236 жыл бұрын
There is a thing missing in your code @XMLElement
@gov9149 жыл бұрын
Brilliant! Thank you.
@lifeoutdare9 жыл бұрын
i have a problem. why i can not return anything except plain string in api. for ex it does not show any list .
@ЮлияДемидович-п5и7 жыл бұрын
How does JAXB define the order of class fields to build an XML? Id, Date, Author and Message itself.
@chiragchandnani96635 жыл бұрын
it's alphabetical
@jbkerns7 жыл бұрын
I had an terrible time running this under JDK 9 with both Tomcat 8 and 9. JDK 9 removes javax support believing it is part of EE. Reverting to JDK8u152 and Tomcat 8.5 fixed the problem.
@bijayy337 жыл бұрын
Thanks man, this worked for me. Do u have any idea why this happens with latest version?
@gauravdighe41179 жыл бұрын
Java Brains Can you tell me which will be ideal for connecting to database for Jersey - Hibernate or JPA. Please let me know?
@TheCoolakashrockin9 жыл бұрын
+Gaurav Dighe Personally I would suggest you to go with Hibernate to incorporate all the Dynamics of the project running smoothly.
@ruaaanabi38879 жыл бұрын
if I want to convert the response to json instead of xml , what code changes I need to make apart from Media_Type? please can u write the codes
@naveenk38633 жыл бұрын
MediaType.APPLICATION_JSON
@ayanmukherjee31023 жыл бұрын
Nothing else just make sure you have added jersey-media-json-binding
@tapuchandan0077 жыл бұрын
Default constructor and getter/setters are must for the application to work as expected. Wasted an hour to get to that.
@nehaagrawal54579 жыл бұрын
if I want to convert the response to json instead of xml , what code changes I need to make apart from Media_Type?
@TheCoolakashrockin9 жыл бұрын
+Neha Agrawal All you need to do is after the annotation as shown below is my comment: @Produces(MediaType.Application_JSON) public String Class example{ /* *piece of code */ //If you have Json object already Change return Type to Json and return JSON Object: return Json_Object //If you have a String/Collection Object parse it using GSON first to convert it into JSON first and the return it as shown below: //Also this would require you to import the gson jar into your project. return gson.toJson(String/Map) } Cheers Happy Coding!!
@ruaaanabi38879 жыл бұрын
+Akash Dighe please can u write all of the code cus am not understand
@errrzarrr8 жыл бұрын
That JAXB is great :)
@hurolinci59869 жыл бұрын
Your videos are great, but I can´t look up the source code on your website.
@naveentyagi999 жыл бұрын
+Hürol Inci Then create with him step by step :)
@amenijenhani96088 жыл бұрын
+Hürol Inci github.com/koushikkothagal/messenger
@aceofspadesInd9 жыл бұрын
How can i return a single message as a resource from list of messages in this case? Like /messages/1 Regards.
@lalithamadhuri21308 жыл бұрын
can't we create message class in the same package as messageresource??
@accessashutosh9 жыл бұрын
Very nice video!!!
@Codestry4 жыл бұрын
unable to fix the 500-Internal Server Error. Need help on screen sharing basis
@rockersdhaya8 жыл бұрын
Hi, First of all i want to thank you and the team for making this tutorial, it is very helpful. i have a doubt: I received a 500-Internal Server Error even after I did this in my implementation (tried to implement this myself after a brief watch of first video), and the logs didn't give me a stacktrace (every debug-session also showed the MessageList was created and returned successfully.). I have a default constructer too in the POJO class.
@rockersdhaya8 жыл бұрын
+amit rajawat comment solved the issue, but why is the access specificier change giving 500 error anyways public should work fine riht? please clarify
@madhulikaghosh38766 жыл бұрын
I am enjoying rest
@benjaminao20087 жыл бұрын
Thank you very much, Koushik. but I can explain how to answer a JSON
@ahmettachmuradov86303 жыл бұрын
Let me first like it and then watch
@moonshine47572 жыл бұрын
Can anyone please help me? When I try simple string message, I'm getting output. but when I create list, or use xml, there's 500 internal error.
@kunal-ashar7 жыл бұрын
Followed all the steps properly and still received 500 error. It was a configuration related issue. I had started tomcat 9.0 server with Java 1.9. Post downgrading tomact to 8.0 and Java 1.8, i was able to fetch proper XML response.
@yiminggong65638 жыл бұрын
For those of you who get these annoying 404 error, please have a look at meriem karoun's comment first. If the error's not gone, you could do two things, 1. delete the MessageResource.java class and write it again, 2 . shut down your eclipse and re-run it. Hope this will help.
@satya55667 жыл бұрын
well explained . i got 404 error , so waited till INFO: Reloading Context with name [/messenger] is completed in console( wait for server to complete the job ) . Than successfully web page displayed - hello world .
@shaileshsingh23536 жыл бұрын
hi Koushik Sir Merry Christmas.. I want to upload file and dto at a single time by jax-rs jersey 1.11 how could i achieve it
@rsanath7 жыл бұрын
Im getting the result as a single string. Its not in the xml format
@aniwar26987 жыл бұрын
Meow Meow try using Google chrome . In default eclipse browser , it will show plain text .
@avneeshkumar-fj9rw6 жыл бұрын
I am using java version 9 and i am getting the error " java.lang.NoClassDefFoundError: javax/activation/DataSource"
@shibadhamija43056 жыл бұрын
hey can anyone tell what abut the sequencing of xml output , how author name came 1st and all ...kindly tell
@PiyushSingh-em5vz4 жыл бұрын
Im getting error why i cant understant not any stacktrace in console
@alexop59193 жыл бұрын
For those, who get 500-Internal Server Error. One of the solutions is to change to MediaType.APPLICATION_JSON and enabled JSON mapping in POM.xml
@swapnasankar71303 жыл бұрын
Can you post the details on what the change is needed in pom.xml?
@ValentinaMoraru3 жыл бұрын
@@swapnasankar7130 add the last json dependency from the mvnrepository in pom.xml
@karthikbattula80566 жыл бұрын
i am not able to import "import javax.xml.bind.annotation.XmlRootElement", bcoz im not getting that package, have any idea?
@SarthakJainSRJ6 жыл бұрын
Look 2 comments below. You should get your answer. I was facing the same issue as yours.
@santoshsahu28399 жыл бұрын
Shared on Google+
@MinhPham-uw1eb8 жыл бұрын
I have 404 error and 500 errors like everyone says here. In addition, sometime I receive 500 error saying something is wrong with my servlet.init. To this day, I still don't know what was going on. But after 2 days, countless restart of the laptop, Netbean, Tomcat server.... I just come back normally and I can move on the next tutorial . I did change the following: the Message class (the model class) must have an empty constructor. Its fields should have private variagle
@bighneshsabat53748 жыл бұрын
I hava used @XmlRootElement in profile model class and @praduce(MediaType.APPLICATION_XML) in profileService class.Still I'm getting this error. SEVERE: MessageBodyWriter not found for media type=application/xml, type=class java.util.ArrayList, genericType=java.util.List.Could you please any one help me?
@aniwar26987 жыл бұрын
bighnesh sabat add empty constructor in Message class
@krishnaveniramasamy69127 жыл бұрын
in your note you have @praduce instead of @Produces can you please verify
@anareddy4 жыл бұрын
for me it worked with java 1.8 earlier i was using java 11
@sultanqureshi27663 жыл бұрын
doing this project in 2021 facing issues with JAVAX as JAKARTA is used in JAVA EE
@jonassx1006 жыл бұрын
how to make list printed as output instead of turning it to XML
@sidimohamedelhajsidi72789 жыл бұрын
I was receiving 500 Internal Server Error because, by mistake, I made the attribute of Message class to be public instead of private. Does anyone know the reason behind this?
@maganrakhra32094 жыл бұрын
While returning as xml i am getting 500 error but while returning as string it is working fine. I have also included @XmlRootElement annotations at the beginning of Message class. Can anyone suggest what i might be doing wrong.
@dimitrievskidarko9 жыл бұрын
Awesome!
@renujoshi2436 жыл бұрын
how to resolve this error: XmlRootElement cannot be resolved to a type?? java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext????????
can someome please help me resolve this, when i put in this annotation, @XmlRootElement my eclipse is not importing it automatically. i did some google search and found out that I need a plugin available here github.com/highsource/jaxb2-annotate-plugin but i dont know how to use it. can someone please redirect me
@vijayamarella8 жыл бұрын
I still 500 internal server error, even after having empty constructor, followed all the instructions..what else could go wrong?
@aniwar26987 жыл бұрын
Vijaya Marella Did you add XmlRootElement annotation.
@dheereshcool86986 жыл бұрын
@@aniwar2698 I have added the annotation as well as made the variables private as well as made default const...still 500 code
@PrinceYadav-ll8hs7 жыл бұрын
without default constructor it gives error 500 ????
@bijayy337 жыл бұрын
It's not working for me. I have done exactly the same.
@MrRAYEN19206 жыл бұрын
can you please show us how to create restful web service from oracle database with jersey and thanks
@shashibhushansharma72936 жыл бұрын
Can somebody help, i am getting this HTTP Status 500 - Internal Server Error Type Status Report Message Internal Server Error Description The server encountered an unexpected condition that prevented it from fulfilling the request. Apache Tomcat/9.0.14
@rickhunter82167 жыл бұрын
I ONLY CAN USE JERSEY WITH MAVEN?
@purushothamgamini97686 жыл бұрын
it thrown 500 error when I declared variables in Message.java as public. Once I changed to private, issue resolved. Can anyone explain why?
@sarvilauditore4 жыл бұрын
If anyone is getting 505 error even after trying everything, it maybe just version incompatibility between many things. one solution is you can give MediaType.APPLICATION_JSON instead of XML and you can try in postman client its working perfectly. i could see output in only json format that too in Postman only.
@nageshsoni73298 жыл бұрын
I did same as u told in this tutorial but still its giving HTTP status 500 - Internal Server error for me. Can anybody help me out?
@aniwar26987 жыл бұрын
Nagesh Soni add empty constructor to message class
@milantrehan1784 жыл бұрын
Anyone getting internal server 500 with nullPointerException while running this? SEVERE: Servlet.service() for servlet [Jersey Web Application] in context with path [/messenger.service] threw exception [java.lang.NullPointerException] with root cause java.lang.NullPointerException at jakarta.xml.bind.ContextFinder.handleClassCastException(ContextFinder.java:114) at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:254) at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:240)
@milantrehan1784 жыл бұрын
For anyone struggling with this: stackoverflow.com/questions/61630890/servlet-service-for-servlet-jersey-web-application-in-context-with-path-me/61688539#61688539
@thecodersbay81574 жыл бұрын
@@milantrehan178 Thanks Man , now xml response is also working.
@hamkb97417 жыл бұрын
perfect!
@WithAdvik9 жыл бұрын
SEVERE: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List. generate this error when use MediaType.APPLICATION_JSON instead of MediaType.APPLICATION_XML. Is there any solution like @XmlRootElement
@jyotirmayadehury84679 жыл бұрын
Abhijit Chowdhury I just saw this issue. And found the solution as mentioned below. In MessageService.java modify like this and change ur Resource class method return type to Response. public Response getAllMessages(){ List list = new ArrayList(); list.add(new Message(1L, "XXXXX", "Hello World!!!")); list.add(new Message(2L, "YYYY", "Greetings World!!!")); GenericEntity entity = new GenericEntity(list) {}; Response response = Response.ok(entity).build(); return response; }
@TheCoolakashrockin9 жыл бұрын
+Abhijit Chowdhury Also you can add a new annotation to your class and method: @Context This would help Jersey Understand the particular class to look for when executing your code
@tulsi63178 жыл бұрын
thanks bestie
@chowdeswariappasani97158 жыл бұрын
How to form URL to work out in browser?
@chowdeswariappasani97158 жыл бұрын
yeah got it!
@aniwar26987 жыл бұрын
Most of us are forgetting to add empty Message constructor . That's why #500 .
@AkashGanga25125 жыл бұрын
error 500 internal server error did everything. even added updated dependencies. using java 13 , tomcat 9.0.30
@ocherki4 жыл бұрын
The same
@pichulio4 жыл бұрын
create the constructor empty of message
@DARKOOMER9 жыл бұрын
iam getting 500 error and I wrote @xmlrootelemnt at message class, pls help
@DARKOOMER9 жыл бұрын
darko I fixed the problem, needed an empty constructor
@AbhishekPandey-yi6pf9 жыл бұрын
+darko Can u please tell me why this empty constructor is required ? my email id is abhishekit3002@gmail.com
@aparnarodrigues48579 жыл бұрын
+darko Why do we need an empty constructor. It fixed my problem , however I did not get why?