Androidアプリを開発し、現在は外部DBとサーバーから始めています。通信はRESTful Webサービスによって実行されます。
このAndroidアプリケーションはJSONで情報を生成および消費するだけなので、Webサービスファサードでは、CRUDメソッドのXMLへの言及を消去したいだけです(NetBeansによって自動生成されます)。
つまり、これから:
@GET
@Override
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Counselor> findAll() {
return super.findAll();
}
これ(MediaType.APPLICATION_XMLなし):
@GET
@Override
@Produces(MediaType.APPLICATION_JSON)
public List<Counselor> findAll() {
return super.findAll();
}
問題は、これらの変更をGlassFish Server(4.1.1)にデプロイし、ブラウザでテストを行うと(DBデータを表示したいだけです)、このスタックトレースでエラーが発生することです:
Java.lang.NoClassDefFoundError: Could not initialize class org.Eclipse.persistence.jaxb.BeanValidationHelper
at org.Eclipse.persistence.jaxb.JAXBBeanValidator.isConstrainedObject(JAXBBeanValidator.Java:257)
at org.Eclipse.persistence.jaxb.JAXBBeanValidator.shouldValidate(JAXBBeanValidator.Java:208)
at org.Eclipse.persistence.jaxb.JAXBMarshaller.validateAndTransformIfNeeded(JAXBMarshaller.Java:587)
at org.Eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.Java:481)
at org.Eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.Java:949)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.Java:265)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.Java:250)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.Java:162)
at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.Java:106)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.Java:162)
at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.Java:86)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.Java:162)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.Java:1130)
at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.Java:683)
at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.Java:424)
at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.Java:414)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.Java:312)
at org.glassfish.jersey.internal.Errors$1.call(Errors.Java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.Java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.Java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.Java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.Java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.Java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.Java:292)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.Java:1139)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.Java:460)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.Java:386)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.Java:334)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.Java:221)
at org.Apache.catalina.core.StandardWrapper.service(StandardWrapper.Java:1682)
at org.Apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.Java:318)
at org.Apache.catalina.core.StandardContextValve.invoke(StandardContextValve.Java:160)
at org.Apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.Java:734)
at org.Apache.catalina.core.StandardPipeline.invoke(StandardPipeline.Java:673)
at com.Sun.enterprise.web.WebPipeline.invoke(WebPipeline.Java:99)
at org.Apache.catalina.core.StandardHostValve.invoke(StandardHostValve.Java:174)
at org.Apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.Java:416)
at org.Apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.Java:283)
at com.Sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.Java:459)
at com.Sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.Java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.Java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.Java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.Java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.Java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.Java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.Java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.Java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.Java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.Java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.Java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.Java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.Java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.Java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.Java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.Java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.Java:571)
at Java.lang.Thread.run(Thread.Java:745)
これについてのアイデアはありますか?
私は自分自身を説明したい...前もって感謝します!!
Glassfish 4.1.1のバグです https://Java.net/jira/browse/JERSEY-2888
私は汚い方法でそれを修正することができました:
Glassfish/modules/org.Eclipse.persistence.moxy.jarでMETA-INF/MANIFEST.MFを修正Import-Packageに以下を追加するだけです:
,org.xml.sax.helpers,javax.xml.parsers;resolution:=optional,javax.naming;resolution:=optional
したがって、次のようになります:
gFを再起動します
btw:ターミナルでjarを簡単に編集できます
emacs org.Eclipse.persistence.moxy.jar
ジャックの答えは本当に役に立ちます。
問題を特定し、パッチがなかったときに役立ちました。
しかし、jarを編集する代わりにをお勧めします。バグは2.6.1で修正されているため、download it at: org.Eclipse MVNRepositoryの.persistence.moxy-2.6.1
または、MVNRepositoryから最新バージョンを取得します。 https://mvnrepository.com/artifact/org.Eclipse.persistence/org.Eclipse.persistence.moxy
交換してください。
IDEを閉じて再度開くことを忘れないでください。