Where is the jar file for EJB3 annotations for JBoss 5? - jboss

This should be simple, but I'm at a complete loss.
I'm working through a tutorial for setting up some MBeans in JBoss 5.0. It has an example like this:
#Remote
public interface Calculator {
public double getInterestRate();
public double calculateTotalInterest(double presentValue, int years);
public double calculateFutureValue(double presentValue, int years);
}
I'm trying to find the jar file that contains the data for the #Remote annotation, and I cannot seem to find which jar file I need. A google search gives me little to nothing that seems to apply to JBoss 5.0. Any help would be much appreciated.

It's smuggled away inside common/lib/jboss-javaee.jar, along with the rest of the JavaEE API. This JAR is for use by the JBoss server.
Another copy is kept inside client/jboss-javaee.jar, for use by clients.
Both are copies of the same classes.

And if you are in a similar situation in future, go to www.findjar.com, type in the name of the class, and the search engine would find the jar for you. That website has served me countless times.

Related

How do Service / SourceProviders work in Eclipse 4 RCP 2.0?

I've been busily getting with the future and migrating an old eclipse 3.7 application over to Eclipse 4 and whilst I'm happy with the application model for porting all the views I have a number of source providers that I am unsure about porting wise. I've been using a few tutorials on Eclipse 4 including this Tutorial from good old Lars but none seem to cover this particular element.
For a small amount of Context my existing application has a few classes extending AbstractSourceProvider that are registered in the org.eclipse.ui.services extension point. My views register themselves as listeners to these services using the ISourceProviderService.getSourceProvider(key) function from the workbench and update themselves if that source fires a sourced changed event. I also have a few providers that reference each other some times too so I'm wondering if this will still work with injection.
What sort of model is used in Eclipse 4?, should I just use the same old extension point? Can these extension point services be injected in to the views in the new cool anotationy way?
What gives?
You can create a service in a number of ways:
Create an instance of your service class and put it in the IEclipseContext. This is often done in an 'Addon':
public class MyAddon
{
#PostConstruct
void postConstruct(IEclipseContext context)
{
MyService myService = ContextInjectionFactory.make(MyService.class, context);
context.put(MyService.class, myService);
}
}
The 'Addon' is declared in the application.e4xmi file.
You could also create the service like this in the LifeCycle class for the RCP.
An OSGi service will automatically be added to the Eclipse context.
You can use a Context Function which uses an OSGi service but doesn't create the actual service until it is needed.
In all cases you reference the service by injection:
#Inject
MyService myService;
Note that injection is only done on objects created by Eclipse from objects described in the application.e4xmi. It is possible to do injection on other objects using ContextInjectionFactory.

Creating ejb project

I am trying to learn ejb by reading MasteringEJB by ED Roman. It stated there that we need to create the interface first. For example, we need to create
1.Remote interface for Hello.java
2.Local interface for HelloLocal.java
3.Home interface for HelloHome.java
4.Local Home interface for HelloLocalHome.java
5.and we need to create interface for our bean class, HelloBean.java
6.and we need to have deployment descriptor
and lastly we need to package all this file together in EJB-jar file.
so my question is , I do not know which one to choose?
like go to File>New> --which one should i choose? is it file?interface? java project? ejb?
Could anyone help me ?
Have you tried taking a look at the source code that goes with the book:
http://media.techtarget.com/tss/static/books/wiley/masteringEJB/downloads/3eCode.zip

Create a GWT RPC Service

