NoClassDefFoundError for EJB Home class - jboss

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.

Related

Orika ClassCastException in Eclipse on redeploy

I am using orika-core-1.5.4.jar in my Liferay 7.3.5 CE GA6 Portlet in order to map some classes. Everything goes well if I test it in a main method or if it is the first time when the portlet is deployed, but goes awry if I redeploy it - eg. when I make some changes and then deploy them. The error is the following:
java.lang.ClassCastException: ma.glasnost.orika.generated.Orika_MedicForm_FormDTO_Mapper850365342121300$0 cannot be cast to ma.glasnost.orika.impl.GeneratedObjectBase
From what I have read (here is an interesting article and also this stack article), this is because the first time, the class was generated with a AppClassLoader and the second time with RestartClassLoader - the articles refers to Spring applications. But I am not clear how to manage this. Now, I have to restart the server each time in order to avoid this.
Any ideas would help, thanks !

NServicebus MessageHandlers in a different Project don't get hit

My problem:
I have web project which implements NServicebus and should listen to messages.
Trying to keep my solution tidy I set up a different project for all my messagehandlers.
I now find that these messagehandlers do not get "hit" with messages.
To my understanding NServicebus scans all dll's in the debug folder of the web project to find any classes implementing IHandleMessages<>.
I referenced the messagehandlers class library project in my webproject and it appears in my debug folder, however it does not seem to get hit.
What does work
In a console sample project the inclusion of a referenced project which contains messagehandlers works as expected.
In my web app it works when I move my
messaghandlers to the web app project itself.
Reading through the website http://docs.particular.net/nservicebus/hosting/nservicebus-host/ I found that there are overloads for the Configure.With() method.
However:
I do not know if I need them. They text only seem to suggest that
this will limit the places where NServicebus looks for the
implementations of the interface.
these overloads do not exist in the Configure.WithWeb method which I'm using.
I can solve my problem by moving all the messagehandlers to my web project, but this does not seem like the best solution.
Am I missing something here?
When using NServiceBus in a web project, use NServiceBus.Configure.WithWeb() instead of NServiceBus.Configure.With().
Also, in order to load message handlers in a web application, you need to include the .LoadMessageHandlers() line after .UnicastBus() as described in Hosting NServiceBus in your own Process. Otherwise any IHandleMessages<T> implementations are not loaded and your web application operates as a send-only endpoint.

Using GWT + Twitter4j

I am trying to build a simple gwt project that fetches tweets and displays them.The server passes back the tweets of type twitter4j.Tweet to the client.
Both modules import twitter4j.Tweet.
But when I run I get the following error:
--- ERROR: Line 37: No source code is available for type twitter4j.Tweet; did you forget to inherit a required module?.
I seem to have problems in inheriting twitter4j. All the posts I have seen about inheriting a jar file are not clear about how to do so. I understand I must write an inheritance instruction into gwt.xml file, something like
---
but if I try
---
it does not work. Can anyone please explain?
In a post I found on the Web one person suggested not to inherit it but:
-- Don't put twitter4j to your gwt.xml. Just add it your project class path. and make all functionalities like status updating and all in your serviceImpl. Try
This confuses me even more. I have added the jar file to my project libraries. But it does not work
I suspect I am missing something quite elementary here, but I am totally stuck. Is there something like a GWT path?
Many thanks for any help
Keep in mind that everything in your client package is compiled to JavaScript and executed in the user's browser. Thus, you'll only be able to use twitter4j's classes on the server-side of your application; you'll have to create some sort of light-weight GWT-serializable "proxy object" to pass data back and forth between your client and server tiers.
Since you can't use twitter4j on the client side of your app, you will not need anything in your .gwt.xml file referencing it. Instead, you'll add twitter4j to your classpath and do all your updating on the server side (as mentioned toward the bottom of your question). You do mention that it "does not work," but there's not enough information in your question to try to figure out why.

How do I get my Objects to work in ASP.NET MVC2

I'm rather new to MVC2 (never been in MCV1) though I'm a WebForms developer for some years now...
in my MCV 2 start project I created a App_Code folder that I would put my Business Classes on it, I also add 2 References to 2 DLLs used for the API I'm about to use.
But I don't get Intellisense on the referenced objects
What am I doing wrong?
alt text http://www.balexandre.com/temp/2010-07-28_1343.png
Is this so much different from the WebForms part?
Added
Even if I put the Object in Models instead App_Code (where I normally put all code in WebForms) I still don't get the normal intelisense, so... it just tells me that something is wrong ... dang! MVC is hard! I probably should do this in WebForms...
alt text http://www.balexandre.com/temp/2010-07-28_1509.png
This has nothing to do with MVC2, and everything to do with you're doing it wrong. I can tell that its a possibility, as you're using App_Code (I mean, who does that?). I'd definitely suggest backing up and reading some MVC tutorials, as it IS much different (although not in the way you're asking about).
I'm not exactly sure WHAT you're doing wrong, however. It might bethat PerceptiveMCAPI is internal to the assembly, it might be because there is a bug in VS, it might be that you haven't imported the correct namespace... it could be a number of different things.
I'd do the following: 1) load the assembly in reflector and make sure you have the namespace and type name and that it is public 2) use the fully qualified name of the type 3) compile, check all errors and 4) restart VS.
If all else fails, Connect.
See the Models directory -- that's where your model classes would go, assuming the class is a view model class. Having said that, it should be able to pick up and provide intellisense for whatever references you add. App_Code isn't really intended for a Web Application project (the type used by MVC) where the code is compiled statically, but rather for a WebSite where the code is compiled dynamically at runtime. It could be the "special" nature of the directory that is causing the problem because it doesn't fit the project type. You might try simply creating a different directory (if Models isn't appropriate) and not use the special App_Code directory for your code. A separate class library project with a project reference in the web application would be another alternative and is the one I usually use for non-viewmodel/controller code.

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

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.