We have one EJB for sending email notifications. We did not use Email BC because we have to format the email and we did not want to do that in every BPEL. We have atleast 30 service assemblies using this EJB. Everytime we shutdown one of the service assemblies, this EJB stops working. We will not get email notifications. When we went through the logs we found that we are getting “Unable to locate activated endpoint” error. Usually this error occurs when the service is not deployed or not reachable. On Further investigation we were able to make out that when we shutdown any of the service assemblies which uses this EJB it affects all the others. We thought it is a bug with GlassFishESB. As a workaround, we had to restart all the service assemblies which uses this EJB.
I wanted to fix this Bug. I wrote two service assemblies TestCA1 and TestCA2, and one CommonEJB. TestCA1 and TestCA2 will receive a http request, invoke the CommonEJB and return the string from CommonEJB. This is a plain echo service. For invoking this EJB from BPEL I need to have the WSDL of this EJB. So I used “Generate and Copy WSDL..” option to copy the WSDL into the BPEL folder. I was able to cleanly reproduce the problem. Everytime I shutdown TestBP1, TestBP2 was not working and vice versa. I turned the JBI logging to finest. And this is what I found when I shutdown TestCA1:
[#|2012-02-14T19:33:41.322+0530|FINE|sun-appserver2.1|com.sun.jbi.messaging|_ThreadID=1015;_ThreadName=TestCA1-sun-http-binding;ClassName=com.sun.jbi.messaging.EndpointRegistry;MethodName=removeEndpoint;_RequestID=42f05924-ebc6-43ad-8a4d-539c8d910bf3;|Removed endpoint: http://test.logicoy.com/,CommonEJBService,CommonEJBPort|#]
So it is clear that it is removing this endpoint from EndpointRegistry. But why does it remove this endpoint? Can’t the JBI understand that it is a common service? The answer is No. It cannot. This is what I found when we shutdown a service assembly:
– It looks at the jbi.xml for all the endpoints under connections.
– It removes all the endpoints from EndpointRegistry by supplying endpoint names.
So it does not know if the endpoint is a common endpoint or not. But from the above log, I can clearly see that an endpoint is uniquely identified by namespace, service name and port name, which is exactly what I have in the WSDLs of both the service assemblies.
So the solution is : simple, have separate WSDLs for each service assembly with unique service name and port name. After I renamed the service name and port name in the common EJB’s wsdl, the problem is solved.
One additional note. I think this same problem will occur even when we try to reuse a common Service Assembly. The solution is same, use separate wsdl for each service assembly and have unique service name and port name.