OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.15k stars 592 forks source link

RESTEASY003880: Unable to find contextual data of type: org.jboss.resteasy.spi.ResteasyConfiguration #24300

Open fitzget opened 1 year ago

fitzget commented 1 year ago

This problem was resolved without code change. This issue was left open to resolve a message issue related to trace. See comments below.

Original problem:

Describe the bug
We have a Java servlet making a call to a restful web service using Jakarta V9.1 (RestfulWs-3.0 feature)

The code issues

    Client client = ClientBuilder.newClient();

    System.out.println("AsynClientTest: about to call 'client.target("+REST_SERVICE_URL+")'");

    CompletionStage<String> csResponse = client.target(REST_SERVICE_URL)                
            .request()                 //Webtarget
            .rx()                      //invocation builder
            .get(String.class);        //CompletionStageRxInvoker

    csResponse.thenAccept(System.out::println);

the target never gets invoked and trace shows we get (full trace attached in zip file)

[2/14/23 16:20:20:229 GMT] 0000004c id=00000000 org.jboss.resteasy.spi.LoggableFailure                       > <init> Entry  
                                                                                                           RESTEASY003880: Unable to find contextual data of type: org.jboss.resteasy.spi.ResteasyConfiguration
[2/14/23 16:20:20:229 GMT] 0000004c id=685f4f47 org.jboss.resteasy.spi.LoggableFailure                       < <init> Exit  
                                                                                                           org.jboss.resteasy.spi.LoggableFailure: RESTEASY003880: Unable to find contextual data of type: org.jboss.resteasy.spi.ResteasyConfiguration

This application worked using Java EE8 (using feature jaxrs-2.1)

Trace achieved by setting

*=info=enabled:logservice=all:com.ibm.ws.jaxrs*=all:com.ibm.websphere.jaxrs*=all:org.apache.cxf.*=all:RESTfulWS=all:io.openliberty.org.jboss.*=all:io.openliberty.restfulWS.*=all:org.jboss.resteasy.*=all

