[ 
https://issues.apache.org/jira/browse/CXF-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12852110#action_12852110
 ] 

Sergey Beryozkin commented on CXF-2741:
---------------------------------------

hi, one good thing which has come out of this discussion is that a key for a 
classContexts map will get changed to a String (class name) :-)

but the hang thing is a strange thing indeed...Now, perhaps another thing to 
try is to get rid of the code which tries to get a package context (provided 
you don't need a package context and if you do then may be try to temporarily 
add required JAXB annotations to JAXB beans) and see if the problem has 
something to do with a JAXBContext creating a new package context; so if after 
removing that code no hung occurs then the problem could be narrowed down 
further. In fact, if you do not need a package context then you could just have 
a code there which attempts to create a package context but does not attempts 
to put in a map, just

synchronized (this) {
try {
                    JAXBContext.newInstance(packageName, type.getClassLoader(), 
cProperties);
                 } catch (JAXBException ex) {
                 }

} 

cheers, Sergey

> JAXB hang on JBoss 5.1.0
> ------------------------
>
>                 Key: CXF-2741
>                 URL: https://issues.apache.org/jira/browse/CXF-2741
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.2.6
>         Environment: JBoss 5.1.0.GA, Spring 2.5.6, javax.ws.rs.jsr311-api 1.1
>            Reporter: Jeffrey Poore
>
> We have been using CXF RESTFul services for a long time on jboss-4.2.3 with 
> no issues. When we switched to JBoss 5.1.0.GA, things worked fine at first, 
> but we noticed that after a short period of uptime, requests began to hang 
> and time out. Debugging this issue, we tracked it to the synchronized block 
> in AbstractJAXBProvider.java:
> {code}
> JAXBElementProvider(AbstractJAXBProvider).getPackageContext(Class<?>) line: 
> 377       
> JAXBElementProvider(AbstractJAXBProvider).getJAXBContext(Class<?>, Type) 
> line: 354    
> JAXBElementProvider(AbstractJAXBProvider).createMarshaller(Object, Class<?>, 
> Type, String) line: 453  
> JAXBElementProvider.marshal(Object, Class<?>, Type, String, OutputStream, 
> MediaType) line: 296        
> JAXBElementProvider.writeTo(Object, Class<?>, Type, Annotation[], MediaType, 
> MultivaluedMap<String,Object>, OutputStream) line: 219   
> JAXRSOutInterceptor.serializeMessage(Message, Response, 
> OperationResourceInfo, boolean) line: 241     
> JAXRSOutInterceptor.processResponse(Message) line: 138        
> JAXRSOutInterceptor.handleMessage(Message) line: 77   
> PhaseInterceptorChain.doIntercept(Message) line: 243  
> OutgoingChainInterceptor.handleMessage(Message) line: 76      
> PhaseInterceptorChain.doIntercept(Message) line: 243  
> ChainInitiationObserver.onMessage(Message) line: 109  
> ServletDestination.invoke(ServletConfig, ServletContext, HttpServletRequest, 
> HttpServletResponse) line: 98    
> ServletController.invokeDestination(HttpServletRequest, HttpServletResponse, 
> ServletDestination) line: 406    
> ServletController.invoke(HttpServletRequest, HttpServletResponse) line: 139   
> CXFServlet(AbstractCXFServlet).invoke(HttpServletRequest, 
> HttpServletResponse) line: 142      
> CXFServlet(AbstractHTTPServlet).handleRequest(HttpServletRequest, 
> HttpServletResponse) line: 179      
> CXFServlet(AbstractHTTPServlet).doGet(HttpServletRequest, 
> HttpServletResponse) line: 108      
> CXFServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) 
> line: 617    
> CXFServlet(AbstractHTTPServlet).service(ServletRequest, ServletResponse) 
> line: 159    
> ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) 
> line: 290    
> ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206    
> ReplyHeaderFilter.doFilter(ServletRequest, ServletResponse, FilterChain) 
> line: 96     
> ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) 
> line: 235    
> ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206    
> StandardWrapperValve.invoke(Request, Response) line: 235      
> StandardContextValve.invoke(Request, Response) line: 191      
> SecurityAssociationValve.invoke(Request, Response) line: 190  
> JaccContextValve.invoke(Request, Response) line: 92   
> SecurityContextEstablishmentValve.process(Request, Response, HttpEvent) line: 
> 126     
> SecurityContextEstablishmentValve.invoke(Request, Response) line: 70  
> StandardHostValve.invoke(Request, Response) line: 127 
> ErrorReportValve.invoke(Request, Response) line: 102  
> CachedConnectionValve.invoke(Request, Response) line: 158     
> StandardEngineValve.invoke(Request, Response) line: 109       
> CoyoteAdapter.service(Request, Response) line: 330    
> Http11Processor.process(Socket) line: 829     
> Http11Protocol$Http11ConnectionHandler.process(Socket) line: 598      
> JIoEndpoint$Worker.run() line: 447    
> Thread.run() line: 619        
> {code}
> Specifically, this method:
> {code}
> public JAXBContext getPackageContext(Class<?> type) {
>         if (type == null || type == JAXBElement.class) {
>             return null;
>         }
>         synchronized (packageContexts) {
>             String packageName = PackageUtils.getPackageName(type);
>             JAXBContext context = packageContexts.get(packageName);
>             if (context == null) {
>                 try {
>                     context = JAXBContext.newInstance(packageName, 
> type.getClassLoader(), cProperties);
>                     packageContexts.put(packageName, context);
>                 } catch (JAXBException ex) {
>                     LOG.fine("Error creating a JAXBContext using 
> ObjectFactory : " 
>                                 + ex.getMessage());
>                     return null;
>                 }
>             }
>             return context;
>         }
>     }
> {code}
> It appears that something is holding on to the synchronized lock on 
> packageContexts and thus calls just block. Any help on this would be 
> appreciated.
> We are just trying to call a simple CXF service that uses JSR-311 annotated 
> methods and uses JAXB as the data binding. The class and method being called 
> look like this:
> {code}
> @Path("/LDAP/")
> public class LdapServicesImpl implements LdapServices {
>     @GET
>     @Path("/lookup/")
>     @Produces("text/xml")
>     @Override
>     public SearchResult lookupUser(@Context UriInfo ui) {
>         String userid = ui.getQueryParameters().getFirst("uid");
>         SearchResult result = getLDAPInfo(userid);
>         ...
>         return result;
> }
> {code}
> SearchResult is our JAXB annotated class:
> {code}
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "SearchResult", namespace = "urn:ldap", propOrder = {
>     "ldapUsers",
>     "error"
> })
> @XmlRootElement(name = "searchResult", namespace = "urn:ldap")
> public class SearchResult
>     implements Serializable
> {
>     private final static long serialVersionUID = 987654321L;
>     @XmlElement(namespace = "urn:ldap")
>     protected LdapUsers ldapUsers;
>     @XmlElement(namespace = "urn:ldap")
>     protected String error;
>     ... getters and setters ...
> }
> LdapUsers:
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "LdapUsers", namespace = "urn:ldap", propOrder = {
>     "ldapUsers"
> })
> public class LdapUsers
>     implements Serializable
> {
>     private final static long serialVersionUID = 987654321L;
>     @XmlElement(name = "ldapUser", namespace = "urn:ldap")
>     protected List<LdapUser> ldapUsers;
>     ... getters and setters ...
> }
> LdapUser:
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "LdapUser", namespace = "urn:ldap", propOrder = {
>     "id",
>     "fullName",
>     "firstName",
>     "middleName",
>     "lastName",
>     "address",
>     "city",
>     "state",
>     "zip",
>     "entityCode",
>     "telephone",
>     "title",
>     "dn",
>     "mail",
>     "emsrowid",
>     "community",
>     "objectClasses",
>     "groups"
> })
> public class LdapUser
>     implements Serializable
> {
>     private final static long serialVersionUID = 987654321L;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String id;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String fullName;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String firstName;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String middleName;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String lastName;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String address;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String city;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String state;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String zip;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String entityCode;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String telephone;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String title;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String dn;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String mail;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String emsrowid;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected String community;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected ObjectClasses objectClasses;
>     @XmlElement(namespace = "urn:ldap", required = true)
>     protected Groups groups;
>     ... getters and setters ...
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to