Inject an environment variable into a JPA Entity - jpa-2.0

I want to be able to inject a value from ejb-jar.xml into a JPA Entity Listener. Is that possible? I am using the GlassFish 3.x server

Injection is not supported for entity listeners in EE 6. In EE 7, the JPA 2.1 spec states that entity listeners are CDI beans, which are eligible for injection.

Related

Spring Roo 1.3x web service call

I generate on application with Spring Roo 1.3 x.
I use 2 tables. Department and Employee.
generate spring mvc based application, using roo shell.
Now when I want to ADD an Employee, I want to call - some external web service (REST/SOAP) from my roo application --- against the ADD button operation.
In normal MVC application .. this is very easy ... but in spring roo - how can I achieve this for REST and SOAP ?
Note Spring Roo is a "development tool" that generates a "normal MVC application", you can customize it as needed.
You should customize or evolve it in the same way you would do with any Spring MVC application.

Call EJB 3.1 from EJB 2 client

I need to develop a server side component to accomplish some internal task for my company.
We have a Java EE scheduler application deployed on WebSphere 6.x that will be my client application.
I'd like to write my server side component with EJB 3.1 or with another Java EE 6 compliant technology.
Can I generate a legacy EJB 2.1 client for my component with maven?
Is it better to use another solution like web services and let the scheduler generate his own client?
Other ideas?
I'd suggest using Web Services. EJB will involved RMI/IIOP and serialization. Since you will have 2 different servers, JDK versions you may have much more troubles using EJB integration. If communication is asynchronous, you could also consider JMS.

Hibernate RESTful webservices in NetBeans

Is it possible to create RESTful Web Service using Hibernate in Netbeans 7.4?
I could see wizard to create RESTful Web Service using Persistence, but would like to know how it can be integrated with Hibernate?
Appreciate any help or insight.
Edit 1
I would like to know what I did is the correct method of generating RESTful web services using Hibernate.
First I generated Hibernate Entity classes using NetBeans and then I created RESTful services from Entity classes. So does this creates RESTful Web Services with Hibernate? I could see AbstractFacade classes that is almost like DAO classes
Edit 2
Screen shot for selecting RESTful Web Service from Entity classes
If you want to build a truly RESTful service, you need to build up a link relation architecture. You're going to need more than Hibernate or Netbeans to do that.
I recommend using the milestone Spring Data REST in conjunction with Hibernate's JPA implementation and Spring HATEOAS. See Spring Restbucks as an example which brings all these technologies together.

J2EE web service provider and consumer, must be in same EAR?

A method in one EJB will call a Web service in another EJB. Do they need to be packaged in the same EAR, or can I deploy the Web service provider separately (in a WAR)? Will dependency injection (accomplished through #WebServiceRef annotation) work if the two EJBs are deployed separately?
Thanks!
Do they need to be packaged in the same EAR, or can I deploy the Web service provider separately (in a WAR)?
That depends on how you intend to deploy the EJBs. If you are deploying them in the same EAR file, and therefore, in the same container, I would consider the #WebServiceRef annotation to be pointless and a drag on performance. You might as well inject the other EJB instead of injecting a JAX-WS proxy in it's place.
If you want to separate these out and deploy one of the EJBs (the one providing the webservice) in a WAR file, then it is possible to do so in a Java EE 6 container.
Will dependency injection (accomplished through #WebServiceRef annotation) work if the two EJBs are deployed separately?
Yes, dependency injection will work as long as you have deployed the client in a managed environment (this includes application client containers, web containers and EJB containers). As far as the client EJB is concerned, the container will provide a proxy for the web-service at runtime. All calls will be delegated to the proxy, that will make the required HTTP requests to the actual web-service, and return the appropriate objects after processing the response.

How to deploy a Java EE project that has web services

I already have an enterprise Java EE application. I want expose some of the existing EJBs as web services.
I wanted to know how to organize the Java EE project. I mean where does the web services sit in the Java EE EAR file hierarchy and how to invoke the deployed webs services?
It depends upon exactly how you implement your WebService and also on which Java EE version you are using. Simplest, with JAX-WS your webservice implementation and interface are all packed in the WAR. See the sun tutorial. Possibly you may implement your service as an EJB and in which case you can simply use the #WebService annotation. In which case you're delivering the EJB jar.
Recommend you work through a few tutorials for the specific App Server you are using.