Tomcat 7.0 + Chrome dont show JSON - java

Iam using Dynamic Web Project 2.5, Jersey and Tomcat 7.0 to create a Java Restful Webservice. I want to response JSON if someone request data. But i always get the following error from Tomcat:
That my configurations in relation to web.xml and annotations are ok is demonstrated by using xml instead of JSON. Then its working fine:
If i switch MediaType Notation from APPLICATION_XML to APPLICATION_JSON the error is thrown.
Iam using Chrome-Browser and i read that chrome just show a json-string if requested. I hope someone can help me. Thanks in advance.

Seeing from your previous question, you seem to missing a provider for JSON/POJO support. You can see this answer for all the jars and dependencies you need to add to your project.
Note: The linked answer shows 2.17 jars for Jersey, but you are using 2.18. The answer also provides a link where you can download the version you need.

Related

Hide WSDL in JAX-RPC 1.1 WS

I have a lot of old web services.
Now the wsdl is public, so i need to hide the wsdl.
My configuration is jax-rpc 1.1 + Weblogic 12.1.3.0.0
I have searched a lot, but none of the solutions found have worked for me:
I don't have the option in Weblogic to hide the wsdl (in the documentation appears this option but in my weblogic not):
#WSDL(exposed = false) (¿not possible in jax-rpc?)
Implementing a class with Filter is not working
Does anyone have any idea how to hide the wsdl with this configuration?
Thanks & Regards.
Finally i solved this blocking the GET operations in the webservice (since all SOAP methods use POST )

Apache Karaf Rest Service Issue

I am having a WAB application which is just having only one html file, and its working fine. the code is available on the below git link
https://github.com/vineethvnair0/Karaf/tree/master/first-wab
Now I want to define a rest service in the wab, with the same context root as my web app for example like below.
http://localhost:8181/first-wab/rest/hello
Please let me know how can i do it?
Simply add a CXF servlet to the web.xml. The exact solution depends on how you expose your Rest endpoints. Do you plan to use spring?

WebLogic ClientInstanceInvocationHandler to cxf ClientProxy

Hello I have a WebService Client on my java project the which is on weblogic. Now I need add the header for security reasons to my petition. I have tried everything and finally a friend help me with a code for Jboss the which works fine on Jboss, but on weblogic it gives me a problem with of castClassException.
Like the title said the original class is "ClientInstanceInvocationHandler" and I need that on "ClientProxy" of APACHE CXF
Here is the problem:
org.apache.cxf.endpoint.Client client = ClientProxy.getClient( port );
Does anyone have a solution?
According to this site https://community.oracle.com/thread/2467175?tstart=0 the problem is that the Apache classes are not properly on the classpath of the server.
They said they "set the APACHE CXF jars as a User Defined Library and set it to the 'Deployed by Default' option".
In this blog with the same problem, they use the following fragment in their weblogic-application.xml:
<prefer-application-resources>
<resource-name>META-INF/services/javax.xml.ws.spi.Provider</resource-name>
</prefer-application-resources>
From what I can understand weblogic returns it's own implementations for these methods unless you tell it to prefer the standard interface and put an implementation of the standard interface on the classpath. I guess the custom class gives some extra performance or features beyond the standard interface.
The Apache CXF site itself addresses this in a similar way, but suggests a different package name (javax.jws.*)
In addition to all this, some people had problems getting weblogic to find and recognise the jars because it was loading weblogic classes in preference and had to do the following:
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
But I have seen variations on this, depending on where your Apache jars are located.

Apache CXF WSDL Resolution

Using Apache CXF 2.7.7 if I publish a simple "HelloWorld" JAX-WS service and attempt to resolve the WSDL URL in a web browser using: "localhost:8080/service/HelloWorld?wsdl" the WSDL loads in the browser and everything looks great.
If I then add the below annotation which changes the SOAP Binding to 1.2 the WSDL resolution still works but the WSDL doesn't load in the browser, instead a download dialog is shown and the name of the WSDL is missing the file name extension in the download dialog (which is probably why it isn't loading in the browser).
javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING
The same behavior appears with the SOAP12HTTP_MTOM_BINDING
#javax.xml.ws.BindingType (value=javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_MTOM_BINDING)
Functionally everything works fine even with the BindingType annotation defined so this is just a minor annoyance but I'm wondering how I can get the correct WSDL resolution behavior when the default SOAP 1.1 binding is in use.
I posted this issue on the Apache CXF JIRA and it was acknowledged as a defect. It has been fixed and will be included with the Apache CXF 2.7.8 release.
https://issues.apache.org/jira/browse/CXF-5334

Upload file using Jetty and Maven

I want to use Jetty to upload file to my server I have tried the example from the Jetty documentation, but it doesn't work. It throws an exception:
java.lang.ClassNotFoundException: org.mortbay.servlet.MultiPartFilter
Since you say your using Eclipse Jetty the correct class package is:
org.eclipse.jetty.servlets.MultiPartFilter
Note that using the filter is not recommended for jetty-8 since the Servlet 3.0 spec added an alternative way to access this sort of information through the servlet API.

Categories

Resources