Steps to Reproduce
Application code attached. Two classes.Ist class a servlet which invokes the Restful service (the url for which is passed as querystring part url= on the call to the web servlet

Expected behavior
client.target to invoke the restful web service

Diagnostic information:


product = CICS LIBERTY 6.2.0, WAS FOR Z/OS 22.0.0.9 (wlp-1.0.68.cl220920220815-1900) wlp.install.dir = /itbld/cics.ts.dev/IntA/dist/wlp/ server.config.dir = /u/fitzget/cics750/work/IYK3ZTFA/DFHWLP/wlp/usr/servers/defaultServer/ java.home = /java/J8.0_64 java.version = 1.8.0_351 java.runtime = Java(TM) SE Runtime Environment (8.0.7.20 - pmz6480sr7fp20-20221020_01(SR7 FP20)) os = z/OS (02.04.00; s390x) (en_US) process = 67175682@WINMVS2C Classpath = /itbld/cics.ts.dev/Integrat/dist/lib/com.ibm.cics.common.log.jar:/itbld/cics.ts.dev/Integrat/dist/lib/com.ibm.cics.common.jar:/itbld/cics.ts.dev/Integrat/dist/lib/com.ibm.cics.jvmserver.spi.jar:/itbld/cics.ts.dev/Integrat/dist/lib/dfjrouter.jar:/itbld/cics.ts.dev/Integrat/dist/lib/com.ibm.cics.router.wlp.jar:/itbld/cics.ts.dev/Integrat/dist/wlp/bin/tools/ws-server.jar:/itbld/cics.ts.dev/Integrat/dist/wlp/lib/org.eclipse.osgi_3.17.200.jar:/itbld/cics.ts.dev/Integrat/dist/wlp/bin/tools/ws-javaagent.jar:/itbld/cics.ts.dev/Integrat/dist/wlp/bin/tools/ws-javaagent.jar Java Library path = /java/J8.0_64/lib/s390x/compressedrefs:/java/J8.0_64/lib/s390x:/java/J8.0_64/lib/s390x/compressedrefs:/itbld/cics.ts.dev/Integrat/dist/lib:/java/J8.0_64/bin/j9vm:/java/J8.0_64/lib:/java/J8.0_64/lib/server:/java/J8.0_64/lib/compressedrefs:/java/J8.0_64/lib/j9vm:


java version "1.8.0_351" Java(TM) SE Runtime Environment (build 8.0.7.20 - pmz6480sr7fp20-20221020_01(SR7 FP20)) IBM J9 VM (build 2.9, JRE 1.8.0 z/OS s390x-64-Bit Compressed References 20220929_37824 (JIT enabled, AOT enabled) OpenJ9 - 02180fe OMR - 48fc32a IBM - bf759bf) JCL - 20220922_01 based on Oracle jdk8u351-b10 - server.xml configuration (WITHOUT sensitive information like passwords)

restfulWS problem 2.zip

<variable name="defaultHostName" value="winmvs2c.hursley.ibm.com"/>
<!-- Default HTTP End Point -->
<httpEndpoint host="*" httpPort="10198" httpsPort="10199" id="defaultHttpEndpoint"/>

<!-- The following configuration controls how often server.xml
     is scanned for updates. The default is every 500ms which may
     cause excessive I/O and CPU cost on z/OS.
     The values shown below reduce the overhead while still
     providing a relatively timely detection of new applications
     that have been installed/removed via a CICS Bundle
     (WAR bundlepart). If you use CICS bundles to install Web
     Applications (WAR files) do not use the "disabled" 
     updateTrigger.
-->
<config monitorInterval="5s" updateTrigger="polled"/>

<!-- Further scanning is performed to detect application updates or
     addition/removal of applications to the dropins directory. If
     you are using CICS Bundles as the vehicle for Application 
     deployment you should disable the dropins directory as shown.
     Further I/O and CPU reduction can be achieved by disabling
     the application scan. To effect changes to your applications
     while the server is still running, you should disable and
     re-enable the CICS bundle that contains the Web application.
     The pollingRate is only applicable when the updateTrigger is
     set to the 'polled' value.
     Consult the WebSphere Application Server Liberty Profile
     documentation for further information on these parameters.
-->
<applicationMonitor dropins="dropins" dropinsEnabled="false" pollingRate="5s" updateTrigger="disabled"/>

<!-- By default, the cdi-1.2 feature scans all application archives.
     The cdi-1.2 feature can increase startup time substantially 
     and have the most effect on larger applications. Implicit 
     archive scanning for annotations can be disabled by setting 
     enableImplicitBeanArchives value to false. This setting skips
     the scanning of archives unless they contain a beans.xml.
     Even if not explicitly coded, the cdi-1.2 feature might be 
     enabled through other features, such as the javaee-7.0 
     convenience feature.
-->
<cdi12 enableImplicitBeanArchives="false"/>
<include id="cics_auto" location="${server.config.dir}/installedApps.xml" onConflict="IGNORE"/>
<library id="defaultCICSDb2Library">
    <fileset dir="/usr/lpp/db2v12/jdbc/classes" includes="db2jcc4.jar db2jcc_license_cisuz.jar"/>
    <fileset dir="/usr/lpp/db2v12/jdbc/lib" includes="libdb2jcct2zos4_64.so"/>
</library>
<dataSource id="defaultCICSDataSource" jndiName="jdbc/defaultCICSDataSource" transactional="false" type="javax.sql.ConnectionPoolDataSource">
    <jdbcDriver libraryRef="defaultCICSDb2Library"/>
    <properties.db2.jcc driverType="2"/>
    <connectionManager agedTimeout="0"/>
</dataSource>
<executor id="allowCICSconfigure" maxThreads="15"/>
<ssl id="defaultSSLConfig" keyStoreRef="defaultKeyStore" sslProtocol="TLSv1.2"/>
<keyStore id="defaultKeyStore" password="defaultPassword"/>

Additional context
Add any other context about the problem here.

jim-krueger commented 1 year ago

The following is in the trace.log and appears to point to the root issue:

[2/14/23 16:20:20:229 GMT] 0000004c id=00000000 org.jboss.resteasy.spi.LoggableFailure                       > <init> Entry  
                                                                                                               RESTEASY003880: Unable to find contextual data of type: org.jboss.resteasy.spi.ResteasyConfiguration
[2/14/23 16:20:20:229 GMT] 0000004c id=685f4f47 org.jboss.resteasy.spi.LoggableFailure                       < <init> Exit  
                                                                                                               org.jboss.resteasy.spi.LoggableFailure: RESTEASY003880: Unable to find contextual data of type: org.jboss.resteasy.spi.ResteasyConfiguration
    at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:155)
    at com.sun.proxy.$Proxy36.getParameter(Unknown Source)
    at org.jboss.resteasy.plugins.providers.DocumentProvider.<init>(DocumentProvider.java:92)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:83)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:437)
    at org.jboss.resteasy.core.ConstructorInjectorImpl.constructOutsideRequest(ConstructorInjectorImpl.java:225)
    at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:209)
    at org.jboss.resteasy.core.providerfactory.Utils.createProviderInstance(Utils.java:102)
    at org.jboss.resteasy.core.providerfactory.CommonProviders.processProviderContracts(CommonProviders.java:108)
    at org.jboss.resteasy.core.providerfactory.ClientHelper.processProviderContracts(ClientHelper.java:104)
    at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.processProviderContracts(ResteasyProviderFactoryImpl.java:841)
    at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.registerProvider(ResteasyProviderFactoryImpl.java:829)
    at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.registerProvider(ResteasyProviderFactoryImpl.java:816)
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.registerProviders(RegisterBuiltin.java:109)
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:74)
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.getClientInitializedResteasyProviderFactory(RegisterBuiltin.java:54)
    at org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl.getProviderFactory(ResteasyClientBuilderImpl.java:377)
    at org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl.getConfiguration(ResteasyClientBuilderImpl.java:466)
    at io.openliberty.restfulWS.internal.ssl.component.SslClientBuilderListener.building(SslClientBuilderListener.java:60)
    at io.openliberty.org.jboss.resteasy.common.client.LibertyResteasyClientBuilderImpl.lambda$build$1(LibertyResteasyClientBuilderImpl.java:55)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:195)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:204)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:959)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:524)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:514)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:162)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:185)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:245)
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:429)
    at io.openliberty.org.jboss.resteasy.common.client.OsgiFacade.invoke(OsgiFacade.java:86)
    at io.openliberty.org.jboss.resteasy.common.client.LibertyResteasyClientBuilderImpl.lambda$build$2(LibertyResteasyClientBuilderImpl.java:55)
    at java.util.Optional.map(Optional.java:226)
    at io.openliberty.org.jboss.resteasy.common.client.LibertyResteasyClientBuilderImpl.build(LibertyResteasyClientBuilderImpl.java:54)
    at io.openliberty.org.jboss.resteasy.common.client.LibertyResteasyClientBuilderImpl.build(LibertyResteasyClientBuilderImpl.java:35)
    at jakarta.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:88)
