Switching among different JAX-RS providers by using command prompt

You can use command prompt to list all the Java™ API for RESTful Web Services (JAX-RS) providers, identify, and modify the selected JAX-RS provider in WebSphere® Application Server traditional V9.

About this task

WebSphere Application Server traditional V9 provides four options for JAX-RS provider. By default, JAX-RS provider on version 9 is Apache CXF-based JAX-RS 2.0. With the wsadmin scripting tool, you might choose to list all the information about four JAX-RS providers, identify the current JAX-RS providers that are configured on a server, or modify the selected JAX-RS provider based on your needs.

Important: Ensure that the JAX-RS provider configured on the application server corresponds with your deployed application.
Tip: In WebSphere Application Server traditional V9, JAX-RS is not supported in the Java EE Application Client environment.

Procedure

  • List the information about the JAX-RS providers.
    1. Start the wsadmin scripting tool by using jacl language via -lang jacl.
    2. Run the listSupportedJaxrsProviders command to identify the JAX-RS providers supported by the version 9:
      wsadmin>$AdminTask listSupportedJaxrsProviders
      All the supported JAX-RS providers
      Provider Implementation Version
      2.0 Apache CXF 2.0
      1.1 Apache Wink 1.1
      1.1spec 1.1spec 1.1spec
      2.0spec 2.0spec 2.0spec
      Tip: To list only the supported JAXRS provider level values with the listSupportedJaxrsProviders command, set the -versionOnly parameter value to be true:
      
      wsadmin>$AdminTask listSupportedJaxrsProviders {-versionOnly true}
      2.0
      1.1
      1.1spec
      2.0spec
      
  • Identify the current JAX-RS providers that are configured on a server.
    1. Start the wsadmin scripting tool by using jacl language via -lang jacl.
    2. Run the showJaxrsProvider command.
      The AdminTask showJaxrsProvider command can take either the node and server name as parameters or it can take an ObjectName as a server configuration object:
      • Take the node and server name as its parameters:
        wsadmin>$AdminTask showJaxrsProvider {-node mynode02 -server server1}
      • Take an ObjectName as a server configuration object:
        
        wsadmin>set svr [$AdminConfig list Server]
        server1(cells/mynode02Cell/nodes/mynode02/server/server1|server.xml#Server_1183122130078)
        wsadmin>$AdminTask showJaxrsProvider $svr
        2.0
        
  • Modify the selected JAX-RS provider for a server.
    1. Start the wsadmin scripting tool by using jacl language via -lang jacl.
    2. Run the modifyJaxrsProvider command.
      The AdminTask modifyJaxrsProvider command can take either the node and server name as parameters or it can take an ObjectName as a Server configuration object:
      • Take the node and server name as its parameters:
        
        wsadmin>$AdminTask modifyJaxrsProvider {-node mynode02 -server server1 -provider 2.0}
        CWTRS8813E: The JAXRS Provider for Server server1 has been successfully set to JAXRS 2.0.
      • Take an ObjectName as a server configuration object:
        
        wsadmin>set svr [$AdminConfig list Server]
        wsadmin>$AdminTask modifyJaxrsProvider $svr {-provider 2.0}
        
        CWTRS8813E: The JAXRS Provider for Config Object WebSphere:_Websphere_Config_Data_Display_Name=server1,_Websphere_Config_Data_Id=cells/mynode02Cell/nodes/mynode02/servers/server1|server.xml#Server_1183122130078has been successfully set to JAXRS 2.0.
      Remember: An extra provider parameter -provider is required and accepts values equal to those values produced by the listSupportedJaxrsProviders AdminTask.
      Tip: If the server is one of cluster members, the modification made on server will be applied to all cluster members automatically.
    3. Save the configuration.
    4. Restart the server to take the JAX-RS provider changes into effect.