You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Michael Austermann (JIRA)" <ji...@apache.org> on 2016/12/19 12:12:58 UTC
[jira] [Commented] (CXF-7179) Unable to set ServerConnector in
JettyHTTPServerEngine using jetty 9
[ https://issues.apache.org/jira/browse/CXF-7179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15761010#comment-15761010 ]
Michael Austermann commented on CXF-7179:
-----------------------------------------
There is a work arround for this issue. First create the jetty server and then kind of publish it to cxf like this:
{noformat}
public class Example {
public static void main(String[] args) throws Exception {
Server server = new Server();
ServerConnector sc = new ServerConnector(server);
sc.setHost("localhost");
sc.setPort(12345);
server.setConnectors(new Connector[] { sc });
server.setHandler(new ContextHandlerCollection());
server.start();
JettyHTTPServerEngineFactory factory = new JettyHTTPServerEngineFactory();
JettyHTTPServerEngine jettyHTTPServerEngine = new JettyHTTPServerEngine(factory.getMBeanContainer(), "localhost", 12345);
jettyHTTPServerEngine.setServer(server);
factory.setEnginesList(Arrays.asList(new JettyHTTPServerEngine[] { jettyHTTPServerEngine }));
Provider provider = Provider.provider();
EndpointImpl epi = (EndpointImpl) provider.createEndpoint(null, new FooImpl());
epi.publish("http://localhost:12345/foo");
}
}
{noformat}
> Unable to set ServerConnector in JettyHTTPServerEngine using jetty 9
> --------------------------------------------------------------------
>
> Key: CXF-7179
> URL: https://issues.apache.org/jira/browse/CXF-7179
> Project: CXF
> Issue Type: Bug
> Components: Transports
> Affects Versions: 3.1.9
> Reporter: Michael Austermann
> Assignee: Freeman Fang
>
> With Jetty 9 a reference to the jetty server is needed to create a ServerConnector (jetty's default connector).
> See org.eclipse.jetty.server.ServerConnector.ServerConnector(Server)
> Using the CXF JettyHTTPServerEngineFactory and JettyHTTPServerEngine to create a jetty server, it is impossible to override the Connector.
> The method org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.setConnector(Connector) is useless, because it is impossible to create a ServerConnector without a Jetty Server and JettyHTTPServerEngine.getServer() returns null during configuration phase of the JettyHTTPServerEngine.
> The example below leads to a NullPointerException:
> {noformat}
> public class Example {
> public static void main(String[] args) throws Exception {
> JettyHTTPServerEngineFactory factory = new JettyHTTPServerEngineFactory();
> JettyHTTPServerEngine engine = factory.createJettyHTTPServerEngine(12345, "http");
> ServerConnector connector = new ServerConnector(null); // engine.getServer() is also NULL at this time
> engine.setConnector(connector);
> Provider provider = Provider.provider();
> EndpointImpl epi = (EndpointImpl) provider.createEndpoint(null, new FooImpl());
> epi.publish("http://0.0.0.0:12345/foo");
> }
> }
> {noformat}
> {noformat}
> Exception in thread "main" java.lang.NullPointerException
> at org.eclipse.jetty.server.AbstractConnector.<init>(AbstractConnector.java:170)
> at org.eclipse.jetty.server.AbstractNetworkConnector.<init>(AbstractNetworkConnector.java:44)
> at org.eclipse.jetty.server.ServerConnector.<init>(ServerConnector.java:227)
> at org.eclipse.jetty.server.ServerConnector.<init>(ServerConnector.java:96)
> at Example.main(Example.java:14)
> {noformat}
>
>
> Class JettyHTTPServerEngine needs to be adapted to enable setting a custom jetty 9 connector.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)