Really Silly Deploy on Tomcat without Spring
Hi all, After googling for a few hours, I (think I) am about to run a relly silly application using CXF on Tomcat without Spring. I made a servlet that extends CXFNonSpringServlet and its init is: public void init() throws ServletException { super.init(); Endpoint.publish("http://localhost/foo/services/hello";, new FooImpl()); } and I get this exception: com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class foo.bar.jaxws.Hello is not found. Have you run APT to generate them? I somehow followed http://cwiki.apache.org/CXF20DOC/servlet-transport.html since it is too vague and it seems like some steps were accidentally (or intentionally) omitted. Am I doing everything wrong or I had only missed something really stupid (or simple)? best regards, Rafael Ribeiro -- View this message in context: http://www.nabble.com/Really-Silly-Deploy-on-Tomcat-without-Spring-tp16689619p16689619.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: Really Silly Deploy on Tomcat without Spring
Hi dkulp, First, tks a lot for the first post! :D It seems like I am now nearer than I was before ;). So... After changing from JVM 1.6 to 1.5 and adding a few (missing) libraries to classpath I got this exception: java.lang.RuntimeException: Could not find destination factory for transport http://schemas.xmlsoap.org/soap/http at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:76) at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:90) at org.apache.cxf.endpoint.ServerImpl.(ServerImpl.java:69) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:114) at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:160) at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:304) at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:232) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:183) at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:74) at javax.xml.ws.Endpoint.publish(Endpoint.java:156) at foo.bar.ServiceServlet.init(ServiceServlet.java:15) About using the CXF bundle, I found somewhere (not sure whether on some forum or even here) that it could be problematic to use Servlet support with Jetty support on classpath and then I tried to switch from the jar at lib dir on distribution to the separate jars at modules dir. Is it true or I could have sticked to the bundle jar? dkulp wrote: > > > That message is coming out of the Sun reference implementation, not CXF. > Somehow, the RI is being picked up in stead of CXF. Can you make sure > the CXF jars are properly in the war or available in the app server > classpath? In particular, if you aren't using the CXF bundle jar, you > would need the cxf-rt-frontend-jaxws jar. > > Also, is this java 6? You might also want to try java 5 which doesn't > have the RI built in to make sure it's not getting confused. > > Dan > > > On Monday 14 April 2008, Rafael Ribeiro wrote: >> Hi all, >> >> After googling for a few hours, I (think I) am about to run a relly >> silly application using CXF on Tomcat without Spring. >> I made a servlet that extends CXFNonSpringServlet and its init is: >> public void init() throws ServletException { >> super.init(); >> Endpoint.publish("http://localhost/foo/services/hello";, new >> FooImpl()); } >> >> and I get this exception: >> com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler >> error: Wrapper class foo.bar.jaxws.Hello is not found. Have you run >> APT to generate them? >> >> I somehow followed >> http://cwiki.apache.org/CXF20DOC/servlet-transport.html since it is >> too vague and it seems like some steps were accidentally (or >> intentionally) omitted. >> >> Am I doing everything wrong or I had only missed something really >> stupid (or simple)? >> >> best regards, >> Rafael Ribeiro > > > > -- > J. Daniel Kulp > Principal Engineer, IONA > [EMAIL PROTECTED] > http://www.dankulp.com/blog > > -- View this message in context: http://www.nabble.com/Really-Silly-Deploy-on-Tomcat-without-Spring-tp16689619p16690809.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: servlet transport question
Hi Leos, I managed to get CXF running on Tomcat without Spring... let me try do describe what I had to do in order for it to work: First of all I had problems using the cxf-incubator jar with every module bundled, so, I got the modules separate from modules directory. I remember that I read somewhere that if jetty libs were in classpath they might present problems to run on tomcat so that's why I decided not to use the bundled jar. After, I configured CXFNonSpringServlet on my web.xml file and then I had setup a Servlet (it could be a filter as well) with loadonstartup to register the Services I had using: Endpoint.publish. Be careful not to import the wrong Endpoint (right one is from: javax.xml.ws) class. I am sending the list of jars I have on my web application but beaware that it is mixed with hibernate, jpa, jsf and some seam libs... you might be able to find out which ones you need by only importing the ones found on cxf distro: antlr-2.7.6.jar asm-attrs.jar asm.jar c3p0-0.9.1.jar cglib-2.1.3.jar commons-beanutils.jar commons-collections-2.1.1.jar commons-collections.jar commons-digester.jar commons-lang.jar commons-logging-1.0.4.jar commons-logging.jar concurrent-1.3.2.jar cxf-api-2.0.5-incubator.jar cxf-common-utilities-2.0.5-incubator.ja cxf-rt-bindings-soap-2.0.5-incubator.ja cxf-rt-core-2.0.5-incubator.jar cxf-rt-databinding-jaxb-2.0.5-incubator cxf-rt-frontend-jaxws-2.0.5-incubator.j cxf-rt-frontend-simple-2.0.5-incubator. cxf-rt-transports-http-2.0.5-incubator. cxf-tools-common-2.0.5-incubator.jar dom4j-1.6.1.jar ehcache-1.2.3.jar ejb3-persistence.jar geronimo-activation_1.1_spec-1.0.2.jar geronimo-annotation_1.0_spec-1.1.1.jar geronimo-javamail_1.4_spec-1.2.jar geronimo-stax-api_1.0_spec-1.0.1.jar geronimo-ws-metadata_2.0_spec-1.1.2.jar hibernate-annotations.jar hibernate-commons-annotations.jar hibernate-entitymanager.jar hibernate3.jar javassist.jar jaxb-api-2.0.jar jaxb-impl-2.0.5.jar jaxen-1.1-beta-6.jar jaxws-api-2.0.jar jboss-common.jar jboss-system.jar jsf-api.jar jsf-facelets.jar jsf-impl.jar jta.jar log4j-1.2.11.jar mysql-connector-java-5.1.6-bin.jar richfaces-api.jar richfaces-impl.jar richfaces-ui.jar saaj-api-1.3.jar saaj-impl-1.3.jar wsdl4j-1.6.1.jar wstx-asl-3.2.4.jar xerces-2.6.2.jar xml-apis-1.3.02.jar xml-resolver-1.2.jar XmlSchema-1.3.2.jar 2008/4/20, Glen Mazza <[EMAIL PROTECTED]>: > > > 2008-04-20 (日) の 15:22 +0200 に Leos Literak さんは書きました: > > > Hi, > > > > I want to add soap stack to my web application. I decided for CXF. This > > page http://cwiki.apache.org/CXF20DOC/servlet-transport.html shows it > > could be possible. I set up web.xml and now I want to bind the servlet > > to bus, as specified in documentation: > > > > // cxf is the instance of the CXFServlet > > Bus bus = cxf.getBus(); > > BusFactory.setDefaultBus(bus); > > Endpoint.publish("/Greeter", new GreeterImpl()); > > > > The question is: how can I get the CXFServlet instance? J2EE's > > getServlet() method is deprecated. > > > > 1) I dont want to add spring to my project so I want to use programmatic > > way. > > > There's a CXFNonSpringServlet that you can use that may be of help for > you, but IIRC it is not in heavy use and therefore not very well > documented: > > [1] > > http://www.nabble.com/forum/Search.jtp?forum=16914&local=y&query=cxfnonspringservlet > > > > > 2) My application is a web application running in jetty container, so > > starting jetty within jetty is not good option. > > > Here's everything I know for Tomcat: > http://www.jroller.com/gmazza/date/20080417 > > > > > 3) Endpoint has no method publish, but EndpointImpl. > > > > Thank you > > > > Leos > > > > PS1 documentation says that to build samples you need ant 1.6. I've got > > CXFServlet, but it fails, that verbose attribute is not supported > > > > PS2 javadoc from installer does not contain CXFServlet > > > It's here, but our JavaDoc is pretty weak: > > http://incubator.apache.org/cxf/javadoc/latest/org/apache/cxf/transport/servlet/CXFServlet.html > > > Glen > > >
problem serializing class hierarchy
Hi all, I have an webmethod that returns an arbitrary class. The problem is, on some of its executions it might return some subclass of the class that is expressed on the method signature. Instead of getting the actual class that was serialized from the webservice the client is getting the class that is expressed on the method. Do I have to specify anything on the classes that I need to serialize or on the method in order for it to correct serialize the expected class? I am sending a sample I did to reproduce the problem described above (it is deployed on tomcat using CXFNonSpringServlet and service is registered using an startupservlet): IFake.java - package fake; import javax.jws.WebService; @WebService public interface IFake { public Foo fooOp(); } FakeImpl.java - package fake; public class FakeImpl implements IFake { public Foo fooOp() { return new FooBar(); } } FakeCli.java - import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import fake.IFake; public class FakeCli { private static IFake fakeClient; public static void main(String[] args) { System.out.println(getFakeClient().fooOp()); } public static IFake getFakeClient() { if (fakeClient == null) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(IFake.class); factory .setAddress(" http://localhost:8080/mywebapp/services/fake";); fakeClient = (IFake) factory.create(); } return fakeClient; } } Foo.java - package fake; public class Foo { private String foo; public String getFoo() { return foo; } public void setFoo(String foo) { this.foo = foo; } } FooBar.java - package fake; public class FooBar extends Foo { private String fooBar; public String getFooBar() { return fooBar; } public void setFooBar(String fooBar) { this.fooBar = fooBar; } } This webservice is registered by this call on the startupservlet: Endpoint.publish("/fake", new FakeImpl()); and the result of the execution of FakeCli is something like: [EMAIL PROTECTED] If I try to cast it to FooBar I get a ClassCastException, as expected since this class was really instantiated as Foo instead of FooBar
Re: problem serializing class hierarchy
After some extra googling rounds I found this thread that pointed to the same problem I faced... http://www.nabble.com/Migrating-XFire-Aegis-inheritance-to-CXF-td13536859.html Does anyone knows if there is another method for solving this by using annotations? regards, 2008/4/20, Rafael Ribeiro <[EMAIL PROTECTED]>: > > Hi all, > > I have an webmethod that returns an arbitrary class. The problem is, on > some of its executions it might return some subclass of the class that is > expressed on the method signature. Instead of getting the actual class that > was serialized from the webservice the client is getting the class that is > expressed on the method. Do I have to specify anything on the classes that I > need to serialize or on the method in order for it to correct serialize the > expected class? > I am sending a sample I did to reproduce the problem described above (it > is deployed on tomcat using CXFNonSpringServlet and service is registered > using an startupservlet): > > IFake.java > - > > package fake; > > import javax.jws.WebService; > > @WebService > public interface IFake { > public Foo fooOp(); > } > > FakeImpl.java > - > > package fake; > > public class FakeImpl implements IFake { > > public Foo fooOp() { > return new FooBar(); > } > > } > > > FakeCli.java > - > > import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; > > import fake.IFake; > > public class FakeCli { > private static IFake fakeClient; > > public static void main(String[] args) { > System.out.println(getFakeClient().fooOp()); > } > > public static IFake getFakeClient() { > if (fakeClient == null) { > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > factory.setServiceClass(IFake.class); > factory > .setAddress(" > http://localhost:8080/mywebapp/services/fake";); > fakeClient = (IFake) factory.create(); > } > return fakeClient; > } > } > > Foo.java > - > > package fake; > > public class Foo { > private String foo; > > public String getFoo() { > return foo; > } > > public void setFoo(String foo) { > this.foo = foo; > } > > } > > FooBar.java > - > > package fake; > > public class FooBar extends Foo { > private String fooBar; > > public String getFooBar() { > return fooBar; > } > > public void setFooBar(String fooBar) { > this.fooBar = fooBar; > } > > } > > > > This webservice is registered by this call on the startupservlet: > Endpoint.publish("/fake", new FakeImpl()); > > and the result of the execution of FakeCli is something like: > [EMAIL PROTECTED] > > If I try to cast it to FooBar I get a ClassCastException, as expected > since this class was really instantiated as Foo instead of FooBar >
Re: servlet transport question
2008/4/20, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > Rafael, > > thank you for your message. Especially the note about FQCN for Endpoint is > crucial for me! Can somebody update > http://cwiki.apache.org/CXF20DOC/servlet-transport.html ? > > > >After, I configured CXFNonSpringServlet on my web.xml file and then I had > >setup a Servlet (it could be a filter as well) with loadonstartup to > >register the Services I had using: Endpoint.publish. Be careful not to > >import the wrong Endpoint (right one is from: javax.xml.ws) class. > > > Please put snippet, how to configure the Bus (setup the servlet). The > web.xml part is clear: > > > CXFServlet > CXF Servlet > > > org.apache.cxf.transport.servlet.CXFServlet > > > > > > CXFServlet > /services/* > > > But how to manage this part? > > > // cxf is the instance of the CXFServlet > Bus bus = cxf.getBus(); > BusFactory.setDefaultBus(bus); Seems like it is already done inside startup of CXFNonSpringServlet class... I think I saw in the sources, so the only thing you need to do is run Endpoint.publish after CXFNonSpringServlet has been run. So, remember to have an startupvalue for ur servlet greater than CXFNonSpringServlet to avoid it being run before CXFs. How have you solved it? Or is it set up behind the scene automatically in > 2.0.5 release? > > Thank you > > > Leos > >