You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Mattas, Tony" <to...@stryker.com> on 2007/10/08 21:28:46 UTC

Trying to Consume Jax WS Service

I'm trying to use CXF to handle a Jax-WS service. CXF is running in a
Web Application on JBoss (using quartz), while the Jax-WS service is
running on Glassfish. This is my code to consume the service

 

package com.stryker.cmf.cipush;

import java.net.MalformedURLException;

import java.net.URL;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.Hashtable;

import java.util.logging.Logger;

 

import javax.xml.namespace.QName;

import javax.xml.ws.Service;

 

import org.quartz.Job;

import org.quartz.JobExecutionContext;

import org.quartz.JobExecutionException;

 

import com.stryker.leibinger.db.ConnectionFactoryWrapper;

import com.stryker.cmf.cipush.CIPushClass;

import com.stryker.cmf.cipush.CIPushReceive;

 

public class CIPushBean implements Job {

      

      Logger _log = Logger.getLogger("CIPush");

      private Connection connMako, connRock;

      

      public void execute(JobExecutionContext context) throws
JobExecutionException { 

            Hashtable<String, CIPushClass> allCustomers = new
Hashtable<String, CIPushClass>();

            ArrayList<String> pushCustomerFilter = new
ArrayList<String>();

            ArrayList<CIPushClass> pushCustomers = new
ArrayList<CIPushClass>();

            CIPushClass customer;

            String queryMako, queryRock;

            PreparedStatement psMako, psRock;

            ResultSet rsMako, rsRock;

            int result = 0;

            _log.info("***Starting CIPush Job");

            connMako = ConnectionFactoryWrapper.getConnection("mako");

            connRock =
ConnectionFactoryWrapper.getConnection("sqlServer");

            queryMako = "SELECT c.custnum, c.shipnum, c.custname,
c.address1, c.address2, c.addressx,"

                                    + " c.city, c.state, c.zipcode,
c.regnnum, c.terrnum, c.srepnum, f.forcedesc," 

                                    + " r.regndesc, t.terrname,
t.srepname"

                                    + " FROM sislib.macmt100 c"

                                    + " JOIN sislib.sfcrt100 f ON
c.compnum = f.compnum AND c.regnnum = f.regnnum"

                                    + " JOIN sislib.margt100 r ON
c.compnum = r.compnum AND c.divnnum = r.divnnum"

                                    + " AND c.regnnum = r.regnnum" 

                                    + " JOIN sislib.matrt100 t ON
c.compnum = t.compnum AND c.divnnum = t.divnnum"

                                    + " AND c.regnnum = t.regnnum AND
c.terrnum = t.terrnum AND c.srepnum = t.srepnum"

                                    + " WHERE c.compnum = 18 AND
c.divnnum = c.compnum AND c.active = '1'"

                                    + " AND c.regnnum NOT IN (0, 96, 97,
99) AND c.custnum < 700000"      

                                    + " ORDER BY c.regnnum, c.custnum,
c.shipnum";

            queryRock = "SELECT * FROM ciPush";

            try {

                  _log.info("***Fetching Database information");

                  psMako = connMako.prepareStatement(queryMako);

                  psRock = connRock.prepareStatement(queryRock);

                  rsMako = psMako.executeQuery();

                  rsRock = psRock.executeQuery();

                  while (rsMako.next()) {

                        customer = new CIPushClass();

                        customer.setCustnum(rsMako.getInt(1));

                        customer.setShipnum(rsMako.getInt(2));

                        customer.setCustname(rsMako.getString(3));

                        customer.setAddress1(rsMako.getString(4));

                        customer.setAddress2(rsMako.getString(5));

                        customer.setAddressx(rsMako.getString(6));

                        customer.setCity(rsMako.getString(7));

                        customer.setState(rsMako.getString(8));

                        customer.setZipcode(rsMako.getString(9));

                        customer.setRegnnum(rsMako.getInt(10));

                        customer.setTerrnum(rsMako.getInt(11));

                        customer.setSrepnum(rsMako.getInt(12));

                        customer.setForcedesc(rsMako.getString(13));

                        customer.setRegdesc(rsMako.getString(14));

                        customer.setTerrname(rsMako.getString(15));

                        customer.setSrepname(rsMako.getString(16));

                        allCustomers.put(customer.getCustnum() + "-" +
customer.getShipnum(), customer);

                  }

                  while (rsRock.next()) {

                        pushCustomerFilter.add(rsRock.getString(1));

                  }

                  psMako.close();

                  rsMako.close();

                  psRock.close();

                  rsRock.close();

            } catch (SQLException e) {

                  e.printStackTrace();

            }

