Q:

WebSphere ClassNotFoundException when invoking WebService after startup (but not later)

Update: The ClassNotFoundException only occurs if I try to use the web service immediately after starting the application. If I wait (for some unknown event/duration) the application will work. I would like to know what it is that I need to wait for.

Problem: My application fails because a class that does exist is not found by a classloader.
More info:
The class that cannot be found is com.sun.xml.stream.ZephyrParserFactory.
In my EAR I have the sjsxr.jar. This jar contains the class com.sun.xml.stream.ZephyrParserFactory
The EAR also contains MyApp.jar, which contains the EJB entry points for the application. The MyApp.jar manifest references all the needed jars, including sjsxr.jar
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Created-By: 1.5.0_18 (Sun Microsystems Inc.)
Built-By: GMM Development Team
Class-Path: aopalliance-1.0.jar commons-codec-1.4.jar commons-collecti
 ons-3.1.jar commons-lang-2.1.jar commons-logging-1.1.1.jar ehcache-co
 re-2.1.0.jar ehcache-spring-annotations-1.1.2.jar joda-time-1.6.1.jar
  log4j-1.2.16.jar org.springframework.context.support-3.0.4.RELEASE.j
 ar sjsxr.jar slf4j-api-1.6.1.jar slf4j-log4j12-1.6.1.jar spring-aop
 -3.0.4.RELEASE.jar spring-asm-3.0.4.RELEASE.jar spring-beans-3.0.4.RE
 LEASE.jar spring-context-3.0.4.RELEASE.jar spring-core-3.0.4.RELEASE.
 jar spring-expression-3.0.4.RELEASE.jar spring-jdbc-3.0.4.RELEASE.jar
  spring-tx-3.0.4.RELEASE.jar swiftVal.jar velocity-1.5.jar vm-startup
 .jar xbean.jar

The application contains web services client code generated by WebSphere's wsimport tool. When the application attempts to invoke this code, the following exception is thrown:
EJB threw an unexpected (non-declared) exception during invocation of method 
  "messageIn" on bean "BeanId(MyApp#ejb.jar#NodeEJB, null)". 
Exception data: javax.xml.stream.FactoryConfigurationError: Provider
  com.sun.xml.stream.ZephyrParserFactory not found
    at javax.xml.stream.XMLInputFactory.newInstance(Unknown Source)
    at org.apache.axiom.om.util.StAXUtils$7.run(StAXUtils.java:327)
    at java.security.AccessController.doPrivileged(AccessController.java:202)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory_perClassLoader(StAXUtils.java:323)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:78)
    at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:133)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:596)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:581)
    at org.apache.axis2.deployment.DescriptionBuilder.buildOM(DescriptionBuilder.java:97)
    at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:90)
    at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:641)
    at com.ibm.ws.websvcs.deployment.WASAxis2ConfigurationBuilder.loadAxisCfg(WASAxis2ConfigurationBuilder.java:492)
    at com.ibm.ws.websvcs.deployment.WASAxis2ConfigurationBuilder.loadAxisClientConfiguration(WASAxis2ConfigurationBuilder.java:191)
    at com.ibm.ws.websvcs.client.WSClientConfigurationFactory.getConfigContext(WSClientConfigurationFactory.java:271)
    at com.ibm.ws.websvcs.client.WSClientConfigurationFactory.getClientConfigurationContext(WSClientConfigurationFactory.java:236)
    at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:92)
    at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:79)
    at org.apache.axis2.jaxws.description.DescriptionFactory.createServiceDescription(DescriptionFactory.java:76)
    at org.apache.axis2.jaxws.spi.ServiceDelegate.<init>(ServiceDelegate.java:212)
    at org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Provider.java:59)
    at javax.xml.ws.Service.<init>(Service.java:67)
    at my.generated.Web_Service.<init>(Web_Service.java:44)
...
Caused by: java.lang.ClassNotFoundException: com.sun.xml.stream.ZephyrParserFactory
    at java.lang.Class.forNameImpl(Native Method)
    at java.lang.Class.forName(Class.java:136)
    at javax.xml.stream.FactoryFinder.newInstance(Unknown Source)
    at javax.xml.stream.FactoryFinder.find(Unknown Source)
    at javax.xml.stream.FactoryFinder.find(Unknown Source)
    ... 101 more

I have confirmed half a dozen times that the class, jar and manifest are correct before and after deployment.
I have also tried renaming the sjsxr.jar to avoid any potential eclipses but the problem does not go away.
I am using WebSphere 7.0.0.11 ND
Can anyone help?

A:

It's been a long time since I used java, and only touched WebSphere briefly, but maybe this will help? If you are having problems locating the jar file using the manifest, try packaging it in the WEB-INF/lib folder in the jar. It should be found implicitly without having to reference it in the manifest, assuming I read the info on the linked page correctly.
You also may want to have a look at this WebSphere link, about halfway down the page under the heading "Referencing classes within the EAR file".