...
fitzget commented 1 year ago

Hi

do you have a timeframe for looking at this please

Many Thanks Tony Fitzgerald

jim-krueger commented 1 year ago

Sorry it has taken so long to get back to you on this Tony. I hope to have a meaningful update for this issue within the next several days.

jim-krueger commented 1 year ago

@fitzget: Hi Tony, I apologize again for the delay on this issue. I've reproduced the problem you were seeing locally and have a resolution for you.

First, the error you are seeing when you turn trace on is a red herring and not actually the cause of the problem you are having. This exception occurs whenever trace is enabled. It indicates that org.jboss.resteasy.spi.ResteasyConfiguration is missing, however it does not appear that configuration is needed when running in Open Liberty and processing continues. That being said I plan on leaving this issue open to fix things so this message is either resolved or is prevented from showing up when trace is enabled.

As for the "real" problem you are experiencing. The code you included in your example is attempting to run a Completable Future operation but it is giving it no time to complete. That is making it look like the resource method was not found or executed (but without a 404). To resolve this simply add the following (.toCompletableFuture().get()) line to your AsyncClientTest.runClientAPI() method:

    csResponse.thenAccept(System.out::println);
    csResponse.toCompletableFuture().get();

When I add the line above your example works fine for me.

Hopefully this get things going for you.

fitzget commented 1 year ago

Hi Jim

apologies for the delay in getting back.

Have added the extra line of code to the application and it has resolved the problem.

Many thanks Tony Fitzgerald