I’m trying to create a backend for a homepage with GWT. I created a Google Web Application in Eclipse without sample code and now I would like to add the service, but the developer Google guide doesn’t help me. I’m not sure, where to add the interface and how it exactly works.
If I understand the google documentation correctly, I have to add a module and an entry point class, is that correct? It would be great if you could give me some tips and help how to create a rpc service.
If you create a new GWT project in the Eclipse "New Project" wizard, with "Generate project sample code" checked, it will include a fully functioning RPC service with a sample method, which you can then adapt or copy according to your needs.
Out of memory, don't have eclipse in front of me.
First do create a test project with generated testcode, you can delete it afterward.
Yes you will have to add a module.
Create in client the two interfaces for the async calls, inherit it on server side.
Hope I understood your question right.
I'm not sure what would help you the most. Google developer guide was enough for me (at least when I started using it on version 1.6) to create RPC services for my GWT application.
General APP
Module: is the .gwt.xml file. Yes, you'll need it. The GWT compiler will find it automagically and try to compile all the GWT code (the <source> element will tell which subpackage contains Java code that will be converted to JS). It will tell also which class implements the EntryPoint interface. The onModuleLoad will be the code executed when javascript runs in the client page.
RPC
Well, you should first try UI things and only then, when you're confident enough, try the server thing. Anyway the scheme is:
interface MyService extends RemoteService {
List<String> doSomething(String sample, int other);
}
#RemoteServiceRelativePath("../path/to/servlet") // see later
intercace MyServiceAsync {
void doSomething(String sample, int other, AsyncCallback<List<String>> callback);
}
These are the interfaces. Later is the async one. That's what you'll use from client side. Always calling and passing an implementation of AsyncCallback which will receive (sometime later, you don't know when) the result.
First interface is the syncrhonous one. That is what you need to implement on server. You must inherit from RemoteServiceServlet class (it is an implementation of servlet that already does all the values handling), and implement your interface. GWT code does the rest (almost).
public class ServiceImpl extends RemoteServiceServlet implements MyService
{
// implement the method normally
}
From client you'll need to create the service proxy:
private static MyServiceAsync MY_SERVICE = GWT.create(MyService.class);
Yes. I know it's weird how GWT knows MyserviceAsync and MyService work together. Don't worry about that. It works :)
Just use the service like this:
MY_SERVICE.doSomething("value", 111, new AsyncCallback<List<String>>() {
// note that this code executes some time in the future when response from server is back
public void onSuccess(List<String> result) {
Window.alert("Server answered with " + result.size() + " elements!");
}
public void onFailure(Throwable t) {
Window.alert("Server failed: " + t.getMessage());
}
}
Path to server
You'll have to configure your app to make that servlet implementation listen to URL indicated in #RemoteServiceRelativePath. That's the way client knows where to make the request, and the server knows which servlet attends that request. I'd suggest using:
../my-service.gwt as relative path (GWT module gets published in <ROOT>/module_name
and
configuring your web app to use the servlet for /my-service.gwt
But it's entirely upon your preferences :)
Anyway I think Google tutorials are the best. So please copy&paste. Try&modify until you get to understand the whole thing.

NoClassDefFoundError for EJB Home class

I'm using JBoss 4.2.3, EJB2, XDoclet and have deployed one EAR with the EJBs in it, and other EARs with various websites in them.
When trying to access an EJB from one of the websites, I get NoClassDefFoundError.
It seems that the lookup is successful. I can see, for example, that getContext().lookup(SecurityServiceRemoteHome.JNDI_NAME) returns something of class "$Proxy266". I also see in JBoss's JNDI View this binding:
remote (proxy: $Proxy266 implements interface com.icumed.ifactory.service.session.SecurityServiceRemoteHome,interface javax.ejb.Handle)
FYI, SecurityServiceRemoteHome.JNDI_NAME = "ejb/ifactory/SecurityService/remote"
Right after the lookup, I call this, which is where the error is thrown:
home = (SecurityServiceRemoteHome)PortableRemoteObject.narrow(obj,
SecurityServiceRemoteHome.class);
I've heard that this might be unnecessary and I can just do a straight type conversion here, but I don't think that's the problem. From what I've read on the web so far, it seems like maybe the SecurityServiceRemoteHome cannot be fully loaded. Perhaps some ancillary classes are missing? I don't see any errors indicating this, though. What's the best way to go about debugging this?
After even more digging around, I found the answer. It has to do with the jboss-app.xml file and the loader-repository element. The background is that I previously had one complete EAR file with all the WARs and EJBs in it. I have decided to break them apart, and when I did so, I modified the jboss-app.xml files so that the archive name was different for each one. That was wrong. They must be the same between the EAR for the EJBs and the EARs for the WARs (Yes, I don't really need an EAR file if it's just a WAR...except on OC4J). Furthermore, I must have the loader-repository element present with an archive name. Leaving that out causes other problems.

Grails + GWT - using the same Date Format

I am developing an app using Grails and GWT for a client side.
I want to use the same date format both on the client side and on the server side (preferably defined in one file).
So far i've understood that Grails got it's own mechanism for internationalization (grails-app/i18n). I know i can access these messages from any server code using app context.
I can also access any resource file inside web-app directory.
For the client side, i can use ConstantsWithLookup interface and GWT.Create(...) to get an instance of it.
But, i still haven't found good solution to integrate these two together, so i have date format defined in one place. Any ideas or tips?
Thanks,
Sergey
After digging into Grails more, i came to a solution.
I've put constant into .properties file under grails-app/i18n.
Then, i hook to eventCompileEnd and i copy resources from grails-app/i18n to specific package in target\generated-sources.
After this step is completed, i generate google I18N interfaces using copied property files.
I've put this functionality to separate plugin.
_Events.groovy:
includeTargets << new File("${myPluginDir}/scripts/_MyInternal.groovy")
eventCompileEnd = {
internalCopyMessageResources();
}
eventCopyMessageResourcesEnd = {
generateI18NInterface();
}
Now it is possible to access localized data from server side and from client side.