aspose file tools*
The moose likes Other Open Source Projects and the fly likes Apache CXF and Properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Apache CXF and Properties file" Watch "Apache CXF and Properties file" New topic
Author

Apache CXF and Properties file

Xuxo Garcia
Greenhorn

Joined: Feb 07, 2012
Posts: 3

Hi!,
First of all, thanks for your patience if you read this post.

I am converting a Java app into web services (Disclaimer: I'm not regularly a developer, only when I need to...) using Apache CXF2 runtime on Eclipse with Tomcat 7. As a bit of background, I will state the structure and what works:

////////////////////////////////////////////////Project structure:////////////////////////////////////////////////////////////
---xami
|_____src
|______com.xami.ws
|________AMIServices.java (<-- class file I am turning into Web Services)
|________ConnMgr.java (<-- JDBC connection manager)
|________ServiceTester.java (<-- sample client for me to test)
|______resources
|________config.properties (Properties file used by ConnMgr.java

////////////////////////////////////////////////ConnMgr.java:////////////////////////////////////////////////////////////



////////////////////////////////////////////////AMIServices.java (EXTRACTED METHOD...NOT WHOLE FILE:////////////////////////////////////////////////////////////




////////////////////////////////////////////////ServiceTester.java (SAMPLE TESTER FOR METHOD ABOVE getMeterStatus():////////////////////////////////////////////////////////////



////////////////////////////////////////////////CORRECT OUTPUT FROM DATABASE AFTER RUNNING ABOVE////////////////////////////////////////////////////////////

Connected to the database
M218907 | 1 | OFFLINE | 0 | 2012-02-22 12:47:04.0
M218900 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218904 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218908 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218905 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218909 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218901 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218910 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218902 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218906 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218903 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218911 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
M218899 | 1 | OFFLINE | 0 | 2012-02-22 09:28:55.0
DONE!

////////////////////////////////////////////////MY PROBLEM:////////////////////////////////////////////////////////////

When I create (in Eclipse) Web Services out of AMIServices.java, I get a WSDL created, I can see the methods, etc but ConnMgr.java is not able to pickup the properties file anymore. Here are the commands that CXF runs:

]java2ws -cp /home/alucarda/dev/workspace/xami/WebContent/WEB-INF/classes -s /home/alucarda/dev/workspace/xami/.cxftmp/src -d /home/alucarda/dev/workspace/xami/.cxftmp/wsdl -classdir /home/alucarda/dev/workspace/xami/WebContent/WEB-INF/classes -o amiservices.wsdl -soap12 -createxsdimports -verbose -frontend jaxws -databinding jaxb -wsdl -wrapperbean com.xami.ws.AMIServices
java2ws - Apache CXF 2.5.2

Feb 22, 2012 12:49:18 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://ws.xami.com/}AMIServicesService from class com.xami.ws.AMIServices
java2ws -cp /home/alucarda/dev/workspace/xami/WebContent/WEB-INF/classes -s /home/alucarda/dev/workspace/xami/.cxftmp/src -d /home/alucarda/dev/workspace/xami/.cxftmp/wsdl -classdir /home/alucarda/dev/workspace/xami/WebContent/WEB-INF/classes -o amiservices.wsdl -createxsdimports -verbose -frontend jaxws -databinding jaxb -wsdl -server -wrapperbean com.xami.ws.AMIServices
java2ws - Apache CXF 2.5.2

Feb 22, 2012 1:02:02 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://ws.xami.com/}AMIServicesService from class com.xami.ws.AMIServices
java2ws -cp /home/alucarda/dev/workspace/xami/WebContent/WEB-INF/classes -s /home/alucarda/dev/workspace/xami/.cxftmp/src -d /home/alucarda/dev/workspace/xami/.cxftmp/wsdl -classdir /home/alucarda/dev/workspace/xami/WebContent/WEB-INF/classes -o amiservices.wsdl -createxsdimports -verbose -frontend jaxws -databinding jaxb -wsdl -wrapperbean com.xami.ws.AMIServices
java2ws - Apache CXF 2.5.2

Feb 22, 2012 1:30:31 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://ws.xami.com/}AMIServicesService from class com.xami.ws.AMI
java2ws -cp /home/alucarda/dev/workspace/xami/WebContent/WEB-INF/classes -s /home/alucarda/dev/workspace/xami/.cxftmp/src -d /home/alucarda/dev/workspace/xami/.cxftmp/wsdl -classdir /home/alucarda/dev/workspace/xami/WebContent/WEB-INF/classes -o amiservices.wsdl -createxsdimports -verbose -frontend jaxws -databinding jaxb -wsdl -wrapperbean com.xami.ws.AMIServices
java2ws - Apache CXF 2.5.2

Feb 22, 2012 2:07:20 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://ws.xami.com/}AMIServicesService from class com.xami.ws.AMIServices



However, when I deploy it. and use SoapUI to request the same getMeterStatus(1), I get:

INFO: Inbound Message
----------------------------
ID: 1
Address: http://localhost:8080/xami/services/AMIServicesPort
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml;charset=UTF-8
Headers: {accept-encoding=[gzip,deflate], Content-Length=[288], content-type=[text/xml;charset=UTF-8], host=[localhost:8080], SOAPAction=["urn:GetMeterStatus"], user-agent=[Jakarta Commons-HttpClient/3.1]}
Payload: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.xami.com/">
<soapenv:Header/>
<soapenv:Body>
<ws:getMeterStatus>
<!--Optional:-->
<arg0>1</arg0>
</ws:getMeterStatus>
</soapenv:Body>
</soapenv:Envelope>
--------------------------------------
Feb 22, 2012 2:11:17 PM com.xami.ws.ConnMgr <init>
SEVERE: resources/config.properties (No such file or directory)
java.io.FileNotFoundException: resources/config.properties (No such file or directory)

at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at com.xami.ws.ConnMgr.<init>(ConnMgr.java:22)

Has anyone seen this using CXF2 with Tomcat? I've been searching for a long long time and no answer. I have moved files around to no avail....Thanks for your patience again in reading this....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Apache CXF and Properties file