Return-Path: X-Original-To: apmail-axis-java-dev-archive@www.apache.org Delivered-To: apmail-axis-java-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 27399199FC for ; Mon, 14 Mar 2016 08:50:34 +0000 (UTC) Received: (qmail 4318 invoked by uid 500); 14 Mar 2016 08:50:33 -0000 Delivered-To: apmail-axis-java-dev-archive@axis.apache.org Received: (qmail 4178 invoked by uid 500); 14 Mar 2016 08:50:33 -0000 Mailing-List: contact java-dev-help@axis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@axis.apache.org Delivered-To: mailing list java-dev@axis.apache.org Received: (qmail 4168 invoked by uid 99); 14 Mar 2016 08:50:33 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Mar 2016 08:50:33 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 6E1D92C14F4 for ; Mon, 14 Mar 2016 08:50:33 +0000 (UTC) Date: Mon, 14 Mar 2016 08:50:33 +0000 (UTC) From: =?utf-8?Q?Thorsten_Sch=C3=B6ning_=28JIRA=29?= To: java-dev@axis.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AXIS2-5745) Changing a service name doesn't update its TypeTable struct MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AXIS2-5745?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1519= 2927#comment-15192927 ]=20 Thorsten Sch=C3=B6ning commented on AXIS2-5745: ------------------------------------------ The version 1.6.2 I'm currently using doesn't even compile with my 1.7 or 1= .8 JDKs, 1.7.1 ended with some failing tests and the same with trunk, but d= ifferent tests. I'll provide bug reports for the latter, because 1.6.2 is r= eally old, but I simply lack the time to have a more detailed look into thi= s. > Changing a service name doesn't update its TypeTable struct > ----------------------------------------------------------- > > Key: AXIS2-5745 > URL: https://issues.apache.org/jira/browse/AXIS2-5745 > Project: Axis2 > Issue Type: Bug > Components: kernel > Affects Versions: 1.6.2 > Environment: Windows 8.1 x86-64, Tomcat 7.0.68 x86-64 > Reporter: Thorsten Sch=C3=B6ning > Attachments: WsAxis2SvcLc.java > > > I have an implementation of ServiceLifeCycle in which I'm overriding star= tUp and change the name of my service in some special way to make my deploy= ment easier. I'm simply implementing some kind of mandator mechanism based = on exploded services and their unique name in the file system. > This worked pretty fine the last years, but today I encountered that Axis= 2 is handling structures internally in which the service name is used as so= me component of a key. Those structures were built before startUp was calle= d and were not updated on a changed service name. My service generated an e= xception for some reason, Axis2 tried to handle that and failed itself with= a NPE, which made debugging pretty hard of course because the original exc= eption was lost. > The NPE was thrown in the following line 183 of RPCMessageReceiver and th= e not up to date structure was TypeTable for the service, that's why elemen= tQName was null instead of a valid object. Gladly I was able to access that= map in my ServiceLifeCycle implementation and update the generated keys an= d QNames with my new updated service name. I would have expected that if I'= m able to change the service name, structs containing it would get updated = automatically by Axis 2, which at least for TypeTable currently isn't the c= ase. > {CODE} > 175 Class[] exceptionTypes =3D method.getExceptionTypes(); > 176 for (Class exceptionType : exceptionTypes){ > 177 if (exceptionType.getName().equals(cause.getClass().ge= tName())){ > 178 // this is an bussiness logic exception so handle = it properly > 179 String partQName =3D inMessage.getAxisService().ge= tName() + getSimpleClassName(exceptionType); > 180 TypeTable typeTable =3D inMessage.getAxisService()= .getTypeTable(); > 181 QName elementQName =3D typeTable.getQNamefortheTyp= e(partQName); > 182 SOAPFactory fac =3D getSOAPFactory(inMessage); > 183 OMElement exceptionElement =3D fac.createOMElement= (elementQName); > 184 > 185 if (exceptionType.getName().equals(Exception.class= .getName())){ > 186 // this is an exception class. so create a ele= ment by hand and add the message > 187 OMElement innterExceptionElement =3D fac.create= OMElement(elementQName); > 188 OMElement messageElement =3D fac.createOMElemen= t("Message", inMessage.getAxisService().getTargetNamespace(), null); > 189 messageElement.setText(cause.getMessage()); > {CODE} > http://grepcode.com/file/repo1.maven.org/maven2/org.apache.axis2/axis2-ad= b/1.6.2/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java/#183 > I'm currently unable to build Axis2 from src and am not sure where one wo= uld implement such a change, therefore can't provide patches, but instead I= 'll simply post my implemantation of the change for TypeTable in my Service= LifeCycle. In my case, TypeTable contained the following data for my old se= rvice name "SoapAuth": > {CODE} > complexTypeMap HashMap (id=3D165) > {java.sql=3D{http://sql.java/xsd}SQLException, SoapAuthSecurityException= =3D{http://soap.ws.clients.backend.docs.docsrv.am_soft.de}SoapAuthSecurityE= xception, java.sql.SQLException=3D{http://sql.java/xsd}SQLException, logout= =3D{http://soap.ws.clients.backend.docs.docsrv.am_soft.de}logout, java.io= =3D{http://io.java/xsd}FileNotFoundException, SoapAuthSQLException=3D{http:= //soap.ws.clients.backend.docs.docsrv.am_soft.de}SoapAuthSQLException, cook= ieAbgleich=3D{http://soap.ws.clients.backend.docs.docsrv.am_soft.de}cookieA= bgleich, SoapAuthClassNotFoundException=3D{http://soap.ws.clients.backend.d= ocs.docsrv.am_soft.de}SoapAuthClassNotFoundException, SoapAuthFileNotFoundE= xception=3D{http://soap.ws.clients.backend.docs.docsrv.am_soft.de}SoapAuthF= ileNotFoundException, java.io.IOException=3D{http://io.java/xsd}IOException= , SoapAuthIOException=3D{http://soap.ws.clients.backend.docs.docsrv.am_soft= .de}SoapAuthIOException, java.io.FileNotFoundException=3D{http://io.java/xs= d}FileNotFoundException} > {CODE} > My LifeCycle changes the name from "SoapAuth" to "de.am_soft.docsrv.docs.= backend.SoapAuth" and therefore I simply rename all entries with the wrong = service name, remove them and put new ones in. > {CODE} > private void updateSvcTypeTable(AxisService=09service, > =09=09=09=09=09=09=09=09String=09=09oldSvcName, > =09=09=09=09=09=09=09=09String=09=09newSvcName) > { > =09TypeTable=09=09=09tt=09=09=09=09=3D service.getTypeTable(); > =09@SuppressWarnings("unchecked") > =09Map=09schemaMap=09=09=3D tt.getComplexSchemaMap(); > =09Map=09addSchemaMap=09=3D new HashMap(sch= emaMap.size()); > =09for (Iterator>=09it =3D schemaMap.entrySet().iter= ator(); > =09=09=09=09=09=09=09=09=09=09it.hasNext(); ) > =09{ > =09=09Entry=09entry=09=3D it.next(); > =09=09String=09=09=09=09=09key=09=09=3D entry.getKey(); > =09=09QName=09=09=09=09=09value=09=3D entry.getValue(); > =09=09if (!key.startsWith(oldSvcName)) > =09=09{ > =09=09=09continue; > =09=09} > =09=09String newKeyRegExp=09=09=3D String.format("^\\Q%s\\E", oldSvcName)= ; > =09=09String newValueRegExp=09=3D String.format("}\\Q%s\\E", oldSvcName); > =09=09String newKey=09=09=09=3D key.replaceFirst(newKeyRegExp, newSvcName= ); > =09=09String newValue=09=09=09=3D value.toString().replaceFirst(newValueR= egExp, "}".concat(newSvcName)); > =09=09addSchemaMap.put(newKey, QName.valueOf(newValue)); > =09=09it.remove(); > =09} > =09schemaMap.putAll(addSchemaMap); > } > {CODE} > {CODE} > private void changeSvcName(AxisService service) > { > =09logger.trace("Start: {}", service.getName()); > =09File=09configDir=09=3D this.getConfigDir(service); > =09File=09svcDir=09=09=3D configDir.getParentFile().getParentFile(); > =09String=09oldSvcName=09=3D service.getName(); > =09String=09newSvcName=09=3D svcDir.getName().concat(".").concat(oldSvcNa= me); > =09service.setName(newSvcName); > =09this.updateSvcTypeTable(service, oldSvcName, newSvcName); > =09logger.trace("End: {}", service.getName()); > } > {CODE} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org For additional commands, e-mail: java-dev-help@axis.apache.org