            for (String key: pushCustomerFilter) {

                  _log.info("***Adding customers to push");

                  customer = allCustomers.get(key);

                  pushCustomers.add(customer);

                  _log.info("Customer" +
allCustomers.get(key).toString());

            }

            _log.info("***Attempting to push " + pushCustomers.size() +
" customers");

            for (CIPushClass pushCustomer : pushCustomers) {

                  try {

                        URL wsdlURL = new
URL("http://localhost:8080/CIPushReceive/CIPushReceiveService?wsdl");

                        QName SERVICE_NAME = new
QName("http://cipush.cmf.stryker.com/" , "CIPushReceiveService");

                        Service service = Service.create(wsdlURL,
SERVICE_NAME);

                        CIPushReceive client =
service.getPort(CIPushReceive.class);

                        client.pushAccounts("blah", pushCustomer);

                  } 

                  catch (MalformedURLException e) 

                  { 

                        e.printStackTrace();      

                  } 

            }

            

            _log.info("***Customer Push Complete, pushed " + result + "
accounts.");

            ConnectionFactoryWrapper.close(connMako);

            ConnectionFactoryWrapper.close(connRock);

      }

      

}

 

 

 

When using it I get this stack trace 

 

ava.lang.NoClassDefFoundError: com/stryker/cmf/cipush/CIPushReceive

      at com.stryker.cmf.cipush.CIPushBean.execute(CIPushBean.java:106)

      at org.quartz.core.JobRunShell.run(JobRunShell.java:202)

      at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java
:529)

15:26:08,150 ERROR [ErrorLogger] Job (CI.CIPushJob threw an exception.

org.quartz.SchedulerException: Job threw an unhandled exception. [See
nested exception: java.lang.NoClassDefFoundError:
com/stryker/cmf/cipush/CIPushReceive]

      at org.quartz.core.JobRunShell.run(JobRunShell.java:213)

      at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java
:529)

Caused by: java.lang.NoClassDefFoundError:
com/stryker/cmf/cipush/CIPushReceive

      at com.stryker.cmf.cipush.CIPushBean.execute(CIPushBean.java:106)

      at org.quartz.core.JobRunShell.run(JobRunShell.java:202)

      ... 1 more

 

 

CIPushReceive is the name of the Jax-WS service running in glassfish,
and I have included that on the classpath for the consumer, however no
such luck. Any suggestions?

 

Tony Mattas

IS Intern

 

Stryker Craniomaxillofacial

750 Trade Centre Way

Suite 200

Portage, MI 49002

 

p: 269.324.5346 x 4306

e: tony.mattas@stryker.com

MySharepoint
<http://mysharepoint.stryker.com/Person.aspx?accountname=LEIBINGER%5FUS%
5Ctony%2Emattas> 

 


Re: Trying to Consume Jax WS Service

