when i'm developing code first approach to develop webservice i'm getting
this exception..
i'm new to learn webservices......  please help me... 
EmployeeIdType.java

package org.example.contract.employee;

public class EmployeeIdType {
         protected int employeeId;

        public int getEmployeeId() {
                return employeeId;
        }

        public void setEmployeeId(int employeeId) {
                this.employeeId = employeeId;
        }

}

EmployeeRecordType.java

import javax.xml.datatype.XMLGregorianCalendar;

public class EmployeeRecordType {
        
    protected Integer employeeId;
   
    protected String lastName;
    
    protected String firstName;
    
    protected GenderType gender;
    
    protected int departmentId;
    
    protected XMLGregorianCalendar hiredate;
   
    protected Float salary;

        public Integer getEmployeeId() {
                return employeeId;
        }

        public void setEmployeeId(Integer employeeId) {
                this.employeeId = employeeId;
        }

        public String getLastName() {
                return lastName;
        }

        public void setLastName(String lastName) {
                this.lastName = lastName;
        }

        public String getFirstName() {
                return firstName;
        }

        public void setFirstName(String firstName) {
                this.firstName = firstName;
        }

        public GenderType getGender() {
                return gender;
        }

        public void setGender(GenderType gender) {
                this.gender = gender;
        }

        public int getDepartmentId() {
                return departmentId;
        }

        public void setDepartmentId(int departmentId) {
                this.departmentId = departmentId;
        }

        public XMLGregorianCalendar getHiredate() {
                return hiredate;
        }

        public void setHiredate(XMLGregorianCalendar hiredate) {
                this.hiredate = hiredate;
        }

        public Float getSalary() {
                return salary;
        }

        public void setSalary(Float salary) {
                this.salary = salary;
        }
}


EmployeePortType.java

package org.example.contract.employee;
import javax.jws.WebService;
@WebService(targetNamespace="http://www.example.org/contract/Employee";,
name="EmployeePortType")
public interface EmployeePortType {
        public EmployeeIdType addEmployee(EmployeeRecordType ert);
}

EmployeePortTypeImpl.java

package org.example.contract.employee;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.jws.WebService;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;

@WebService(portName="EmployeePort",serviceName="EmployeeService", 
                    targetNamespace="http://www.example.org/contract/Employee";,
                    
endpointInterface="org.example.contract.employee.EmployeePortType")
public class EmployeePortTypeImpl implements EmployeePortType {
        
        private static Connection dbconn;
        private static DatatypeFactory df;
        
        static{
                try{
                        Class.forName("net.sourceforge.jtds.jdbc.Driver");
                
dbconn=DriverManager.getConnection("jdbc:jtds:Sqlserver://tecapocnp01:1433;DatabaseName=SampleDB",
"sa", "minnalsql12*");
                        if(dbconn!=null)
                        System.out.println("========sqlServer 
connected===========");
                        else
                                System.out.println("=================sqlserver 
connection
refused============");
                        df = DatatypeFactory.newInstance();
                }catch(SQLException e)
                {
                        e.printStackTrace();
                        throw new IllegalStateException("Database connection 
cannot be made: " +
"Code: "
                    + e.getErrorCode() + "; Message: " + e.getMessage());
                }
                catch (DatatypeConfigurationException e) {
                        // TODO: handle exception
                        throw new IllegalStateException("DatatypeFactory cannot 
be
instantiated.");
                } catch (ClassNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
        @Override
        public EmployeeIdType addEmployee(EmployeeRecordType ert)
                        {
                // TODO Auto-generated method stub
                EmployeeIdType eit = null;
                try{
                        
                        String sqlStr = "insert into
employee(first_name,last_name,gender,dept_id,hiredate,salary) values(?, ?,
?, ?, ?, ?)";
                        PreparedStatement pstmt=dbconn.prepareStatement(sqlStr);
                        pstmt.setString(1,ert.getFirstName().toUpperCase());
                        pstmt.setString(2, ert.getLastName().toUpperCase());
                        pstmt.setString(3,ert.getGender().name());
                        pstmt.setInt(4, ert.getDepartmentId());
                        java.util.Calendar cal = new 
java.util.GregorianCalendar();
            cal.clear();
            cal.set(ert.getHiredate().getYear(),
                    ert.getHiredate().getMonth() - 1, ert.getHiredate()
                            .getDay());
            pstmt.setDate(5, new java.sql.Date(cal.getTimeInMillis()));
            if (ert.getSalary() != null) {
                pstmt.setFloat(6, ert.getSalary());
            } else {
                pstmt.setNull(6, java.sql.Types.FLOAT);
            }
            pstmt.execute();
            dbconn.commit();
            
            
            
            sqlStr = "select empl_id from employee where first_name = ? and
last_name = ?";
            pstmt = dbconn.prepareStatement(sqlStr);
            pstmt.setString(1, ert.getFirstName().toUpperCase());
            pstmt.setString(2, ert.getLastName().toUpperCase());
            ResultSet rs = pstmt.executeQuery();
            rs.next();
            int emplId = rs.getInt(1);
             eit = new EmployeeIdType();
            eit.setEmployeeId(emplId);
            
                        
                        
                }catch (SQLException e) {
            
            String errorMsg;
            if ("23503".equals(e.getSQLState())) {
                errorMsg = "Unknown Department ID";
            } else if ("22001".equals(e.getSQLState())) {
                errorMsg = "Invalid column value supplied";
            } else if ("23505".equals(e.getSQLState())) {
                errorMsg = "{First name, Last name} must be unique in
database";
            } else {
                errorMsg = "SQLState: " + e.getSQLState() + "; Message: "
                        + e.getMessage();
            }      
        }
                return eit;
                
        }
}


I'M GEETING THIS Exception
  org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'employeeporttype': Invocation of init method failed; nested
exception is javax.xml.ws.WebServiceException:
org.apache.cxf.service.factory.ServiceConstructionException: Could not find
definition for service
{http://employee.contract.example.org/}EmployeeService.
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1422)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
        at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
        at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
        at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
        at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
        at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
        at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:662)
Caused by: javax.xml.ws.WebServiceException:
org.apache.cxf.service.factory.ServiceConstructionException: Could not find
definition for service
{http://employee.contract.example.org/}EmployeeService.
        at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:371)
        at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)
        at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:539)
        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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1546)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1487)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)
        ... 22 more
Caused by: org.apache.cxf.service.factory.ServiceConstructionException:
Could not find definition for service
{http://employee.contract.example.org/}EmployeeService.
        at
org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:171)
        at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:428)
        at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:548)
        at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
        at
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
        at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
        at
org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
        at
org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
        at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456)
        at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334)
        ... 31 more



--
View this message in context: 
http://cxf.547215.n5.nabble.com/org-apache-cxf-service-factory-ServiceConstructionException-Could-not-find-definition-for-service-ht-tp5742654.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to