REST Web Services 14 - Returning XML Response

  Рет қаралды 354,360

Java Brains

Java Brains

Күн бұрын

Пікірлер: 259
@RayFIghtZzMe
@RayFIghtZzMe 9 жыл бұрын
I've watched almost all tutorial series on your channel and I can say you are awesome at explaining, thanks a lot
@srit3652
@srit3652 7 жыл бұрын
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.
@saumitrabhardwaj2944
@saumitrabhardwaj2944 9 жыл бұрын
Excellent as always. Pray to have atleast one more video for this week.
@JaimePenagosGuitar
@JaimePenagosGuitar 7 жыл бұрын
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.
@pushpendersharma673
@pushpendersharma673 7 жыл бұрын
Why we are using empty constructor?
@moonshine4757
@moonshine4757 2 жыл бұрын
Did it work? I tried that, but still I'm getting internal error
@manisharora619
@manisharora619 9 жыл бұрын
Java Brains Thanks for the awesome tutorial kaushik.I am fond of your teaching. You are doing a great job.
@sameerkhnl1
@sameerkhnl1 6 жыл бұрын
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_boi
@pucie_boi 6 жыл бұрын
This worked! Also, make sure not to copy and paste this because you will get unrecognized characters. Type in manually.
@anunaiishan4693
@anunaiishan4693 5 жыл бұрын
Thanks a lot! I was running into trouble with the 500 errors but these dependencies fixed it.
@_ak_k
@_ak_k 5 жыл бұрын
This is really helpful! thank you so much!!!
@akshitkumar4485
@akshitkumar4485 3 жыл бұрын
worked! Thanks man
@themountains1701
@themountains1701 2 жыл бұрын
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.
@ocherki
@ocherki 4 жыл бұрын
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.
@imparfait994
@imparfait994 4 жыл бұрын
Same to me, your solution worked! Thank you very much!
@thecodersbay8157
@thecodersbay8157 4 жыл бұрын
Thanks , for JSON RESPONSE it is working fine for me ... :)
@tarunverma4542
@tarunverma4542 4 жыл бұрын
Thnx, working for me 2
@kristianshepherd6123
@kristianshepherd6123 4 жыл бұрын
I've faced the same problem and after you wrote this post I recieved JSON, but I need XML. Have you solved the issue?
@thecodersbay8157
@thecodersbay8157 4 жыл бұрын
@@kristianshepherd6123 stackoverflow.com/questions/61630890/java-lang-nullpointerexception-at-jakarta-xml-bind-contextfinder-handleclasscast/61688539#61688539 This solved my problem..., hope it helps you
@kanavghai887
@kanavghai887 3 жыл бұрын
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_revolution
@Modern_revolution 5 жыл бұрын
Thank you so much! Pls note that you need to restart the eclipse and restart the tomcat to get this work!
@vandanpatel3395
@vandanpatel3395 8 жыл бұрын
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.
@cruzcruz96
@cruzcruz96 6 жыл бұрын
Thank you for that information! I was getting plaintext but running it ion Chrome worked.
@tatjanaandrjushina3860
@tatjanaandrjushina3860 5 жыл бұрын
Same here, thank you for the info
@nipunharjai2242
@nipunharjai2242 5 жыл бұрын
Oh god thank you so much! I've been trying to fix that 'problem' since a couple of hours now!
@Rhyzal_
@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....)
@kakoiniksvoboden
@kakoiniksvoboden 9 ай бұрын
Thank you!
@Punithavathy1
@Punithavathy1 9 жыл бұрын
Awesome teacher you are. Thanks for uploading this video.
@ujjwalshrestha1317
@ujjwalshrestha1317 9 жыл бұрын
Your tutorial is really amazing. Thanks for Sharing
@andrei-un3yr
@andrei-un3yr 4 жыл бұрын
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
@ReviewSutras
@ReviewSutras 4 жыл бұрын
I am getting the same error.
@jfkpami4194
@jfkpami4194 5 жыл бұрын
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?
@r4riaz
@r4riaz 9 жыл бұрын
Thank you very much, Koushik. What else do you plan to explore next?
@nikunjgupta607
@nikunjgupta607 5 жыл бұрын
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
@lrm3642
@lrm3642 6 жыл бұрын
MASTERPIECE !!! well done pal!!
@felipecabral9443
@felipecabral9443 9 жыл бұрын
Brilliant again!! Congratulations!
@shinelil1
@shinelil1 8 жыл бұрын
Thank you for your great tutorials!!
@photonpoint7086
@photonpoint7086 9 жыл бұрын
Thanks in advance before the listening.
@jaganathgowda2806
@jaganathgowda2806 8 жыл бұрын
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 ....
@aleemfirnas1317
@aleemfirnas1317 8 жыл бұрын
Great , commenting before starting. :)
@swapnasankar7130
@swapnasankar7130 3 жыл бұрын
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-kahtani3864
@mohammedal-kahtani3864 7 жыл бұрын
you are great , many thanks for this video .
@amitrajawat_crish_07int
@amitrajawat_crish_07int 9 жыл бұрын
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.
@srinivasmaheedhar4118
@srinivasmaheedhar4118 9 жыл бұрын
+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
@rockersdhaya
@rockersdhaya 8 жыл бұрын
+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?
@kumarpushpam1995
@kumarpushpam1995 8 жыл бұрын
@amit rawat thank bro
@arunodasamarasinghe9464
@arunodasamarasinghe9464 6 жыл бұрын
This worked for me. Thanks
@caliberservices3633
@caliberservices3633 6 жыл бұрын
good catch
@JamesJ30t
@JamesJ30t 8 жыл бұрын
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.
@mechadroit
@mechadroit 8 жыл бұрын
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.
@ciaranwhyte4088
@ciaranwhyte4088 8 жыл бұрын
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
@mechadroit
@mechadroit 8 жыл бұрын
Awesome. Thanks.
@samritijamwal492
@samritijamwal492 4 жыл бұрын
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?
@thecodersbay8157
@thecodersbay8157 4 жыл бұрын
Try with the JSON response and uncomment the json part from pom.xml as well
@thecodersbay8157
@thecodersbay8157 4 жыл бұрын
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
@akankshajain2786
@akankshajain2786 8 жыл бұрын
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.
@abhishiekmahajan9103
@abhishiekmahajan9103 4 жыл бұрын
Lovely Explanation
@miteshmanani
@miteshmanani 9 жыл бұрын
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.
@ChristianAltamiranoAyala
@ChristianAltamiranoAyala 8 жыл бұрын
+Java Brains thanks for the tutorials, I have a questions, Why it does not work when I do not add the empty constructor?.
@surabhigupta9814
@surabhigupta9814 8 жыл бұрын
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
@pkkoniec
@pkkoniec 9 жыл бұрын
In Chrome it works fine, but what's wrong with Safari? it only shows plain text.. any ideas? (intelliJ)
@Java.Brains
@Java.Brains 9 жыл бұрын
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.
@PMPhotographyVideography
@PMPhotographyVideography 9 жыл бұрын
+Java Brains So it cant render websites who deal with JSON data? Website creators have to deal with that?
@ramkethireddy9445
@ramkethireddy9445 6 жыл бұрын
same for me,works in chrome but not in eclipse internal browser
@abhinavanand736
@abhinavanand736 4 жыл бұрын
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?
@meriemkaroun7626
@meriemkaroun7626 8 жыл бұрын
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
@yiminggong6563
@yiminggong6563 8 жыл бұрын
I did the same thing , but I still get this annoying 404 error.
@yiminggong6563
@yiminggong6563 8 жыл бұрын
Finally, I fixed it. I just restart the eclipse and the Tomcat. Thank you a lot meriem :)
@haripramod29
@haripramod29 9 жыл бұрын
It is showing the same internal 500 error even after xmlrootelement annotation. and in the console it is not even showing anything
@chiragshah5744
@chiragshah5744 7 жыл бұрын
you must have to create default constructor than only it will creates an instance
@SanjuChougule
@SanjuChougule 6 жыл бұрын
@@chiragshah5744 Thanks...
@pushkarchauhan7776
@pushkarchauhan7776 6 жыл бұрын
Make sure your member variables are declared as private and not public
@catherinesharon510
@catherinesharon510 4 жыл бұрын
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
@SahilKaironVlogs
@SahilKaironVlogs 3 жыл бұрын
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.
@ayanmukherjee3102
@ayanmukherjee3102 3 жыл бұрын
@@SahilKaironVlogs I am having the same problem, JSON works fine
@bhupendra_s
@bhupendra_s 2 жыл бұрын
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
@tejaaravind5271
@tejaaravind5271 8 жыл бұрын
really ur classes are awesome.Thank u so much...I am having small doubt what is the annotion to convert into json format
@raamch
@raamch 10 ай бұрын
Great tutorial
@vajahatalee
@vajahatalee 9 жыл бұрын
Really nice work!
@guideg4250
@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
@yogeshdixit2823
@yogeshdixit2823 6 жыл бұрын
There is a thing missing in your code @XMLElement
@gov914
@gov914 9 жыл бұрын
Brilliant! Thank you.
@lifeoutdare
@lifeoutdare 9 жыл бұрын
i have a problem. why i can not return anything except plain string in api. for ex it does not show any list .
@ЮлияДемидович-п5и
@ЮлияДемидович-п5и 7 жыл бұрын
How does JAXB define the order of class fields to build an XML? Id, Date, Author and Message itself.
@chiragchandnani9663
@chiragchandnani9663 5 жыл бұрын
it's alphabetical
@jbkerns
@jbkerns 7 жыл бұрын
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.
@bijayy33
@bijayy33 7 жыл бұрын
Thanks man, this worked for me. Do u have any idea why this happens with latest version?
@gauravdighe4117
@gauravdighe4117 9 жыл бұрын
Java Brains Can you tell me which will be ideal for connecting to database for Jersey - Hibernate or JPA. Please let me know?
@TheCoolakashrockin
@TheCoolakashrockin 9 жыл бұрын
+Gaurav Dighe Personally I would suggest you to go with Hibernate to incorporate all the Dynamics of the project running smoothly.
@ruaaanabi3887
@ruaaanabi3887 9 жыл бұрын
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
@naveenk3863
@naveenk3863 3 жыл бұрын
MediaType.APPLICATION_JSON
@ayanmukherjee3102
@ayanmukherjee3102 3 жыл бұрын
Nothing else just make sure you have added jersey-media-json-binding
@tapuchandan007
@tapuchandan007 7 жыл бұрын
Default constructor and getter/setters are must for the application to work as expected. Wasted an hour to get to that.
@nehaagrawal5457
@nehaagrawal5457 9 жыл бұрын
if I want to convert the response to json instead of xml , what code changes I need to make apart from Media_Type?
@TheCoolakashrockin
@TheCoolakashrockin 9 жыл бұрын
+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!!
@ruaaanabi3887
@ruaaanabi3887 9 жыл бұрын
+Akash Dighe please can u write all of the code cus am not understand
@errrzarrr
@errrzarrr 8 жыл бұрын
That JAXB is great :)
@hurolinci5986
@hurolinci5986 9 жыл бұрын
Your videos are great, but I can´t look up the source code on your website.
@naveentyagi99
@naveentyagi99 9 жыл бұрын
+Hürol Inci Then create with him step by step :)
@amenijenhani9608
@amenijenhani9608 8 жыл бұрын
+Hürol Inci github.com/koushikkothagal/messenger
@aceofspadesInd
@aceofspadesInd 9 жыл бұрын
How can i return a single message as a resource from list of messages in this case? Like /messages/1 Regards.
@lalithamadhuri2130
@lalithamadhuri2130 8 жыл бұрын
can't we create message class in the same package as messageresource??
@accessashutosh
@accessashutosh 9 жыл бұрын
Very nice video!!!
@Codestry
@Codestry 4 жыл бұрын
unable to fix the 500-Internal Server Error. Need help on screen sharing basis
@rockersdhaya
@rockersdhaya 8 жыл бұрын
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.
@rockersdhaya
@rockersdhaya 8 жыл бұрын
+amit rajawat comment solved the issue, but why is the access specificier change giving 500 error anyways public should work fine riht? please clarify
@madhulikaghosh3876
@madhulikaghosh3876 6 жыл бұрын
I am enjoying rest
@benjaminao2008
@benjaminao2008 7 жыл бұрын
Thank you very much, Koushik. but I can explain how to answer a JSON
@ahmettachmuradov8630
@ahmettachmuradov8630 3 жыл бұрын
Let me first like it and then watch
@moonshine4757
@moonshine4757 2 жыл бұрын
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-ashar
@kunal-ashar 7 жыл бұрын
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.
@yiminggong6563
@yiminggong6563 8 жыл бұрын
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.
@satya5566
@satya5566 7 жыл бұрын
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 .
@shaileshsingh2353
@shaileshsingh2353 6 жыл бұрын
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
@rsanath
@rsanath 7 жыл бұрын
Im getting the result as a single string. Its not in the xml format
@aniwar2698
@aniwar2698 7 жыл бұрын
Meow Meow try using Google chrome . In default eclipse browser , it will show plain text .
@avneeshkumar-fj9rw
@avneeshkumar-fj9rw 6 жыл бұрын
I am using java version 9 and i am getting the error " java.lang.NoClassDefFoundError: javax/activation/DataSource"
@shibadhamija4305
@shibadhamija4305 6 жыл бұрын
hey can anyone tell what abut the sequencing of xml output , how author name came 1st and all ...kindly tell
@PiyushSingh-em5vz
@PiyushSingh-em5vz 4 жыл бұрын
Im getting error why i cant understant not any stacktrace in console
@alexop5919
@alexop5919 3 жыл бұрын
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
@swapnasankar7130
@swapnasankar7130 3 жыл бұрын
Can you post the details on what the change is needed in pom.xml?
@ValentinaMoraru
@ValentinaMoraru 3 жыл бұрын
@@swapnasankar7130 add the last json dependency from the mvnrepository in pom.xml
@karthikbattula8056
@karthikbattula8056 6 жыл бұрын
i am not able to import "import javax.xml.bind.annotation.XmlRootElement", bcoz im not getting that package, have any idea?
@SarthakJainSRJ
@SarthakJainSRJ 6 жыл бұрын
Look 2 comments below. You should get your answer. I was facing the same issue as yours.
@santoshsahu2839
@santoshsahu2839 9 жыл бұрын
Shared on Google+
@MinhPham-uw1eb
@MinhPham-uw1eb 8 жыл бұрын
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
@bighneshsabat5374
@bighneshsabat5374 8 жыл бұрын
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?
@aniwar2698
@aniwar2698 7 жыл бұрын
bighnesh sabat add empty constructor in Message class
@krishnaveniramasamy6912
@krishnaveniramasamy6912 7 жыл бұрын
in your note you have @praduce instead of @Produces can you please verify
@anareddy
@anareddy 4 жыл бұрын
for me it worked with java 1.8 earlier i was using java 11
@sultanqureshi2766
@sultanqureshi2766 3 жыл бұрын
doing this project in 2021 facing issues with JAVAX as JAKARTA is used in JAVA EE
@jonassx100
@jonassx100 6 жыл бұрын
how to make list printed as output instead of turning it to XML
@sidimohamedelhajsidi7278
@sidimohamedelhajsidi7278 9 жыл бұрын
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?
@maganrakhra3209
@maganrakhra3209 4 жыл бұрын
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.
@dimitrievskidarko
@dimitrievskidarko 9 жыл бұрын
Awesome!
@renujoshi243
@renujoshi243 6 жыл бұрын
how to resolve this error: XmlRootElement cannot be resolved to a type?? java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext????????
@priyankapaul2844
@priyankapaul2844 6 жыл бұрын
add these dependency- javax.activation activation 1.1.1 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
@satyaprakashroul1496
@satyaprakashroul1496 6 жыл бұрын
@@priyankapaul2844 Thanks Priyanka, It worked
@vamshikrishna8143
@vamshikrishna8143 6 жыл бұрын
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
@vijayamarella
@vijayamarella 8 жыл бұрын
I still 500 internal server error, even after having empty constructor, followed all the instructions..what else could go wrong?
@aniwar2698
@aniwar2698 7 жыл бұрын
Vijaya Marella Did you add XmlRootElement annotation.
@dheereshcool8698
@dheereshcool8698 6 жыл бұрын
@@aniwar2698 I have added the annotation as well as made the variables private as well as made default const...still 500 code
@PrinceYadav-ll8hs
@PrinceYadav-ll8hs 7 жыл бұрын
without default constructor it gives error 500 ????
@bijayy33
@bijayy33 7 жыл бұрын
It's not working for me. I have done exactly the same.
@MrRAYEN1920
@MrRAYEN1920 6 жыл бұрын
can you please show us how to create restful web service from oracle database with jersey and thanks
@shashibhushansharma7293
@shashibhushansharma7293 6 жыл бұрын
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
@rickhunter8216
@rickhunter8216 7 жыл бұрын
I ONLY CAN USE JERSEY WITH MAVEN?
@purushothamgamini9768
@purushothamgamini9768 6 жыл бұрын
it thrown 500 error when I declared variables in Message.java as public. Once I changed to private, issue resolved. Can anyone explain why?
@sarvilauditore
@sarvilauditore 4 жыл бұрын
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.
@nageshsoni7329
@nageshsoni7329 8 жыл бұрын
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?
@aniwar2698
@aniwar2698 7 жыл бұрын
Nagesh Soni add empty constructor to message class
@milantrehan178
@milantrehan178 4 жыл бұрын
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)
@milantrehan178
@milantrehan178 4 жыл бұрын
For anyone struggling with this: stackoverflow.com/questions/61630890/servlet-service-for-servlet-jersey-web-application-in-context-with-path-me/61688539#61688539
@thecodersbay8157
@thecodersbay8157 4 жыл бұрын
@@milantrehan178 Thanks Man , now xml response is also working.
@hamkb9741
@hamkb9741 7 жыл бұрын
perfect!
@WithAdvik
@WithAdvik 9 жыл бұрын
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
@jyotirmayadehury8467
@jyotirmayadehury8467 9 жыл бұрын
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; }
@TheCoolakashrockin
@TheCoolakashrockin 9 жыл бұрын
+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
@tulsi6317
@tulsi6317 8 жыл бұрын
thanks bestie
@chowdeswariappasani9715
@chowdeswariappasani9715 8 жыл бұрын
How to form URL to work out in browser?
@chowdeswariappasani9715
@chowdeswariappasani9715 8 жыл бұрын
yeah got it!
@aniwar2698
@aniwar2698 7 жыл бұрын
Most of us are forgetting to add empty Message constructor . That's why #500 .
@AkashGanga2512
@AkashGanga2512 5 жыл бұрын
error 500 internal server error did everything. even added updated dependencies. using java 13 , tomcat 9.0.30
@ocherki
@ocherki 4 жыл бұрын
The same
@pichulio
@pichulio 4 жыл бұрын
create the constructor empty of message
@DARKOOMER
@DARKOOMER 9 жыл бұрын
iam getting 500 error and I wrote @xmlrootelemnt at message class, pls help
@DARKOOMER
@DARKOOMER 9 жыл бұрын
darko I fixed the problem, needed an empty constructor
@AbhishekPandey-yi6pf
@AbhishekPandey-yi6pf 9 жыл бұрын
+darko Can u please tell me why this empty constructor is required ? my email id is abhishekit3002@gmail.com
@aparnarodrigues4857
@aparnarodrigues4857 9 жыл бұрын
+darko Why do we need an empty constructor. It fixed my problem , however I did not get why?
@nehamehta6186
@nehamehta6186 9 жыл бұрын
Thanks alot
REST Web Services 15 - Installing a REST API client
6:25
Java Brains
Рет қаралды 266 М.
REST Web Services 13 - Creating a Resource
14:31
Java Brains
Рет қаралды 383 М.
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН
Andro, ELMAN, TONI, MONA - Зари (Official Audio)
2:53
RAAVA MUSIC
Рет қаралды 8 МЛН
БОЙКАЛАР| bayGUYS | 27 шығарылым
28:49
bayGUYS
Рет қаралды 1,1 МЛН
REST Web Services 07 - REST Response
16:33
Java Brains
Рет қаралды 372 М.
13.6: XML and JSON - Processing Tutorial
18:00
The Coding Train
Рет қаралды 128 М.
Katalon Studio API Testing 11 | Validate XML and JSON Response Values
11:58
Automation Step by Step
Рет қаралды 10 М.
Java Online Training | Parsing XML using Java DOM Parser
14:10
Firebox Training
Рет қаралды 221 М.
REST Web Services 11 - Setting Up
10:45
Java Brains
Рет қаралды 473 М.
REST Web Services 08 - HATEOAS
14:14
Java Brains
Рет қаралды 396 М.
Calling a SOAP web service from Java client
18:06
Software Pulse (John McNeil)
Рет қаралды 47 М.
1 Введение в веб сервисы
20:45
javabegin
Рет қаралды 35 М.
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН