Wednesday, November 12, 2008

Could not load driver OracleDriver. Could not get JDBC Connection nested exception is SQLException: No suitable driver

I was working on Spring web services with Axis and I received this strange error related to my c3p0 connections:


java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver [[oracle.jdbc.driver.OracleDriver]]

Could not get JDBC Connection nested exception is SQLException: No suitable driver


It seems this is because my bean was containing some white spaces since I had copied the settings from other project. Here is the correct configuration for c3p0 with Oracle 9i


 <bean id="dataSourceC3PO" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass">
<value>oracle.jdbc.OracleDriver</value>
</property>
<property name="jdbcUrl">
<value>jdbc:oracle:thin:@SERVER:1521:07</value>
</property>
<property name="user">
<value>USERNAME</value>
</property>
<property name="password">
<value>PASSWORD</value>
</property>
<property name="initialPoolSize">
<value>3</value>
</property>
<property name="acquireIncrement">
<value>3</value>
</property>
<property name="minPoolSize">
<value>1</value>
</property>
<property name="maxPoolSize">
<value>15</value>
</property>
<property name="maxStatementsPerConnection">
<value>100</value>
</property>
<property name="automaticTestTable">
<value>oracle_server</value>
</property>
<property name="numHelperThreads">
<value>20</value>
</property>
<property name="preferredTestQuery">
<value>select * from oracle_server</value>
</property>
</bean>



Do not forget to include Oracle driver ojdbc14.jar and c3po jar c3p0-0.9.1.2.jar in the class path.


Also, for those who need DBCP settings here they are:-


 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@SERVER:1521:07" />
<property name="username" value="USERNAME" />
<property name="password" value="PASSWORD" />
<property name="initialSize" value="2" />
<property name="maxActive" value="5" />
<property name="maxIdle" value="2" />
</bean>

Tuesday, November 11, 2008

Answers to Sun Certified Developer for Java Web Services Free Proficiency Assessment

1. Given:


10. <?xml version="1.0" encoding="utf-8" ?>

11. <employee firstName="John" lastName="Doe">

12. <id>12345</id>

13. <office number="100"/>

14. </employee>

Which is true?

firstName is an XML attribute.



2. Which is a requirement of a well-formed XML document?



complies with XML syntax rules



3. How does a Web service specify the parameter types it accepts?

The parameters are defined in an XML Schema.



4. Which restrictions are applied to attachments by the WS-I Basic Profile 1.1?

The Basic Profile allows attachments with any MIME type.



5. Which two are part of a SOAP document? (Choose two)

Envelope

Namespace



6. Which is true of SOAP in Web services?



Server side errors are transmitted to clients using SOAP.





7. Which is a valid WSDL element according to the WS-I Basic Profile 1.1?


<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/jms"/>


<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/https"/>


<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>


<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/rmi"/>



8. Given:



11. public class PurchaseOrder {

12. public int poNumber;

13. public double amt;

14. public String customerName;

15. public java.util.Calendar orderDate;

16. }



The PurchaseOrder class is used as a parameter to a Web service. How is the PurchaseOrder class described in the service's WSDL document?



The class is a complex type and should be described in WSDL using an XML schema.



9. How does a client get the WSDL for a Web service from a UDDI registry?

The client retrieves the WSDL URI from the UDDI TModel.



10. The Java programming language does NOT support out or in-out parameters. The SOAP specification supports out and in-out. Which is true of out and in-out parameters?

JAX-RPC supports out or in-out parameters.



11. Which is required to build a stand-alone Java client to a Web service using JAX-RPC Dynamic Interface Invocation?

the qualified name of the Web service operation



12. A Web service takes requests from clients to render a series of JPEG images of a 3-dimensional object. The rendering may take hours or days. After the images are rendered, clients will connect again and retrieve them. Which invocation mode is appropriate for this service?

The service should use non-blocking RPC.





14. Which mapping is provided by JAXB?

an object mapping to an XML element



15. Which two are valid use cases for JAXB? (Choose two.)

Create an XML Document based on an XML Schema.

Load an XML Document into a document tree without validation.



16. Given the SOAP Envelope and Java code fragment in the Exhibit, what is the output?



EXHIBIT:

11. <SOAP-ENV:Envelope

12. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

13. <SOAP-ENV:Body>

14. <getAccountHolderName xmlns="http://account.sun.com/">

15. <acctNum>3</acctNum>

16. </getAccountHolderName>

17. </SOAP-ENV:Body>

18. </SOAP-ENV:Envelope>


11. SOAPMessage message = ...

12. SOAPBody body = message.getSOAPPart().getEnvelope().getBody();

13. Iterator i = body.getChildElements();

14. SOAPElement element = (SOAPElement) i.next();

15. System.out.println( element.getElementName().getLocalName() );


getAccountHolderName



17. Which two describe the use of JAXR in compliance with the WS-I Basic Profile 1.1? (Choose two.)

The provider must support UDDI registries.

The provider must support the level 0 profile.



18. Which three can be used by JAXR clients to query a registry? (Choose three.)

findServices

findOrganizations

findServiceBindings





19 Which method is NOT supported by the javax.transaction interface?

setStatus



20.Which is NOT included in the J2EE specification?

firewall-friendly EJB protocols



21. Which three are true of the JAXP? (Choose three.)

JAXP includes SAX.

JAXP includes DOM

JAXP includes XSLT



22. Which two correctly describe the Security Assertion Markup Language (SAML)? (Choose two.)

An assertion is a package of information that supplies zero or more statements made by a SAML authority.

SAML assertions are usually made about a subject.



23. The requirements for a particular Web service dictate that the security mechanism must support strong authentication of the client. The service will be implemented using HTTP, but may migrate to another form of transport. Which security mechanism will support these requirements?

XML Digital Signature



24. A J2EE compliant Web service is implemented with an EJB endpoint that uses declarative security. What two actions must a client do to access the Web service? (Choose two.)

The client must connect to the Web service as a security Principal mapped to a role defined in the endpoint's ejb-jar.xml file.

The client must connect to the Web service in a security Group defined in the endpoint's ejb-jar.xml file.



25 Which two are used to deploy EJB technology-based endpoints? (Choose two.)

EAR files

EJB-JAR files



26 Which messaging mode should a document-oriented Web service use according to the WS-I Basic profile?

Document/Literal



27 Which is NOT a characteristic of a Web services-based service oriented architecture?

Services are conversational.



28 Which is an example of the Business Delegate pattern?

A client calls a method that looks up a Web service in a UDDI registry and invokes it to calculate sales tax.



29 Given: An existing set of services consisting of Enterprise JavaBeans that is exposed to clients by creating a stateless session bean (facade) as an EJB endpoint. Which two are true? (Choose two.)

The existing Enterprise JavaBeans are the processing layer.

The endpoint is the service interaction layer.



30 Which two correctly define how the endpoint container implementation handles a document received in javax.xml.transform.Source format? (Choose two.)

The container automatically handles the document as an attachment.

The container implementation handles the document-passing.