cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: NullPointerException migrating from 2.1.10 to CXF 2.3.0 and 2.2.11
Date Thu, 21 Oct 2010 20:40:43 GMT

I really don't have an objection to putting a null guard there, but I do have 
to wonder how something is being started up without an address.  That seems a 
bit strange to me.    Can you post the setup code or whatever that you have so 
I can see why the address is ending up null?

Thanks!
Dan


On Thursday 21 October 2010 3:46:55 pm Gary Gregory wrote:
> Hi All:
> 
> 
> 
> I am currently on CXF 2.2.10 and our unit tests are humming along great.
> 
> 
> 
> When I switch to 2.1.11 or 2.3.0, I see many NullPointerException like:
> 
> 
> 
> junit.framework.AssertionFailedError: Expected response to start with
> "<?xml": <html>
> 
> <head>
> 
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
> 
> <title>Error 500 Server Error</title>
> 
> </head>
> 
> <body><h2>HTTP ERROR 500</h2>
> 
> <p>Problem accessing /. Reason:
> 
> <pre>    Server Error</pre></p><h3>Caused
> by:</h3><pre>java.lang.NullPointerException
> 
>       at
> org.apache.cxf.transport.servlet.ServletDestination.getBasePath(ServletDes
> tination.java:105)
> 
>       at
> org.apache.cxf.transport.http.AbstractHTTPDestination.setupMessage(Abstrac
> tHTTPDestination.java:335)
> 
>       at
> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestinat
> ion.java:88)
> 
>       at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servl
> etController.java:428)
> 
>       at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletControlle
> r.java:183)
> 
>       at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServ
> let.java:148)
> 
>       at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Abstrac
> tHTTPServlet.java:179)
> 
>       at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPSe
> rvlet.java:103)
> 
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
> 
>       at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPS
> ervlet.java:159)
> 
>       at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:527)
> 
>       at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:423)
> 
>       at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:1
> 19)
> 
>       at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:493
> )
> 
>       at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.ja
> va:225)
> 
>       at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.ja
> va:930)
> 
>       at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:358)
> 
>       at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.jav
> a:183)
> 
>       at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.jav
> a:866)
> 
>       at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:1
> 17)
> 
>       at
> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollectio
> n.java:126)
> 
>       at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java
> :113)
> 
>       at org.eclipse.jetty.server.Server.handle(Server.java:351)
> 
>       at
> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:
> 594)
> 
>       at
> org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(Http
> Connection.java:1042)
> 
>       at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:558)
> 
>       at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:211)
> 
>       at
> org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:424)
> 
>       at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.j
> ava:506)
> 
>       at
> org.eclipse.jetty.util.thread.OldQueuedThreadPool$PoolThread.run(OldQueued
> ThreadPool.java:524)
> 
> </pre>
> 
> <hr /><i><small>Powered by Jetty://</small></i><br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> <br/>
> 
> 
> 
> </body>
> 
> </html>
> 
> 
> 
>       at junit.framework.Assert.fail(Assert.java:47)
> 
>       at junit.framework.Assert.assertTrue(Assert.java:20)
> 
>       at
> com.seagullsw.appinterface.server.comm.http.TestUtils.assertExecute(TestUt
> ils.java:51)
> 
>       at
> com.seagullsw.appinterface.server.comm.http.TestUtils.execute(TestUtils.ja
> va:114)
> 
>       at
> com.seagullsw.appinterface.server.comm.http.TestUtils.doATest(TestUtils.ja
> va:102)
> 
>       at
> com.seagullsw.appinterface.server.comm.http.TestUtils.doAnOkTest(TestUtils
> .java:78)
> 
>       at
> com.seagullsw.appinterface.server.comm.http.TestUtils.doAnOkTest(TestUtils
> .java:74)
> 
>       at
> com.seagullsw.appinterface.server.comm.soap.SoapCmRoundtripTestCase.doAnOk
> Test(SoapCmRoundtripTestCase.java:76)
> 
>       at
> com.seagullsw.appinterface.server.comm.soap.SoapCmRoundtripTestCase.testNo
> opDocLiteralSoap(SoapCmRoundtripTestCase.java:126)
> 
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> 39)
> 
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorIm
> pl.java:25)
> 
>       at java.lang.reflect.Method.invoke(Method.java:597)
> 
>       at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMetho
> d.java:44)
> 
>       at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable
> .java:15)
> 
>       at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.
> java:41)
> 
>       at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.j
> ava:20)
> 
>       at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
> 28)
> 
>       at
> org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRun
> ner.java:79)
> 
>       at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.j
> ava:71)
> 
>       at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.j
> ava:49)
> 
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 
>       at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
> 28)
> 
>       at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31
> )
> 
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 
>       at org.junit.runners.Suite.runChild(Suite.java:128)
> 
>       at org.junit.runners.Suite.runChild(Suite.java:24)
> 
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 
>       at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestR
> eference.java:49)
> 
>       at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java
> :38)
> 
>       at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTest
> Runner.java:467)
> 
>       at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTest
> Runner.java:683)
> 
>       at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunne
> r.java:390)
> 
>       at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunn
> er.java:197)
> 
> 
> 
> 
> 
> Should the method:
> 
> 
> 
>     protected String getBasePath(String contextPath) throws IOException {
> 
> 
> 
>         String address = getAddress().getAddress().getValue();
> 
>         if (address.startsWith("http")) {
> 
>             return URI.create(address).getPath();
> 
>         }
> 
> 
> 
>         return contextPath + address;
> 
>     }
> 
> 
> 
> have guard clause like:
> 
> 
> 
>     protected String getBasePath(String contextPath) throws IOException {
> 
> 
> 
>         String address = getAddress().getAddress().getValue();
> 
>         if (address == null) {
> 
>            return contextPath;
> 
>         }
> 
>         if (address.startsWith("http")) {
> 
>             return URI.create(address).getPath();
> 
>         }
> 
> 
> 
>         return contextPath + address;
> 
>     }
> 
> 
> 
> ?
> 
> 
> 
> Gary Gregory
> 
> Senior Software Engineer
> 
> Rocket Software
> 
> 3340 Peachtree Road, Suite 820 * Atlanta, GA 30326 * USA
> 
> Tel: +1.404.760.1560
> 
> Email: ggregory@seagullsoftware.com
> 
> Web: seagull.rocketsoftware.com

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Mime
View raw message