apache cxf 2.1 with spring 2, maven 2 and eclipse wtp

Apache CXF 2.1 is released. I know XFire since a long time as web service provider. CXF is a merger of XFire with celtix, which provided an enterprise service bus. The main reason for choosing XFire rather then Axis was the WS-I BP compatibility. It’s a better arguing with a commercial eai provider when your webservice is at least WS-I BP 1.0 conform. CXF is JAX-WS 2.1 compatible. You can enable Pojo services with standard annotations as web services. To try that new release out i created with eclipse web tools platform a new dynamic web project with tomcat 6 as web container. First step is to add the libs needed for CXF. Normally i would download by myself the libs and copy it in to Web-inf/lib folder. Disk space is not a problem but you can’t share such projects by mail because of the size needed for the libs. So i use maven 2 to define the needed libs. The pom.xml define the project and its dependencies. Place it in the root of the project:



	4.0.0
	de.schaeftlein.dev
	cxf-sample
	war
	
	
	0.0.1-SNAPSHOT
	
	
	
		
			org.apache.cxf
			cxf-rt-core
			2.1
		
		
			org.apache.cxf
			cxf-rt-frontend-simple
			2.1
		
		
			org.apache.cxf
			cxf-rt-frontend-jaxws
			2.1
		
		
			org.apache.cxf
			cxf-rt-databinding-aegis
			2.1
		
		
			org.apache.cxf
			cxf-rt-transports-local
			2.1
		
		
			org.apache.cxf
			cxf-rt-transports-http
			2.1
		
		
			org.apache.cxf
			cxf-rt-transports-http-jetty
			2.1
		
		
			org.apache.cxf
			cxf-rt-transports-jms
			2.1
		
		
			org.apache.cxf
			cxf-rt-management
			2.1
		
		
			org.apache.cxf
			cxf-common-utilities
			2.1
		
		
			org.mortbay.jetty
			jetty
			6.1.6
		
		
			junit
			junit
			3.8.2
			test
		
		
			org.springframework
			spring
			2.0.8
		
	
	
		
			
				maven-compiler-plugin
				
					1.6
					1.6
				
			
		
		war:install
	


So the libs are defined but nothing happened in eclipse. I use the M2 Eclipse plugin. Now i enable maven with right click on the project and choose from M2 the “Enable dependency management” entry. The plugin now download the libs into the local repository for all projects. In the eclipse build path you will find now a new library called “maven dependencies”. Eclipse WTP does not deploy out of the box this library. Inside the project configuration you will find a section called “j2ee module dependencies”. Just click the check box beside the “maven dependencies” library. Now all dependent libs are deployed as well. As controller act the CXFServlet and for spring need a listener to be defined both in the web.xml:



  cxf-sample
	
		contextConfigLocation
		WEB-INF/beans.xml
	

	
		
			org.springframework.web.context.ContextLoaderListener
		
	

	
		CXFServlet
		
			org.apache.cxf.transport.servlet.CXFServlet
		
		1
	

	
		CXFServlet
		/*
	

I use spring as main configuration tool. CXF depends on spring 2.0.8. The beans.xml imports the default cxf settings and defines the HelloWorld service:

The web service has a interface:

package demo.spring;

import javax.jws.WebService;

@WebService
public interface HelloWorld {
    String sayHi(String text);
}

and a implementation:

package demo.spring;

import javax.jws.WebService;

@WebService(endpointInterface = "demo.spring.HelloWorld")
public class HelloWorldImpl implements HelloWorld {

    public String sayHi(String text) {
        return "Hello " + text;
    }
}

If not set up a local server during creation of the project you need to go to the servers tab in eclipse. Define a new server with server type “Tomcat v6.0 Server”. If the adapter does not appear click on the link to “download additional server adapters”. Under “installed runtime” should be a tomcat 6 server. If not you have to add a new runtime. For tomcat 6 i recommend at least java 1.5 as jre. In the last step you can directly add the created project for cxf. Spring and CXF use commons logging for logging. So i provide in the classpath a simple log4j.xml to output everything interesting to std out:








	
		
			
		
	
	
		
	
	
		
		
	

Setup and implementation are now done. So i started the server inside eclipse. The console should contains lines from spring configuring cxf. To see a list of deployed web services just open a browser to http://localhost:8080/cxf-sample/services, where cxf-sample is the name of your eclipse project. You should see a list of links to the generated wsdl’s of the defined services. Copy the url to the HelloWorldImplPort in the clipboard. For testing i use the free tool soapui which will be started and installed by webstart. Choose under file the point “new wsdl project”. Give it a name and paste the url from the wsdl. Leave the tack for creating sample requests and choose ok. In the tree you see the project, the service, the operations and a request for each operation. Double Click on the only request for our service. Replace the ? with a value of your own inside the arg0 tag and hit the green run button:


   
   
      
         
         
         John Doe
      
   

You should see a response like that on right side of the request in a new window:


   
      
         Hello John Doe
      
   

google that…

More often i heard someone saying “google that” (or in german “google das mal…”). Not that problem with current smart phones or iphone and a mobile flatrate. Short look with opera mini or opera mobile and the discussion can go on. In the IT world is it more important to know where the details are written then to know everything in mind. Everyday start more people surfing the net. You don’t need a drivers license to start using. Normally i would say it’s not necessary, but today i get an reason to have such a entry access check.

Hoax are really old and comes mostly in conjunction with chain mails. On the first look it sounds like good behaviour to forward such help requests. Looking deeper shows trojaner, virus, and other crap contained in that email or in links inside. Not really difficult to determine if a email is a hoax. Just take the subject of the email and google that… Mostly you get in the first ten hits pages about current hoax floating around. The evil does not sleep so these hoax mails become more professional. You get emails about a cancer case with a complete patient address. These address may exists because the writers took the original hoax, translate them in good native language and insert real people. Not a problem to get such data. Not only head hunter use the net to retrieve private information about real people.

Hoax are spam, not more or less.

To have a PC, a DSL connection and a browser does not mean that you are fully prepared for surfing the net. It’s like having a drill machine and you want to make a hole for a screw. You can have luck and hit no cable or pipe. But it can happen to hit. As mention in the adverts “ask someone who knows it” or google that…

jdbc DataBaseMetaData + oracle 10g + dbunit + username..

If you are using DBUnit as tool for set up test environment in your oracle 10g then you have to provide the username of course. Normally it isn’t case sensitive in most tools. The jdbc driver or sqlplus let you create connection with lower case. DBUnit ask the DataBaseMetaData to get the defined tables in the schema. Schema and username are the same in the oracle world. So in DBUnit the source is

DatabaseMetaData databaseMetaData = jdbcConnection.getMetaData();
ResultSet resultSet = databaseMetaData.getTables(null, schema, "%", tableType);

where tableType is the String[] {“table”}. with schema == username lower case i get in my oracle 10.2 db nothing back. With upper case username et voila! Don’t know if this is really an standard behaviour….

JDBC Connection + Oracle 10g + recycle bin…

Since Oracle 10g dropped tables goes into a recycle bin: http://orafaq.com/node/968. These tables aren’t visible inside the admin site under the user but if you are using JDBC to access the schema. Thought first of a bug in SQL Explorer when i saw the huge list of tables starting with BIN$… Every time you drop tables more BIN$ you get… If someone needs such a future… I’m more a friend of the “know what i’m doing’ approach. The good thing is that this is a feature which you can disable:

  1. sqlplus sys/<your password> as sysdba
  2. SQL> purge dba_recyclebin;
  3. SQL> alter system set recyclebin = OFF scope=both;

tech stuff, development news…