我创建了一个横幅文档,其中包含图像和一些文本作为内容。 我还与其他服务经理创建了一个休息链接。但是当运行下面的rest链接时,我得到一个NullPointerException:
其余链接:http://localhost:8080/site/restapi/Banner?_type=json
我的Banner.java bean是:
@XmlRootElement(name = "banner")
@XmlAccessorType(XmlAccessType.NONE)
@HippoEssentialsGenerated(internalName = "gogreen:bannerdocument")
@Node(jcrType = "gogreen:bannerdocument")
public class Banner extends BaseDocument {
@XmlElement
@HippoEssentialsGenerated(internalName = "gogreen:title")
public String getTitle() {
return getProperty("gogreen:title");
}
@XmlJavaTypeAdapter(HippoHtmlAdapter.class)
@XmlElement
@HippoEssentialsGenerated(internalName = "gogreen:content")
public HippoHtml getContent() {
System.out.println("** Getting the NPE here: **********");
return getHippoHtml("gogreen:content");
}
@HippoEssentialsGenerated(internalName = "gogreen:link")
public HippoBean getLink() {
return getLinkedBean("gogreen:link", HippoBean.class);
}
@HippoEssentialsGenerated(internalName = "gogreen:image")
public Imageset getImage() {
System.out.println("******** Getting the banner Image here **********");
return getLinkedBean("gogreen:image", Imageset.class);
}
..
}
我正在排队NullPointerExeption:
return getHippoHtml("gogreen:content");
Banner已经有内容(图像/文本),但getContent()返回null。 请帮我解决这个问题:
例外是:
[INFO] [talledLocalContainer] 13.11.2015 14:29:04 ERROR http-nio-8080-exec-8 [DefaultHstLinkCreator$HstLinkResolver.resolve:620] E
xception during creating link
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.linking.DefaultHstLinkCreator$HstLinkResolver.resolve(DefaultHstLinkCreat
or.java:505)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.linking.DefaultHstLinkCreator.create(DefaultHstLinkCreator.java:136)
[INFO] [talledLocalContainer] at org.hippoecm.hst.content.rewriter.impl.SimpleContentRewriter.createLink(SimpleContentRewriter.j
ava:417)
[INFO] [talledLocalContainer] at org.hippoecm.hst.content.rewriter.impl.SimpleContentRewriter.getLink(SimpleContentRewriter.java
:374)
[INFO] [talledLocalContainer] at org.hippoecm.hst.content.rewriter.impl.SimpleContentRewriter.getBinaryLink(SimpleContentRewrite
r.java:298)
[INFO] [talledLocalContainer] at org.hippoecm.hst.content.rewriter.impl.SimpleContentRewriter.rewriteBinaryLink(SimpleContentRew
riter.java:274)
[INFO] [talledLocalContainer] at org.hippoecm.hst.content.rewriter.impl.SimpleContentRewriter.rewrite(SimpleContentRewriter.java
:179)
[INFO] [talledLocalContainer] at org.hippoecm.hst.content.rewriter.impl.SimpleContentRewriter.rewrite(SimpleContentRewriter.java
:84)
[INFO] [talledLocalContainer] at org.hippoecm.hst.content.rewriter.impl.SimpleContentRewriter.rewrite(SimpleContentRewriter.java
:42)
[INFO] [talledLocalContainer] at org.onehippo.cms7.essentials.components.rest.adapters.HippoHtmlAdapter.marshal(HippoHtmlAdapter
.java:36)
[INFO] [talledLocalContainer] at org.onehippo.cms7.essentials.components.rest.adapters.HippoHtmlAdapter.marshal(HippoHtmlAdapter
.java:27)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.module.jaxb.AdapterConverter.convert(AdapterConverter.java:33)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.std.StdDelegatingSerializer.convertValue(StdDelegatingSerial
izer.java:238)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.std.StdDelegatingSerializer.serialize(StdDelegatingSerialize
r.java:156)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:
505)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.ja
va:639)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSeri
alizer.java:100)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSeri
alizer.java:21)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.ja
va:183)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:
505)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.ja
va:639)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerPr
ovider.java:250)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:604)
[INFO] [talledLocalContainer] at com.fasterxml.jackson.jaxrs.base.ProviderBase.writeTo(ProviderBase.java:648)
[INFO] [talledLocalContainer] at org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1363)
[INFO] [talledLocalContainer] at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:
244)
[INFO] [talledLocalContainer] at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:1
17)
[INFO] [talledLocalContainer] at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:80)
[INFO] [talledLocalContainer] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
[INFO] [talledLocalContainer] at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java
:83)
[INFO] [talledLocalContainer] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
[INFO] [talledLocalContainer] at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
[INFO] [talledLocalContainer] at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:251)
[INFO] [talledLocalContainer] at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223
)
[INFO] [talledLocalContainer] at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:197)
[INFO] [talledLocalContainer] at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:149)
[INFO] [talledLocalContainer] at org.hippoecm.hst.jaxrs.cxf.CXFJaxrsService.invoke(CXFJaxrsService.java:147)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.JaxrsRestServiceValve.invoke(JaxrsRestServiceValve.java:38)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:269)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.GenericResponseHeadersValve.invoke(GenericResponseHeadersValve.
java:83)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:269)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.SubjectBasedSessionValve.invoke(SubjectBasedSessionValve.java:5
8)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:269)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.SecurityValve.invoke(SecurityValve.java:177)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:269)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.CmsSecurityValve.invoke(CmsSecurityValve.java:82)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:269)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.InitializationValve.invoke(InitializationValve.java:50)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:269)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.HstSitePipeline.invokeValves(HstSitePipeline.java:170)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.HstSitePipeline.invoke(HstSitePipeline.java:153)
[INFO] [talledLocalContainer] at org.hippoecm.hst.core.container.HstRequestProcessorImpl.processRequest(HstRequestProcessorImpl.
java:79)
[INFO] [talledLocalContainer] at org.hippoecm.hst.container.HstDelegateeFilterBean.doFilter(HstDelegateeFilterBean.java:397)
[INFO] [talledLocalContainer] at org.hippoecm.hst.container.DelegatingFilter.doFilter(DelegatingFilter.java:84)
[INFO] [talledLocalContainer] at org.hippoecm.hst.container.HstFilter.doFilter(HstFilter.java:51)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:23
9)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
[INFO] [talledLocalContainer] at org.hippoecm.hst.container.XSSUrlFilter.doFilter(XSSUrlFilter.java:52)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:23
9)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
[INFO] [talledLocalContainer] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter
.java:88)
[INFO] [talledLocalContainer] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:23
9)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
[INFO] [talledLocalContainer] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
[INFO] [talledLocalContainer] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
[INFO] [talledLocalContainer] at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
[INFO] [talledLocalContainer] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
[INFO] [talledLocalContainer] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
[INFO] [talledLocalContainer] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
[INFO] [talledLocalContainer] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
[INFO] [talledLocalContainer] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[INFO] [talledLocalContainer] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
答案 0 :(得分:0)
您已使用Essentials Rest设置工具生成示例或演示Rest实现。生成设置后,开发人员需要扩展和优化结果。 默认情况下,此安装程序中富文本内的链接是为当前安装生成的,即REST安装。由于图像不能通过REST挂载获得,因此您将获得/ pagenotfound URL。
如果您检查横幅的Bean,您会看到 HippoHtml 字段使用 HippoHtmlAdapter 。检查其代码:它使用 SimpleContentRewriter 。创建您自己的适配器版本并使用 ContentRewriter 的扩展版本。覆盖 #rewriteBinaryLink 方法。在其中调用super方法,但将站点挂载指定为目标挂载。
为网站安装添加 hst:别名是一个不错的主意,因此您可以使用别名引用该网站。