# WebSphere: Missing SSLSocketFactory Class

### Problem <a href="#problem" id="problem"></a>

When using the SeaLights test listener as a javaagent in WebSphere, it fails to connect to our server with `ClassNotFoundException` for `com.ibm.websphere.ssl.protocol.SSLSocketFactory`

{% code overflow="wrap" lineNumbers="true" %}

```
[SEALIGHTS] (...) Error: java.lang.ClassNotFoundException: Cannot find the specified class com.ibm.websphere.ssl.protocol.SSLSocketFactory
java.net.SocketException: java.lang.ClassNotFoundException: Cannot find the specified class com.ibm.websphere.ssl.protocol.SSLSocketFactory
	at javax.net.ssl.DefaultSSLSocketFactory.a(SSLSocketFactory.java:10)
	...
```

{% endcode %}

### Cause <a href="#cause" id="cause"></a>

This is a known issue with WebSphere when SSL is enabled and using a JDK from the WebSphere Application Server (see references below).

When the IBM WebSphere Application Server starts up it sets the security property to the WebSphere default of `com.ibm.websphere.ssl.protocol.SSLSocketFactory` but this class is not visible to the Java agent, thus the `ClassNotFoundException` is raised when trying to open a secured connection to Sealights' servers.

### Solution <a href="#solution" id="solution"></a>

This issue can be resolved by creating a *file* called `sl.java.security` with the following content

{% code overflow="wrap" lineNumbers="true" %}

```
ssl.SocketFactory.provider=
ssl.ServerSocketFactory.provider=
```

{% endcode %}

And then add the following parameter to the JVM arguments of WebSphere alongside our javaagent:

{% code overflow="wrap" lineNumbers="true" %}

```
-Djava.security.properties=fullPathTo/sl.java.security
```

{% endcode %}

Another solution is to set WebSphere SSL configuration to use the IBM JSSE implementation by defining the content of `sl.java.security` file as below

{% code overflow="wrap" lineNumbers="true" fullWidth="false" %}

```
ssl.SocketFactory.provider=com.ibm.jsse2.SSLSocketFactoryImpl 
ssl.ServerSocketFactory.provider=com.ibm.jsse2.SSLServerSocketFactoryImpl 
```

{% endcode %}

#### References <a href="#references" id="references"></a>

* <https://www.ibm.com/support/pages/cannot-find-specified-class-comibmwebspheresslprotocolsslsocketfactory>
* <https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/jsse2Docs/customization.html>
* <https://backstage.forgerock.com/knowledge/kb/article/a48447600>
* <https://support.contrastsecurity.com/hc/en-us/articles/360040457971-Java-Agent-fails-to-connect-to-Contrast-UI-java-lang-ClassNotFoundException>

### Related articles <a href="#related-articles" id="related-articles"></a>

* [Pivotal Cloud Foundry (PCF) Support](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/pivotal-cloud-foundry-pcf-support.md) (Java)
* [NodeJS - JavaScript heap out of memory](/knowledgebase/setup-and-configuration/troubleshooting-faq/node-javascript/nodejs-javascript-heap-out-of-memory.md)
* [Testing Frameworks Integration](/knowledgebase/setup-and-configuration/integrations/testing-frameworks-integration.md)
* [Installing the Coverage Listener as a JVM Java Agent](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/default-usage-cli/installing-the-coverage-listener-as-a-jvm-java-agent.md) (Java)
* [CD Agent for Java Application](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/cd-agent/cd-agent-for-java-application.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/java/websphere-missing-sslsocketfactory-class.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
