Using embedded jetty with camel-cxf - apache-camel

I have a couple of rest routes defined in my Camel project and now I'm trying to add a SOAP service to my project using the same jetty embedded server.
I have something like this:
restConfiguration()
.component("jetty")
.host("0.0.0.0")
.port(8080)
;
CxfEndpoint cxfEndpoint = new CxfEndpoint();
cxfEndpoint.setCamelContext(getContext());
cxfEndpoint.setServiceClass(TestService.class);
cxfEndpoint.setAddress("http://0.0.0.0:8080/test");
from(cxfEndpoint)
.log(LoggingLevel.INFO, log, "test");
When I try to run the application, I get this error message:
Web server failed to start. Port 8080 was already in use.
Look like it's trying to start 2 instances of Jetty using the same port and that's why it's failing.
I would really like to make the cxf endpoint work with the embedded Jetty used for my other services. Is there any way to do that?

Related

Maven cxf-codegen-plugin with NTLM Authentication - fails with java.io.IOException: Server returned HTTP response code: 401 for URL

I'm trying to generate java code using cxf-codegen-plugin for a SOAP webservice that is secured over NTLM. I'm not sure how do pass on the username/pwd/domain information to maven to connect to the remote server while generating the java code. I could open the wsdl using the browser using the username/pwd/domain combination I have. However, I'm wondering how to do it via command-line by passing some extra vm args to - mvn package. Or is there any other plugin config that I can do which helps me to do this?

Socket connection getting close while creating room on kurento

I have configure kurento on WS. Its spring boot application running on https://localhost:8443 (tomcat).
Logs:
s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8443 (https)
DEBUG 4730 --- [apterApp.main()] o.s.w.c.s.StandardServletEnvironment : Adding [server.ports] PropertySource with highest search precedence
INFO 4730 --- [apterApp.main()] com.io.AdapterApp : Started AdapterApp in 14.041 seconds (JVM running for 29.346)
Start boot application using below command:
sudo mvn compile exec:java Dkms.url=ws://io-storage:8888/kurento
Websocket running on 8888 port. (not secure WS).
While creating room the request is ws://io-storage:8888/call
But getting following error while request send to the kurento server
2018-10-31 13:12:23,252181 2009 [0x00007fe37ce5b700] error KurentoWebSocketTransport WebSocketTransport.cpp:455 openHandler() Invalid path "/call", closing connection
Kurento Media Server doesn't listen for RPC commands on the /call endpoint. Why are you requesting that URL?
Just use the Java API client by following any of the Java tutorials; this library does all of the RPC commands for you.
If you still need to work without libraries and program directly against the RPC API, then check the protocol docs.

Use Undertwo web server to serve both static pages and web service

I am trying to use Undertow to serve both static pages and web service (RestEasy) but couldn't get both of them working the same time. I see others asking the same questions like HTTP Handler and Resteasy Deployment with undertow and resteasy. There has to be a way to get this work, right? WildFly can handle both on the same port. But how could I do this? Thanks!
How about:
DeploymentInfo servletBuilder = deployment()
.setClassLoader(App.class.getClassLoader())
.setContextPath("/api")
.setDeploymentName("test.war")
.addServlets(
servlet("MessageServlet", MessageServlet.class)
.addInitParam("message", "Hello World")
.addMapping("/*"),
servlet("MyServlet", MessageServlet.class)
.addInitParam("message", "MyServlet")
.addMapping("/myservlet"));
DeploymentManager manager = defaultContainer().addDeployment(servletBuilder);
manager.deploy();
HttpHandler servletHandler = manager.start();
Undertow.builder().addHttpListener(8080, "0.0.0.0")
.setHandler(Handlers.path()
// REST API path
.addPrefixPath("/servlet", servletHandler)
// Serve all static files from a folder
.addPrefixPath("/static", new ResourceHandler(
new PathResourceManager(Paths.get("/path/to/www/"), 100))
.setWelcomeFiles("index.html"))
).build().start();
The servlet part is taken from Undertow's official examples, here.
You can talk to your Message servlets via:
GET /servlet/api
POST /servlet/api/myservlet

How to use taskqueues with GAE 1.7.7 behind a proxy

I upgraded to GAE 1.7.7 today and found out that task queues stopped working on my development setup.
I'm using https on my development environment through an nginx set up to proxy the connections from fakedomain.local:80 and fakedomain.local:443 to localhost:8080 (where GAE listens).
With this setup, taskqueues end up being created to be executed at fakedomain.local:80. This used to work because the request would be picked up by nginx, but the version 1.7.7 of the development server seems to have a port registry which won't serve a request unless the port is known (if I understand google.appengine.tools.devappserver2.Dispatcher._resolve_target correctly). Of course, GAE listens on port 8080 and my tasks marked to run on fakedomain.local:80 never get executed (GAE logs this error: An error occured while sending the task "task1" (Url: "...") in queue...).
I tried patching dispatcher.py:577 so instead of raising a ServerDoesNotExistError when the port is not known it will just use the default server. With this modification I can get the taskqueues running again, but I'd rather use a solution which doesn't involve changing GAE's code.
How can I make GAE register the port 80 and 443 in version 1.7.7? Alternatively, is there a way I could specify the complete target URL for the task? (ie fakedomain.local:8080/my_task, instead of just /mytask).
taskqueue.add(target=taskqueue.DEFAULT_APP_VERSION, ...)
will run it on your default app, which should do exactly what you want.
taskqueue.DEFAULT_APP_VERSION =>
app_identity.get_default_version_hostname() =>
environ['DEFAULT_VERSION_HOSTNAME'] =>
'%s:%s' % (environ['SERVER_NAME'], server_port)

WSDL2Java tool error Apache CXF

We get the following error when we use WSDL2Java tool to generate stubs. The webservice is up and running.
WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsd
l definition from : http://scheduler.heartbeatsoftware.com/scheduler/WebServices
/SampleSNMWebService?wsdl
Caused by : WSDLException: faultCode=PARSER_ERROR: java.lang.IllegalArgumentExce
ption: InputSource must have a ByteStream or CharacterStream
If we donwload the wsdl and generate stubs from that wsdl, they are generated. But the java client using those stubs throws the same exception as above
Strangely when we deploy the same webservice on our LAN such a problem is not encountered stubs are generated sucessfully and the subsequent java client works well.
The webservice is created using apache cxf version 2.2.5 and hosted on tomcat 6
Any pointers would be appreciated
regards
Sameer
Found solution. Just need to modify the wsdl.java.bat to include proxy settings
-Dhttp.proxyHost= -Dhttp.proxyPort=8080

Resources