[Javassist Development] New message: "ScopedClassPoolRepositoryImpl and default ClassPool"
by Flavia Rainone
User development,
A new message was posted in the thread "ScopedClassPoolRepositoryImpl and default ClassPool":
http://community.jboss.org/message/524465#524465
Author : Flavia Rainone
Profile : http://community.jboss.org/people/flavia.rainone@jboss.com
Message:
--------------------------------------------------------------
While trying to fix the JBoss AOP + AS tests with the new jboss-classpool project, I bumped into a https://jira.jboss.org/jira/browse/JBREFLECT-94 involving ScopedClassPoolRepositoryImpl and DefaultClassPool.
Our factories were using DefaultClassPool to represent null class loaders so that bootstrap classes could be loaded without duplicates. This turned out to be a problem because we were seeing duplicates of JBoss normal classes. Take a look at this example:
-> BaseClassLoader vfsfile:xxx/server/all/conf/jboss-service.xml belongs to DefaultDomain.
When this ClassLoader is requested to load class org.jboss.jms.client.container.StateCreationAspect, it will delegate to DefaultDomain, which will in turn find the original BaseClassLoader as a candidate to load that class. That BaseClassLoader loads the class and the result is returned.
When this example is ported to ClassPool-level, we get a CNFException. The reason for this is that the BaseClassPool vfsfile:xxx/server/all/conf/jboss-service.xml has a parent that can find the resource that contains the requested class:
public class TranslatableClassLoaderIsLocalResourcePlugin extends AbstractIsLocalResourcePlugin
{
public boolean isMyResource(String resourceName)
{
ClassLoader loader = getPool().getClassLoader();
if (loader instanceof Translatable == false)
{
throw new IllegalStateException("ClassLoader of pool " + getPool() + " is not instance of Translatable " + loader);
}
URL url = ((Translatable)getPool().getClassLoader()).getResourceLocally(resourceName);
if (url == null)
{
return false;
}
RETURNS TRUE -----> if (isSameInParent(resourceName, url))
{
return false;
}
return true;
}
}
This is isSameInParent implementation:
protected boolean isSameInParent(String classResourceName, URL foundURL)
{
ClassPool parent = pool.getParent();
if (parent != null)
{
ClassLoader parentLoader = parent.getClassLoader();
URL parentURL = parentLoader.getResource(classResourceName);
if (parentURL == null)
{
return false;
}
URI parentURI = URI.create(parentURL.toString());
URI foundURI = URI.create(foundURL.toString());
if (parentURI.equals(foundURI))
{
return true;
}
}
return false;
}
And ClassPool.getClassLoader implementation:
public ClassLoader getClassLoader()
{
return getContextClassLoader();
}
In the given example, getClassLoader will return the BaseClassLoader for AOP module, which can of course find the requested resource, even though it shouldn't.
Another problem I had is that ScopedClassPoolRepositoryImpl edits the classpath of the DefaultClassPool:
private ScopedClassPoolRepositoryImpl {
classpool = ClassPool.getDefault();
// FIXME This doesn't look correct
ClassLoader cl = Thread.currentThread().getContextClassLoader();
classpool.insertClassPath(new LoaderClassPath(cl));
}
This is similar to the problem explained above, and makes this class pool capable of loading classes that other classpools should be responsible to load. As a result, we get duplicates of the same CtClass. Its FIXME tells me that this was already spotted before as a possible bug.
I worked around this issue by replacing the usage of the Default ClassPool by this Singleton class:
public class SystemClassPool extends ClassPool
{
private SystemClassPool()
{
super(null);
appendSystemPath();
}
@Override
public ClassLoader getClassLoader()
{
return ClassLoader.getSystemClassLoader();
}
}
Equally to DefaultClassPool, it has the SystemPath appended, but its getClassLoader method returns the SystemClassLoader, which is the closest I can get to Bootstrap class loader (take a look at the http://java.sun.com/javase/7/docs/api/java/lang/ClassLoader.html#getResou... for more on this).
That didn't solve my problem entirely, because ScopedClassPoolRepositoryImpl has its own “default” classpool field:
public class ScopedClassPoolRepositoryImpl implements ScopedClassPoolRepository {
/** The default class pool */
protected ClassPool classpool;
/** The factory for creating class pools */
protected ScopedClassPoolFactory factory = new ScopedClassPoolFactoryImpl();
/**
* Get the instance.
*
* @return the instance.
*/
public static ScopedClassPoolRepository getInstance() {
return instance;
}
/**
* Singleton.
*/
private ScopedClassPoolRepositoryImpl() {
classpool = ClassPool.getDefault();
// FIXME This doesn't look correct
ClassLoader cl = Thread.currentThread().getContextClassLoader();
classpool.insertClassPath(new LoaderClassPath(cl));
}
...
}
Differently from what one may have thought, the ClassPoolRepository class (from jboss-classpool project) is not a subclass of ScopedClassPoolRepositoryImpl, given this class cannot be subclassed. This has been an issue for me before, because I always thought my code would be much cleaner if I could extend ScopedClassPoolRepositoryImpl instead of http://anonsvn.jboss.org/repos/jbossas/projects/jboss-classpool/trunk/cla....
So, what should be done in this regard? I'm opening this thread se we can find an elegant solution to my problem. Should ScopedClassPoolRepository be singleton? Should we use ScopedClassPoolFactory at all (the problem with not doing that is that we will have duplicate code in both classes)? I know that ScopedClassPool and auxiliary classes have been created to be used as the ClassPool solution to AS, but so many things have changed ever since that this solution is far from being complete, and that's why we need jboss-classpool now. So now, I'm not even sure what to do of that.
Regarding ClassPool.getClassLoader()'s implementation, I don't think it is a bug, even though we are not using this implementation at all (ScopedClassPool overwrites it, and so does the new SystemClassPool class). I just think that it is a way of doing things that works with simple standalone scenarios, but that doesnot fulfill our needs with AS.
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/524465#524465
16 years, 5 months
[jBPM] New message: "Re: When will the Spring Integration be fixed"
by Ronald van Kuijk
User development,
A new message was posted in the thread "When will the Spring Integration be fixed":
http://community.jboss.org/message/524464#524464
Author : Ronald van Kuijk
Profile : http://community.jboss.org/people/kukeltje
Message:
--------------------------------------------------------------
Robert,
What will be implemented when is in the jira. There even was a short post on this recently:
http://community.jboss.org/thread/147624
Prioritization is done based on things like (in no particular order) number of votes, (paying) customer request, personal preference, liking someone who asks to fix something, external contributions (afaik, 70%-80% of spring in jBPM4 was externally contributed), etc...
One of the quickest ways to get things fixed is to help out...I explicitly do not say fix it your self, since just helping explicitly pinpointing where it is (like Tom requested in one of the previous spring related posts) could also help save time...
Regards,
Ronald
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/524464#524464
16 years, 5 months
[JBoss Web Services Development] New message: "Help with Returning a web service client."
by Alan Terriaga
User development,
A new message was posted in the thread "Help with Returning a web service client.":
http://community.jboss.org/message/524462#524462
Author : Alan Terriaga
Profile : http://community.jboss.org/people/alan_rocket
Message:
--------------------------------------------------------------
Hi guys Im using Axis framework and I'm getting a lot of problems with it. But the most one that Im not able to solve is this:
I hava an interface:
**public
**
*
* public* EstabComercialVO[] consultaEstabComercial( String codigo, String nome );
}
And I have the class which implements.
@Remote
(CasEstabComercialRemote.class)
@Stateless
@WebService
(name = "CasEstabComercial", targetNamespace = "http://www.cas.csu.com.br/CasEstabComercial", serviceName="CasEstabComercialService", portName="CasEstabComercial")
@SOAPBinding
(style = SOAPBinding.Style.RPC)
public
private static Logger log = Logger.getLogger(CasEstabComercial.class);
@WebMethod(operationName="consultaEstabComercial")
@WebResult(name="lista" )
public EstabComercialVO[] consultaEstabComercial( @WebParam(name="codigo") String codigo, @WebParam(name="nome") String nome ) {
BasicConfigurator.configure();
EstabComercialDAO dao =
new EstabComercialDAO(); List<EstabComercialVO> lista =
null; EstabComercialVO[] array =
null;
try{
EstabComercialVO vo = new EstabComercialVO(); vo.setCodEstabelecimento( codigo );
vo.setNomeEstabelecimento( nome );
lista = dao.consultaEstabComercial(vo);
int cont = 0; array =
new EstabComercialVO[lista.size()];
for( EstabComercialVO voLista : lista ){ array[cont] = voLista;
cont++;
}
}
catch (DAOException e) { e.printStackTrace();
}
return array;}
}
class CasEstabComercial implements CasEstabComercialRemote{
With that I could generate the follow WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="CasEstabComercialService" targetNamespace="http://www.cas.csu.com.br/CasEstabComercial" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.cas.csu.com.br/CasEstabComercial" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xs:schema targetNamespace="http://www.cas.csu.com.br/CasEstabComercial" version="1.0" xmlns:tns="http://www.cas.csu.com.br/CasEstabComercial" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="estabComercialVO">
<xs:sequence>
<xs:element minOccurs="0" name="cep" type="xs:string"/>
<xs:element minOccurs="0" name="cgcEstabelecimento" type="xs:string"/>
<xs:element minOccurs="0" name="codAdquirente" type="xs:string"/>
<xs:element minOccurs="0" name="codBloqueio" type="xs:string"/>
<xs:element minOccurs="0" name="codBloqueioMbs" type="xs:string"/>
<xs:element minOccurs="0" name="codEstabelecimento" type="xs:string"/>
<xs:element minOccurs="0" name="codRegiao" type="xs:string"/>
<xs:element minOccurs="0" name="codStatus" type="xs:string"/>
<xs:element minOccurs="0" name="comEndereco" type="xs:string"/>
<xs:element minOccurs="0" name="dataUltExtracao" type="xs:string"/>
<xs:element minOccurs="0" name="endEstabelecimento" type="xs:string"/>
<xs:element minOccurs="0" name="extracao" type="xs:string"/>
<xs:element minOccurs="0" name="nomeBairro" type="xs:string"/>
<xs:element minOccurs="0" name="nomeContato" type="xs:string"/>
<xs:element minOccurs="0" name="nomeEstabelecimento" type="xs:string"/>
<xs:element minOccurs="0" name="numeroEndereco" type="xs:string"/>
<xs:element minOccurs="0" name="telefone" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType final="#all" name="estabComercialVOArray">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="tns:estabComercialVO"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name="CasEstabComercial_consultaEstabComercial">
<part name="codigo" type="xsd:string">
</part>
<part name="nome" type="xsd:string">
</part>
</message>
<message name="CasEstabComercial_consultaEstabComercialResponse">
<part name="lista" type="tns:estabComercialVOArray">
</part>
</message>
<portType name="CasEstabComercial">
<operation name="consultaEstabComercial" parameterOrder="codigo nome">
<input message="tns:CasEstabComercial_consultaEstabComercial">
</input>
<output message="tns:CasEstabComercial_consultaEstabComercialResponse">
</output>
</operation>
</portType>
<binding name="CasEstabComercialBinding" type="tns:CasEstabComercial">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="consultaEstabComercial">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://www.cas.csu.com.br/CasEstabComercial"/>
</input>
<output>
<soap:body use="literal" namespace="http://www.cas.csu.com.br/CasEstabComercial"/>
</output>
</operation>
</binding>
<service name="CasEstabComercialService">
<port name="CasEstabComercial" binding="tns:CasEstabComercialBinding">
<soap:address location="http://127.0.0.1:8080/casWS/CasEstabComercial"/>
</port>
</service>
</definitions>
Now the problem is when I try to call the webservice.
Follow is my client class.
String XSD =
"http://www.w3.org/2001/XMLSchema";String urlService =
"http://www.cas.csu.com.br/CasEstabComercial";String nameService =
"CasEstabComercialService";String endPoint =
http://localhost:8080/casWS/CasEstabComercial?wsdl;
try{ QName qname =
new QName(urlService);
ServiceFactory serviceFactory = ServiceFactory.newInstance();
javax.xml.rpc.Service service = serviceFactory.createService(qname);
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endPoint);
// OPERATION
QName operationName = new QName(urlService, "consultaEstabComercial"); call.setOperationName(operationName);
// REQUEST
QName qParametroString = new QName(XSD, "string"); call.addParameter(
"codigo", qParametroString, ParameterMode.IN ); call.addParameter(
"nome", qParametroString, ParameterMode.IN );
// RESPONSE
QName qReturn = new QName("http://www.cas.csu.com.br/CasEstabComercial", "estabComercialVOArray"); call.setReturnType(qReturn);
call.setReturnQName(
new QName("", "lista"));
call.registerTypeMapping( EstabComercialVO.
class, qReturn,
new ArraySerializerFactory(),
new ArrayDeserializerFactory() );
// Setting parameters
EstabComercialVO voEntrada =
new EstabComercialVO(); voEntrada.setCodEstabelecimento(
"1"); String codigo =
"1"; String nome =
"";
Object[] entrada =
new Object[]{ codigo, nome };
EstabComercialVO[] array = (EstabComercialVO[]) call.invoke(entrada);
System.out.println("SIZE: " + array.length);
}
catch( Exception ex ){ex.printStackTrace();
}
My service can start and execute an operatioin in my database without problems, but when comes the time to fill the response:
Now after trying many possibilites in the method "registerTypeMapping" I'm getting the follow exception:
17:07:06,858 INFO [STDOUT] 156915 [http-127.0.0.1-8080-3] DEBUG br.com.csu.casWS.test.TestIBatis - carregando arquivo sql ibatis br/com/csu/casWS/config/SqlMapConfig_casDSS.xml
17:07:07,427 INFO [STDOUT] 157487 [http-127.0.0.1-8080-3] INFO br.com.csu.casWS.service.CasEstabComercial - Consulta no banco os estabelecimentos comerciais.
17:07:07,428 INFO [STDOUT] 157488 [http-127.0.0.1-8080-3] DEBUG br.com.csu.casWS.test.TestIBatis - select na tabela estbmto
17:07:10,547 INFO [STDOUT] 160607 [http-127.0.0.1-8080-3] DEBUG com.ibatis.common.jdbc.SimpleDataSource - Created connection 5686307.
17:07:10,556 INFO [STDOUT] 160616 [http-127.0.0.1-8080-3] DEBUG java.sql.Connection - {conn-100000} Connection
17:07:10,573 INFO [STDOUT] 160633 [http-127.0.0.1-8080-3] DEBUG java.sql.Connection - {conn-100000} Preparing Statement: select COD_ADQUIRENTE, COD_ESTBMTO, COD_REGIAO, NOM_ESTBMTO, END_ESTBMTO, NUM_ENDERECO, COM_ENDERECO, NOM_BAIRRO, CEP, TEL_CONTATO, NOM_CONTATO, CGC_ESTBMTO, COD_BLOQUEIO, COD_STATUS, COD_BLOQUEIO_MBS, FLG_EXTRACAO, DAT_ULT_EXTRACAO from ESTBMTO where COD_ESTBMTO = ?
17:07:10,631 INFO [STDOUT] 160691 [http-127.0.0.1-8080-3] DEBUG java.sql.PreparedStatement - {pstm-100001} Executing Statement: select COD_ADQUIRENTE, COD_ESTBMTO, COD_REGIAO, NOM_ESTBMTO, END_ESTBMTO, NUM_ENDERECO, COM_ENDERECO, NOM_BAIRRO, CEP, TEL_CONTATO, NOM_CONTATO, CGC_ESTBMTO, COD_BLOQUEIO, COD_STATUS, COD_BLOQUEIO_MBS, FLG_EXTRACAO, DAT_ULT_EXTRACAO from ESTBMTO where COD_ESTBMTO = ?
17:07:10,631 INFO [STDOUT] 160691 [http-127.0.0.1-8080-3] DEBUG java.sql.PreparedStatement - {pstm-100001} Parameters: [1]
17:07:10,631 INFO [STDOUT] 160691 [http-127.0.0.1-8080-3] DEBUG java.sql.PreparedStatement - {pstm-100001} Types: [java.lang.String]
17:07:10,638 INFO [STDOUT] 160698 [http-127.0.0.1-8080-3] DEBUG java.sql.ResultSet - {rset-100002} ResultSet
17:07:10,650 INFO [STDOUT] 160710 [http-127.0.0.1-8080-3] DEBUG java.sql.ResultSet - {rset-100002} Header: [COD_ADQUIRENTE, COD_ESTBMTO, COD_REGIAO, NOM_ESTBMTO, END_ESTBMTO, NUM_ENDERECO, COM_ENDERECO, NOM_BAIRRO, CEP, TEL_CONTATO, NOM_CONTATO, CGC_ESTBMTO, COD_BLOQUEIO, COD_STATUS, COD_BLOQUEIO_MBS, FLG_EXTRACAO, DAT_ULT_EXTRACAO]
17:07:10,651 INFO [STDOUT] 160710 [http-127.0.0.1-8080-3] DEBUG java.sql.ResultSet - {rset-100002} Result: [1, 1, 7627, teste loja 1, endereco 1, 1, comp 1, bairro 1, 11111111, 1112345678, contato 1, cgc 1, null, 1, null, null, null]
17:07:10,659 INFO [STDOUT] 160718 [http-127.0.0.1-8080-3] DEBUG com.ibatis.common.jdbc.SimpleDataSource - Returned connection 5686307 to pool.
17:07:10,845 ERROR [Call] Exception:
org.xml.sax.SAXException
SimpleDeserializer.java:145)at org.apache.axis.encoding.DeserializationContext.startElement(
DeserializationContext.java:1035)at org.apache.axis.message.SAX2EventRecorder.replay(
SAX2EventRecorder.java:165)at org.apache.axis.message.MessageElement.publishToHandler(
MessageElement.java:1141)at org.apache.axis.message.RPCElement.deserialize(
RPCElement.java:236)at org.apache.axis.message.RPCElement.getParams(
RPCElement.java:384)at org.apache.axis.client.Call.invoke(
Call.java:2467)at org.apache.axis.client.Call.invoke(
Call.java:2366)at org.apache.axis.client.Call.invoke(
Call.java:1812)at br.com.csu.cas.presentation.action.cadastros.EstabComercialAction.teste(
EstabComercialAction.java:127)at br.com.csu.cas.presentation.action.cadastros.EstabComercialAction.consulta(
EstabComercialAction.java:62)at sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(
Method.java:597)at org.apache.struts.actions.DispatchAction.dispatchMethod(
DispatchAction.java:276)at org.apache.struts.actions.DispatchAction.execute(
DispatchAction.java:196)at org.apache.struts.action.RequestProcessor.processActionPerform(
RequestProcessor.java:421)at org.apache.struts.action.RequestProcessor.process(
RequestProcessor.java:226)at org.apache.struts.action.ActionServlet.process(
ActionServlet.java:1164)at org.apache.struts.action.ActionServlet.doGet(
ActionServlet.java:397)at javax.servlet.http.HttpServlet.service(
HttpServlet.java:617)at javax.servlet.http.HttpServlet.service(
HttpServlet.java:717)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:290)at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
ReplyHeaderFilter.java:96)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:235)at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:235)at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:191)at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(
SecurityAssociationValve.java:190)at org.jboss.web.tomcat.security.JaccContextValve.invoke(
JaccContextValve.java:92)at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(
SecurityContextEstablishmentValve.java:126)at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(
SecurityContextEstablishmentValve.java:70)at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:102)at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(
CachedConnectionValve.java:158)at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:330)at org.apache.coyote.http11.Http11Processor.process(
Http11Processor.java:829)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
Http11Protocol.java:598)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(
JIoEndpoint.java:447)at java.lang.Thread.run(
Thread.java:619)17:07:10,855 ERROR [STDERR] AxisFault
faultCode: {
http://schemas.xmlsoap.org/soap/envelope/}Server.userExceptionfaultSubcode:
faultString:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.faultActor:
faultNode:
faultDetail:
: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(
Please I'd like to know what it's going on, or maybe there is other framework better than Axis to create WebServices in my JBoss 4.0.5.
Thanks in advance.
Alan
* *interface* CasEstabComercialRemote *extends* Remote {
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/524462#524462
16 years, 5 months