I tried to deploy in GlassFish JAX-WS web service,
Here is a snippet of class were the web service is defined. Pay attention that I implemented Provider interface on EJB endpoint.
#Stateless(name = "HelloWorldEJBWS")
#WebServiceProvider(
portName = "HelloWorldWSPort",
serviceName = "HelloWorldWSService",
targetNamespace = "http://ivan.com/",
wsdlLocation ="HelloWorldEJBProvider.wsdl")
#ServiceMode(value = Service.Mode.PAYLOAD)
public class HelloWorldEJBWS implements Provider<Source> {
public Source invoke(final Source inRequestMessage) {
...
}
}
The problem is about the deploying the service in GlassFish (3.1.2.2) . F.
[#|2012-09-08T16:39:15.682-0400|INFO|glassfish3.1.2|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=20;_ThreadName=Thread-2;|EJB5181:Portable JNDI names for EJB HelloWorldEJBWS: [java:global/JAX-WS_GreetingEJBMutualAuthProvider/HelloWorldEJBWS, java:global/JAX-WS_GreetingEJBMutualAuthProvider/HelloWorldEJBWS!javax.xml.ws.Provider]|#]
[#|2012-09-08T16:39:15.792-0400|INFO|glassfish3.1.2|javax.enterprise.webservices.org.glassfish.webservices|_ThreadID=20;_ThreadName=Thread-2;|WS00019: EJB Endpoint deployed
JAX-WS_GreetingEJBMutualAuthProvider listening at address at http://ABRAMOV1:8088/HelloWorldWSService/com.ivan.wsejb.provider.HelloWorldEJBWS|#]
Even it shows the endpoint is deployed - is not . I can't reach this endpoint and it is not shown in GlassFish console.
For comparison I provide the log when I deployed the service using #WebService but not #WebServiceProvider
[#|2012-09-08T16:41:50.514-0400|INFO|glassfish3.1.2|javax.enterprise.webservices.org.glassfish.webservices|_ThreadID=22;_ThreadName=Thread-2;|WS00019: EJB Endpoint deployed
JAX-WS_GreetingEJBMutualAuth listening at address at http://ABRAMOV1:8088/HelloWorldEJBWSService/HelloWorldEJBWS|#]
In this case endpoint deployed correctly and everything is working fine.
Here is snipped of the code when I apply #WebService
#Stateless(name = "HelloWorldEJBWS")
#WebService()
public class HelloWorldEJBWS {
public String hello(final String inMessage) {
...
}
}
Did I do something wrong ?
I did everything right but was mislead by GlassFish. It could be a a bug...
When I deploy web service with endpoint implemented as servlet (second case) in the console I can see endpoint, but in case with endpoint implemented as EJB the endpoint did not appear in the console. But I could access the WSDL with a link http://localhost:8088/HelloWorldWSService/com.ivan.wsejb.provider.HelloWorldEJBWS?wsdl and ultimately tested web service with the client
Related
I'm quite new to the Wildfly server.
Currently I'm trying to expose a simple Stateless Session Bean as web service. I don't want to use the webModule to define servlet mappings for the web services beans. I want to keep that seperated.
I just want to expose a simple Stateless Session Bean as web service.
I used the wildfly-javaee7-webapp-ear-blank-archetype as starting point.
In the ejbModule i added a Stateless Session Bean with #WebService annotation.
The ejbModule is packaged in an .ear file, which is deployed to the WildFly Server 9. The deployment shows now error message.
I now expected to see some endpoints in the admin console under web service endpoints as the documentation(https://docs.jboss.org/author/display/WFLY9/JAX-WS+User+Guide) says. But I can't see any endpoints.
What I'm doing wrong ?
How can i access the generated WSDL file of the web service ?
What is the exact context root when ejb is packaged inside ear file?
Any hints are appreciated.
package eu.sample.testws.service;
import javax.ejb.Stateless;
import javax.jws.WebService;
/**
* Session Bean implementation class TestWSBean
*/
#Stateless
#WebService(serviceName="TestWSService", name="TestWSServiceName", portName="TestWSPortName", targetNamespace="http://sample.eu")
public class TestWSBean {
/**
* Default constructor.
*/
public TestWSBean() {
// TODO Auto-generated constructor stub
}
public String sayHello(){
return "Hello";
}
}
I am having problems to get a #WebServiceProvider web service deployed in Glassfish 3.1.2.
I configured the glassfish-ejb-jar.xml the following way for my service.
<ejb>
<ejb-name>TestWebService</ejb-name>
<webservice-endpoint>
<port-component-name>TestWebService</port-component-name>
<endpoint-address-uri>HEAD/TestWebService</endpoint-address-uri>
<transport-guarantee>NONE</transport-guarantee>
</webservice-endpoint>
</ejb>
The web service is implemented as follows.
package test.ws.services;
import [...left out for brevity...]
#WebServiceProvider(
targetNamespace = "http://ws.test.com"
, serviceName = "HEAD/TestWebService"
, portName = "TestServicePort")
#ServiceMode(value = Service.Mode.PAYLOAD)
#Stateless
#HandlerChain(file = "test_handlers.xml")
#Interceptors({ TestInterceptor.class })
public class TestWebService implements Provider<Source> {
#WebMethod
public Source invoke(Source request) {
return calcResponseSource(request);
}
}
When starting the glassfish server the following error is shown in the glassfish server.log.
SEVERE javax.enterprise.system.tools.deployment.org.glassfish.deployment.common DPL5041:Unknown port-component-name TestWebServiceService port, all sub elements will be ignored
WARNING javax.enterprise.system.tools.deployment.org.glassfish.deployment.common DPL8007: Unsupported deployment descriptors element endpoint-address-uri value HEAD/TestWebService
WARNING javax.enterprise.system.tools.deployment.org.glassfish.deployment.common DPL8007: Unsupported deployment descriptors element transport-guarantee value NONE
Later on the service gets deployed at a "technical" URL showing the fully qualified class name.
INFO javax.enterprise.webservices.org.glassfish.webservices WS00019: EJB Endpoint deployed
server listening at address at http://test:10280/HEAD/TestWebService/test.ws.services.TestWebService
I searched the web, but could not find any solution for setting up the glassfish server to do a deployment without errors.
PS: This problem also seems to stop me from enabling HTTPS for the web service.
Regards
Egbert
I want to deploy an EJB 3.0 stateless bean to WAS7 so I can access it as an EJB through a local interface and also as a jax-ws web service.
My bean looks as following:
#Stateless
#WebService
public class UserManagerImpl implements UserManager {
public UserManagerImpl() {
}
#WebMethod
public String getName(){
return "UserName";
}
}
The problem is that if I package it into an EJB-JAR and deploy, it doesn't work as a web service on WAS-7.
The only working configuration for me is if I put the EJB-JAR into a EAR and put this EJB-JAR to a WAR that is also in the EAR, like this:
EAR/
|--EJB-JAR
|--WAR/
|WEB-INF/lib/
|EJB-JAR
So my bean is duplicated.
Is there any problem with this design? If so, is there a better solution?
If your application contains #WebService annotated EJBs, then you need to process the EAR with the endptEnabler tool shipped with WebSphere before deploying it. Note that this doesn't apply to #WebService annotated classes in Web modules.
i have a local client j2se application and backend is derby(javadb) database and dao is jpa eclipselink .
how do i send these database pojo to a remote database which linked with spring ( jsp) application on tomcat server
simply this is a rich client with swing which connects to tomcat deployed web application. The client should receive data and send data through HTTP requests to the server-side of the service,
what would be the best solution ??
01) direct database connection/transaction through socket using Eclipselink
02) web service ??
03) just send post request to spring web application and convert it to POJO and persist to database
how do i achieve this??
DISCLAIMER I am not suggesting you port your app from Spring to EJB. Despite how people like to compare them as exclusively one or the other, you can use them both. Its your app, you can be as pragmatic as you want to be :)
You don't necessarily have to use Web Services if you wanted. You could drop the OpenEJB war file into Tomcat as well and create an Remote EJB to send data back and forth.
Once you drop in OpenEJB you can put a remote #Stateless bean in your app like so:
#Stateless
#Remote
public class MyBean implements MyBeanRemote {
//...
}
public interface MyBeanRemote {
// any methods you want remotely invoked
}
Then look it up and execute it over HTTP from your Swing app like so:
Properties p = new Properties();
p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://tomcatserver:8080/openejb/ejb");
// user and pass optional
p.put("java.naming.security.principal", "myuser");
p.put("java.naming.security.credentials", "mypass");
InitialContext ctx = new InitialContext(p);
MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
Client-side all you need are the openejb-client.jar and javaee-api.jar from the OpenEJB war file and your own classes.
Since it's already a Spring app don't bother trying to use #PersistenceContext to get a reference to the EntityManager so the EJB can use it. Just figure out how to expose the EntityManagerFactory that Spring creates (or you create) to the EJB via any means possible. The direct and ugly, but effective, approach would be a static on the MyBean class and a bit of startup logic that sets it. You'd just be using the EJB for remoting so no need for fancier integration.
If you did really need web services for non-java communication or something, you can add #WebService to the top of your bean and then it will have WSDL and all that generated for it:
#Stateless
#Remote
#WebService(portName = "MyBeanPort",
serviceName = "MyBeanService",
targetNamespace = "http://superbiz.org/wsdl"
endpointInterface = "org.superbiz.MyBeanRemote")
public class MyBean implements MyBeanRemote {
//...
}
public interface MyBeanRemote {
// any methods you want remotely invoked
}
Then you can also use the same bean as a web service like:
Service service = Service.create(
new URL("http://tomcatserver:8080/MyBeanImpl?wsdl"),
new QName("http://superbiz.org/wsdl", "MyBeanService"));
assertNotNull(service);
MyBeanRemote myBean = service.getPort(MyBeanRemote.class);
Both approaches are over http, but the web service approach will be a bit slower as it isn't a binary protocol.
When I deploy my EJB Web service in a WAR file the context of the Service changes.
i.e.
--http://localhost:8080/ServiceName/EJBName?wsdl
Now, it has the web application context->
--http://localhost:8080/WebAppName/ServiceName?wsdl
Why did this change and how do I control the URL of the Web service
I'm using Glassfish3/Java6 and this is what my EJB looks like->
#Stateless
#WebService(endpointInterface = "com.foo.bar.Sei", serviceName = "ServiceName")
public class EJBName implements My {}
There was a bug in Glassfish v3 where ejb webservices in war were being treated as webapps. This has been addressed in GF 3.0.1 and the GF 3.1
I updated my Glassfish Server and problem is gone:)