Posted by Daniel Kulp <dk...@apache.org>.
I hate classloaders.  :-(


What MAY work is to put:

Thread.currentThread().setContextClassLoader(CIPushReceive.class.getClassLoader());

at the start to make sure the contextClassLoader is set to a classloader 
that may actually contain the required classes.   I'm not really sure 
though.   :-(

Dan



On Monday 08 October 2007, Mattas, Tony wrote:
> I'm trying to use CXF to handle a Jax-WS service. CXF is running in a
> Web Application on JBoss (using quartz), while the Jax-WS service is
> running on Glassfish. This is my code to consume the service
>
>
>
> package com.stryker.cmf.cipush;
>
> import java.net.MalformedURLException;
>
> import java.net.URL;
>
> import java.sql.Connection;
>
> import java.sql.PreparedStatement;
>
> import java.sql.ResultSet;
>
> import java.sql.SQLException;
>
> import java.util.ArrayList;
>
> import java.util.Hashtable;
>
> import java.util.logging.Logger;
>
>
>
> import javax.xml.namespace.QName;
>
> import javax.xml.ws.Service;
>
>
>
> import org.quartz.Job;
>
> import org.quartz.JobExecutionContext;
>
> import org.quartz.JobExecutionException;
>
>
>
> import com.stryker.leibinger.db.ConnectionFactoryWrapper;
>
> import com.stryker.cmf.cipush.CIPushClass;
>
> import com.stryker.cmf.cipush.CIPushReceive;
>
>
>
> public class CIPushBean implements Job {
>
>
>
>       Logger _log = Logger.getLogger("CIPush");
>
>       private Connection connMako, connRock;
>
>
>
>       public void execute(JobExecutionContext context) throws
> JobExecutionException {
>
>             Hashtable<String, CIPushClass> allCustomers = new
> Hashtable<String, CIPushClass>();
>
>             ArrayList<String> pushCustomerFilter = new
> ArrayList<String>();
>
>             ArrayList<CIPushClass> pushCustomers = new
> ArrayList<CIPushClass>();
>
>             CIPushClass customer;
>
>             String queryMako, queryRock;
>
>             PreparedStatement psMako, psRock;
>
>             ResultSet rsMako, rsRock;
>
>             int result = 0;
>
>             _log.info("***Starting CIPush Job");
>
>             connMako = ConnectionFactoryWrapper.getConnection("mako");
>
>             connRock =
> ConnectionFactoryWrapper.getConnection("sqlServer");
>
>             queryMako = "SELECT c.custnum, c.shipnum, c.custname,
> c.address1, c.address2, c.addressx,"
>
>                                     + " c.city, c.state, c.zipcode,
> c.regnnum, c.terrnum, c.srepnum, f.forcedesc,"
>
>                                     + " r.regndesc, t.terrname,
> t.srepname"
>
>                                     + " FROM sislib.macmt100 c"
>
>                                     + " JOIN sislib.sfcrt100 f ON
> c.compnum = f.compnum AND c.regnnum = f.regnnum"
>
>                                     + " JOIN sislib.margt100 r ON
> c.compnum = r.compnum AND c.divnnum = r.divnnum"
>
>                                     + " AND c.regnnum = r.regnnum"
>
>                                     + " JOIN sislib.matrt100 t ON
> c.compnum = t.compnum AND c.divnnum = t.divnnum"
>
>                                     + " AND c.regnnum = t.regnnum AND
> c.terrnum = t.terrnum AND c.srepnum = t.srepnum"
>
>                                     + " WHERE c.compnum = 18 AND
> c.divnnum = c.compnum AND c.active = '1'"
>
>                                     + " AND c.regnnum NOT IN (0, 96,
> 97, 99) AND c.custnum < 700000"
>
>                                     + " ORDER BY c.regnnum, c.custnum,
> c.shipnum";
>
>             queryRock = "SELECT * FROM ciPush";
>
>             try {
>
>                   _log.info("***Fetching Database information");
>
>                   psMako = connMako.prepareStatement(queryMako);
>
>                   psRock = connRock.prepareStatement(queryRock);
>
>                   rsMako = psMako.executeQuery();
>
>                   rsRock = psRock.executeQuery();
>
>                   while (rsMako.next()) {
>
>                         customer = new CIPushClass();
>
>                         customer.setCustnum(rsMako.getInt(1));
>
>                         customer.setShipnum(rsMako.getInt(2));
>
>                         customer.setCustname(rsMako.getString(3));
>
>                         customer.setAddress1(rsMako.getString(4));
>
>                         customer.setAddress2(rsMako.getString(5));
>
>                         customer.setAddressx(rsMako.getString(6));
>
>                         customer.setCity(rsMako.getString(7));
>
>                         customer.setState(rsMako.getString(8));
>
>                         customer.setZipcode(rsMako.getString(9));
>
>                         customer.setRegnnum(rsMako.getInt(10));
>
>                         customer.setTerrnum(rsMako.getInt(11));
>
>                         customer.setSrepnum(rsMako.getInt(12));
>
>                         customer.setForcedesc(rsMako.getString(13));
>
>                         customer.setRegdesc(rsMako.getString(14));
>
>                         customer.setTerrname(rsMako.getString(15));
>
>                         customer.setSrepname(rsMako.getString(16));
>
>                         allCustomers.put(customer.getCustnum() + "-" +
> customer.getShipnum(), customer);
>
>                   }
>
>                   while (rsRock.next()) {
>
>                         pushCustomerFilter.add(rsRock.getString(1));
>
>                   }
>
>                   psMako.close();
>
>                   rsMako.close();
>
>                   psRock.close();
>
>                   rsRock.close();
>
>             } catch (SQLException e) {
>
>                   e.printStackTrace();
>
>             }
>
>             for (String key: pushCustomerFilter) {
>
>                   _log.info("***Adding customers to push");
>
>                   customer = allCustomers.get(key);
>
>                   pushCustomers.add(customer);
>
>                   _log.info("Customer" +
> allCustomers.get(key).toString());
>
>             }
>
>             _log.info("***Attempting to push " + pushCustomers.size()
> + " customers");
>
>             for (CIPushClass pushCustomer : pushCustomers) {
>
>                   try {
>
>                         URL wsdlURL = new
> URL("http://localhost:8080/CIPushReceive/CIPushReceiveService?wsdl");
>
>                         QName SERVICE_NAME = new
> QName("http://cipush.cmf.stryker.com/" , "CIPushReceiveService");
>
>                         Service service = Service.create(wsdlURL,
> SERVICE_NAME);
>
>                         CIPushReceive client =
> service.getPort(CIPushReceive.class);
>
>                         client.pushAccounts("blah", pushCustomer);
>
>                   }
>
>                   catch (MalformedURLException e)
>
>                   {
>
>                         e.printStackTrace();
>
>                   }
>
>             }
>
>
>
>             _log.info("***Customer Push Complete, pushed " + result +
> " accounts.");
>
>             ConnectionFactoryWrapper.close(connMako);
>
>             ConnectionFactoryWrapper.close(connRock);
>
>       }
>
>
>
> }
>
>
>
>
>
>
>
> When using it I get this stack trace
>
>
>
> ava.lang.NoClassDefFoundError: com/stryker/cmf/cipush/CIPushReceive
>
>       at
> com.stryker.cmf.cipush.CIPushBean.execute(CIPushBean.java:106)
>
>       at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
>
>       at
> org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.ja
>va
>
> :529)
>
> 15:26:08,150 ERROR [ErrorLogger] Job (CI.CIPushJob threw an exception.
>
> org.quartz.SchedulerException: Job threw an unhandled exception. [See
> nested exception: java.lang.NoClassDefFoundError:
> com/stryker/cmf/cipush/CIPushReceive]
>
>       at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
>
>       at
> org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.ja
>va
>
> :529)
>
> Caused by: java.lang.NoClassDefFoundError:
> com/stryker/cmf/cipush/CIPushReceive
>
>       at
> com.stryker.cmf.cipush.CIPushBean.execute(CIPushBean.java:106)
>
>       at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
>
>       ... 1 more
>
>
>
>
>
> CIPushReceive is the name of the Jax-WS service running in glassfish,
> and I have included that on the classpath for the consumer, however no
> such luck. Any suggestions?
>
>
>
> Tony Mattas
>
> IS Intern
>
>
>
> Stryker Craniomaxillofacial
>
> 750 Trade Centre Way
>
> Suite 200
>
> Portage, MI 49002
>
>
>
> p: 269.324.5346 x 4306
>
> e: tony.mattas@stryker.com
>
> MySharepoint
> <http://mysharepoint.stryker.com/Person.aspx?accountname=LEIBINGER%5FU
>S% 5Ctony%2Emattas>



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog