try {
SecurityActions.setContextClassLoader(ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
WSDeploymentBuilder.getInstance().build(unit);
dep = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
dep.addAttachment(ServiceTarget.class, target);
DeploymentAspectManager dam = new DeploymentAspectManagerImpl();
dam.setDeploymentAspects(aspects);
dam.deploy(dep);
// TODO: [JBWS-3426] fix this. START workaround
if (target == null) {
SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
EndpointRegistryFactory factory = spiProvider.getSPI(EndpointRegistryFactory.class);
EndpointRegistry registry = factory.getEndpointRegistry();