isabel
14 years agoNew Contributor
MockServices on Weblogic doesn't works entirely
First of all, I want to thank Alex Forbes and Henrik Olsson for helping me with other issues.
I had some variety of problems using soapUI mock services in weblogic. I'll describe all of them here. The first two I have work arounds but the third is the one I can't figure it out.
I'm using SoapUI 4.0-beta2, Weblogic 10.3 and Tomcat 6.0.32.
1) Logo image in the webui page
When I deployed the war file in the weblogic, the webui page was not showing the logo image. I thought that weird but the mock services using sequence or random dispatchers were responding correctly, just the mock services using groovy script or xpath or query_match were responding the xpath exception.
The same war file was deployed in Tomcat and the webui page showed the logo image.
These are the configurations I was using to generate the war file:

Although I think the war file should have worked, I came up with an work around.
Work around: Tomcat opens the deployed war file in a directory. Weblogic doesn't do that by itself. So, instead of deploying the war file in weblogic I deployed the directory and it worked. The logo image was shown in the webui page correctly (http://10.18.126.2:7001/SATSMocksWar/webui).
These are the configurations I am using to generate only the war directory:

2) Not able to add wsdl from the url
Clicking on the WSDL link (http://10.18.126.2:7001/SATSMocksWar/It ... caoWS?WSDL) in the webui page the wsdl content was shown correctly but when I tried to add the wsdl in a soapUI project I got the following error.
The problem is that I didn't put the schema code insine de the wsdl. Instead, I put an import tag to the xsd file as follow. That problem also happens when using Tomcat.
The schema location should have the contextRoot but it doesn't.
This way it point to a xsd file in (http://10.18.126.2:7001/ItemAlimentacao ... ntacao.xsd) that doesn't exists. The correct url would be (http://10.18.126.2:7001/SATSMocksWar/It ... ntacao.xsd).
Although I think it should work when the wsdl uses imported schemas, I came up with an work around.
Work around: I put all schema code inside the wsdl file, imported it again in soapUI, generated the war directory again and deployed it again. This way I was able to import the wsdl successfully to a project in soapUI.
3) Problem using script, query_match or xpath dispatchers for mock services
This problem is the same reported in viewtopic.php?f=2&t=7470&hilit=weblogic.
I just tried a few things more to try to get it to work but it was impossible.
Mock services using sequence or random dispatchers works fine in weblogic. The problem is when you need to use some other dispatcher that enables getting the value in the request and returning a specific response.
Therefore, I tried to use a groovy script, query_match and xpath. All of them worked in soapUI and Tomcat, but none worked in weblogic.
For xpath I used:
And for groovy script:
Since I used a try/catch the mock service returns the default response configured and shows the exception in the Groovy Log output in the webui page.
The exception I'm getting in groovy log output is:
And in weblogic console shows:
I also put some logs in the groovy script in order to find out what line was giving the exception. It seems it is the line holder.getNodeValue("//item:codigo").
Some other things I tried that didn't work:
1 - Creating an weblogic.xml in WEB-INF
2 - Creating an ear directory with war directory inside
3 - Set Document Builder Factory and SAX parser factory through setDomainEnv and weblogic-application.xml (using ear directory)
4 - Set <prefer-web-inf-classes>true</prefer-web-inf-classes> in weblogic.xml (using war directory)
5 - Put the lib directory in the APP-INF in the ear directory and forced to use javax.jws and org.apache.xerces packages through prefer-application-packages in weblogic-application.xml
6 - Changed the xbean_xpath-2.4.0.jar to a xbean_xpath.jar that I downloaded from xmlbeans (2.4.0) pages
7 - Changed saxon-9.1.0.8j.jar and saxon-dom-9.1.0.8j.jar to saxon-9.0.0.4.jar and saxon-dom-9.0.0.4.jar downloaded from saxon pages.
About item 4, when I did that weblogic returned a ClassCastException for org.apache.xerces.jaxp.DocumentBuilderFactoryImpl when deploying the war directory. I'm not sure but I think I had that same error on item 5.
Conclusion: I believe the problem is in classpath, some jar incompability between the application and weblogic. I'm not really sure.
If you have any ideas how I could have this mock service working I would appreciate your help.
I had some variety of problems using soapUI mock services in weblogic. I'll describe all of them here. The first two I have work arounds but the third is the one I can't figure it out.
I'm using SoapUI 4.0-beta2, Weblogic 10.3 and Tomcat 6.0.32.
1) Logo image in the webui page
When I deployed the war file in the weblogic, the webui page was not showing the logo image. I thought that weird but the mock services using sequence or random dispatchers were responding correctly, just the mock services using groovy script or xpath or query_match were responding the xpath exception.
The same war file was deployed in Tomcat and the webui page showed the logo image.
These are the configurations I was using to generate the war file:
Although I think the war file should have worked, I came up with an work around.
Work around: Tomcat opens the deployed war file in a directory. Weblogic doesn't do that by itself. So, instead of deploying the war file in weblogic I deployed the directory and it worked. The logo image was shown in the webui page correctly (http://10.18.126.2:7001/SATSMocksWar/webui).
These are the configurations I am using to generate only the war directory:
2) Not able to add wsdl from the url
Clicking on the WSDL link (http://10.18.126.2:7001/SATSMocksWar/It ... caoWS?WSDL) in the webui page the wsdl content was shown correctly but when I tried to add the wsdl in a soapUI project I got the following error.
The problem is that I didn't put the schema code insine de the wsdl. Instead, I put an import tag to the xsd file as follow. That problem also happens when using Tomcat.
...
<wsdl:types>
<xsd:schema targetNamespace="http://www.petrobras.com.br/SATS/ItemAlimentacao">
<xsd:import namespace="http://www.petrobras.com.br/SATS/ItemAlimentacao" schemaLocation="/ItemAlimentacaoWS?WSDL&interface=ItemAlimentacaoWSSOAP&part=ItemAlimentacao.xsd"/>
</xsd:schema>
</wsdl:types>
...
The schema location should have the contextRoot but it doesn't.
This way it point to a xsd file in (http://10.18.126.2:7001/ItemAlimentacao ... ntacao.xsd) that doesn't exists. The correct url would be (http://10.18.126.2:7001/SATSMocksWar/It ... ntacao.xsd).
Although I think it should work when the wsdl uses imported schemas, I came up with an work around.
Work around: I put all schema code inside the wsdl file, imported it again in soapUI, generated the war directory again and deployed it again. This way I was able to import the wsdl successfully to a project in soapUI.
3) Problem using script, query_match or xpath dispatchers for mock services
This problem is the same reported in viewtopic.php?f=2&t=7470&hilit=weblogic.
I just tried a few things more to try to get it to work but it was impossible.
Mock services using sequence or random dispatchers works fine in weblogic. The problem is when you need to use some other dispatcher that enables getting the value in the request and returning a specific response.
Therefore, I tried to use a groovy script, query_match and xpath. All of them worked in soapUI and Tomcat, but none worked in weblogic.
For xpath I used:
declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/";
declare namespace item="http://www.petrobras.com.br/SATS/ItemAlimentacao";
//soapenv:Envelope/soapenv:Body/item:getItemAlimentacaoRequest/item:codigo
And for groovy script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
try{
def holder = groovyUtils.getXmlHolder( mockRequest.getRequestContent() )
holder.getNodeValue("//item:codigo")
}catch(all){
log.error("Exception: " + all.getMessage())
}
Since I used a try/catch the mock service returns the default response configured and shows the exception in the Groovy Log output in the webui page.
The exception I'm getting in groovy log output is:
Trying XBeans path engine... Trying XQRL... Trying delegated path engine... FAILED on declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/'; declare namespace item='http://www.petrobras.com.br/SATS/ItemAlimentacao'; //item:codigo
And in weblogic console shows:
13:59:17,655 ERROR [XmlUtils] Error creating XmlOptions; org.apache.xerces.util.
SecurityManager
java.lang.ClassCastException: org.apache.xerces.util.SecurityManager
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setProperty(
XMLEntityManager.java:1714)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.setProp
erty(XML11Configuration.java:914)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setPrope
rty(AbstractSAXParser.java:1941)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.s
etProperty(SAXParserImpl.java:473)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(SAX
ParserImpl.java:263)
at weblogic.xml.jaxp.WebLogicSAXParser.setProperty(WebLogicSAXParser.jav
a:117)
at weblogic.xml.jaxp.RegistrySAXParser.setProperty(RegistrySAXParser.jav
a:113)
at com.eviware.soapui.support.xml.XmlUtils.createDefaultXmlOptions(XmlUt
ils.java:311)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRequest.getRequestXmlObject
(WsdlMockRequest.java:303)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRequest.initPostRequest(Wsd
lMockRequest.java:155)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRequest.<init>(WsdlMockRequ
est.java:107)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(Wsdl
MockRunner.java:378)
at com.eviware.soapui.mockaswar.MockAsWarServlet$MockServletSoapUICore.d
ispatchRequest(MockAsWarServlet.java:242)
at com.eviware.soapui.mockaswar.MockAsWarServlet.service(MockAsWarServle
t.java:179)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run
(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri
tyHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:292)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:3498)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
ervletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
ontext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j
ava:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
I also put some logs in the groovy script in order to find out what line was giving the exception. It seems it is the line holder.getNodeValue("//item:codigo").
Some other things I tried that didn't work:
1 - Creating an weblogic.xml in WEB-INF
2 - Creating an ear directory with war directory inside
3 - Set Document Builder Factory and SAX parser factory through setDomainEnv and weblogic-application.xml (using ear directory)
4 - Set <prefer-web-inf-classes>true</prefer-web-inf-classes> in weblogic.xml (using war directory)
5 - Put the lib directory in the APP-INF in the ear directory and forced to use javax.jws and org.apache.xerces packages through prefer-application-packages in weblogic-application.xml
6 - Changed the xbean_xpath-2.4.0.jar to a xbean_xpath.jar that I downloaded from xmlbeans (2.4.0) pages
7 - Changed saxon-9.1.0.8j.jar and saxon-dom-9.1.0.8j.jar to saxon-9.0.0.4.jar and saxon-dom-9.0.0.4.jar downloaded from saxon pages.
About item 4, when I did that weblogic returned a ClassCastException for org.apache.xerces.jaxp.DocumentBuilderFactoryImpl when deploying the war directory. I'm not sure but I think I had that same error on item 5.
<28/07/2011 14h11min43s BRT> <Warning> <Deployer> <BEA-149004> <Failures were de
tected while initiating deploy task for application 'SATSMocksWar'.>
<28/07/2011 14h11min43s BRT> <Warning> <Deployer> <BEA-149078> <Stack trace for
message 149004
weblogic.application.ModuleException: Failed to load webapp: 'SATSMocksWar'
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:387)
at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedM
oduleDriver.java:176)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(Modu
leListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(Depl
oymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineD
river.java:37)
Truncated. see log file for complete stacktrace
java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderF
actory.java:123)
at com.bea.core.repackaged.springframework.beans.factory.xml.DefaultDocu
mentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:88)
at com.bea.core.repackaged.springframework.beans.factory.xml.DefaultDocu
mentLoader.loadDocument(DefaultDocumentLoader.java:70)
at com.bea.core.repackaged.springframework.beans.factory.xml.XmlBeanDefi
nitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
at com.bea.core.repackaged.springframework.beans.factory.xml.XmlBeanDefi
nitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:340)
Truncated. see log file for complete stacktrace
>
Conclusion: I believe the problem is in classpath, some jar incompability between the application and weblogic. I'm not really sure.
If you have any ideas how I could have this mock service working I would appreciate your help.