java.lang.NoClassDefFoundError while calling RabbitMQ methods from ejb - java

I had written a custom ejb component with schedular attached to it. In the scheduled ejb method, I am calling the RabbitMQ methods to dequeue the messages. The whole thing works with in eclipse while debugging the individual java file. but the same while build and deployed on the Wildfly server, throws the "Caused by: java.lang.NoClassDefFoundError: com/rabbitmq/client/ConnectionFactory. Seems like a classpath issue but even adding the dependent jars in the manifest file doesn't help. I am blocked with this issue. Could anyone help me on this?
"

I converted the project to dynamic web project and added the Rabbit mq client libraries to the web-inf\lib folder. Now when I tried to deploy to the Wildfly server, its detecting the external assemblies and I am able to create the connection factory. Not sure its the right way to solve the issue.

Related

Java Web Container implementation independant development

One of the most important non-functional requirements of any project is the build process in my opinion and that's where I kinda get stuck in my java project, which has just one external dependency, a jdbc compatible database. All the tutorials about spring and deployment out there; I've read them all, but they either say:
run it with gradle bootRun applications.properties (yes works but on a webserver I'm not going to have any properties-files, but JNDI resource for example) or
build a deployable war file with JNDI resources (yes it works on the webserver, but not in my embedded webserver or I'm doing it wrong, but I cannot find any doc about how an embedded tomcat loads a context.xml from outside the jar file).
Now I tried to use the same setup as my server and installed tomcat7 and the #Asyc #Scheduled services run, but no servlets, like a simple /status page should return "OK" just for checking. catalina.out does not show any errors. My /manager from tomcat7-admin says deployment ok, and when I click start: "FAIL - Application at context path /xyz-0.1.0 could not be started
FAIL - Encountered exception org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/xyz-0.1.0]]"
And now I want to make a cut here and throw every "bootstrap" stuff away and start from zero.
So my question is, am I wrong when I say, that the big deal of my deployment is a jdbc JNDI resource provided from the web container, which is called 'jdbc/xyz' and everyone who wants to deploy my war needs that JNDI. That means so matter if you're using wildfly, jboss, tomcat, glassfish or any embedded server: your server impl has to provide that web container and jndi resource to make it run. And I don't want to configure any tomcat, glassfish or whatever implementation in my war.
Is that wrong?
It would be great, if you could help me. I'm playing around with that many weeks now :( and if A works B does not and vice versa. Would it be easier to use JEE?
Thank you.

Convert Spring Roo Application into a JBoss 6 Application

I have a Spring Roo app that is deploying to Tomcat with no issues. I'm trying to deploy it to JBoss 6, but I'm finding it impossible to do so.
I've exhausted all resources from Google and I simply receive errors everywhere. Unfortunately, they do not seem specific enough to start narrowing them down to list here.
What can information could I provide to help resolve this situation?
Essentially, I need to know what I need to change from a standard Spring Roo app, using Hibernate and Mysql to work with JBoss 6.
EDIT:
This is the error that I am getting
[ClassLoaderManager] Unexpected error during load of:org.apache.commons.collections.DoubleOrderedMap$1$1: java.lang.IllegalAccessError: class org.apache.commons.collections.DoubleOrderedMap$1$1 cannot access its superclass org.apache.commons.collections.DoubleOrderedMap$DoubleOrderedMapIterator
Impossible to tell, since you posted no errors.
I'm guessing that it's a problem with the configuration difference between JBOSS and Tomcat.
You set up JDBC data source connection pools differently. Tomcat has the context.xml in the server /conf folder. JBOSS has other XML config files in its server/default/deploy folder. Did you create those correctly?
I assume that you're using JNDI names for injected data sources.
Your JDBC driver JAR for MySQL goes in the Tomcat /lib folder and the JBOSS server/default/deploy/lib folder, not the wAR WEB-INF/lib.
But you should be able to take a WAR with all the Spring Roo stuff, put it into an EAR with jboss-web.xml configuration, and start it up.

java.lang.NoClassDefFoundError: org/springframework/web/context/ContextCleanupListener

I have a webapp built using spring framework. I'm trying to deploy this to Tomcat6 using Eclipse. Everytime i make a change to jsp file, I had to clean the build, publish it & then start the server. I believe, we don't have to do all these steps for JSP changes. If i just publish the files, when the server is running, i get the below exceptions
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/springframework/web/context/ContextCleanupListener
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.NoClassDefFoundError: org/springframework/util/Log4jConfigurer
And the war file is not getting deployed in server.
If I make a change to JSP file & then click restart in eclipse, it sometimes publish the files & then start the server. But in some cases, it restarts the server & then publishes the files (in which case i got the above mentioned exceptions & the war file was not getting deployed).
Ideal way that it works is, Stop the server, publish the contents & then start the server. I hate to do this every time i make a simple jsp change. Is there any alternate one click process to do this?
There's something wrong with the way you setup your project or server in Eclipse. I'd recommend following the instructions here. Also, you may want to download STS (Eclipse already bundled with Spring support) and use that instead of the vanilla eclipse.
Make sure that spring is deployed together with your application. Either set the correct export options in eclipse or copy the spring libraries to /WEB-INF/lib.
MyEclipse works fine here. You could also check JRebel as well. They advertise no redeployments. ;)
you can use exploded war and incremental hot-deploy.
this should work http://www.youtube.com/watch?v=OMtcjgTyP-g
folow at 2:30

OpenEJB Standalone -- Non-JMS MDB Fails to Deploy

I just want to go 'live' with the setup that is currently working beautifully in testing. I've downloaded the standalone OpenEJB server and put my EJBs in the /apps directory.
The output in the logs suggests the standalone server may not support non-JMS adapters:
Deployment 'SocketMDB' has message listener interface com.example.TCPMessageEndpoint but this MDB container only supports interface javax.jms.MessageListener
Note the other modules, including the RA itself seem to startup successfully. The only issue seems to be with creating consumers of non-JMS messages.
What else might I try to look at or configure? Thanks!
In the testing scenario we wrap all the modules we find in the classpath up into an EAR and deploy that. To mimic that environment, try putting your rar and ejbs into an EAR file and drop that into the apps/ directory. You should get the same results as with an embedded scenario.
I've ended up just driving an embedded OpenEJB container for further testing. Will try to post new results here when I have them.

how do i wait for service when another service depends on it

i'm about to deploy two different but dependent war-files into a single jboss (AS 4.2.x GA)
One implements some webservices (jax-ws) exposing their interfaces through
a wsdl. The other one is a (say) web frontend using the aformentioned webservices. When I drop both warfiles to $JBOSS_HOME/server/default/deploy at the same time I can see that the first gets deployed (somehow) but the second one gets stuck and the entire jboss is not responding.
When I deploy them one after another, everything is fine (it just works:)
Is there a way to tell jboss that deployment of warfile2.war has to wait
for warfile1.war to finish deployment before starting deployment of warfile2.war?
Is there a way to determine programatically wheter a given 'service' is deployed
and ready?
I'm wonder what happens when both wars are present and jboss is restarted?
Kind regards,
Jay Wee.
To answer your last question first, JBoss will deploy the contents of its deploy directory in alphabetical order. If you drop two WAR files into a running server's deploy directory, the results are unpredictable, but should be safe, so I'm not sure what's going on there.
By the way you describe the dependency, it sounds like when a user uses the frontend WAR, it calls the web service WAR, and that on startup there's no link between the two? Could anyone be trying to use the frontend WAR while the web service WAR is still deploying? Which WAR comes first alphabetically?
As a possible solution, when you have two WAR files that depend on each other, you should consider packing them both into a single EAR file. That way JBoss will deploy them together in a controlled way.
What about implementing a listener in the web frontend waiting for a successfull head request to the wsdl on localhost?
Thats right. backend.war is deployed before frontend.war.
I deployed it on my local jboss and nobody else has acces to it.
What I can see when i debug into jboss is that the frontend accesses the backend wsdl (https://localhost:9999/app/svc?wsdl ) hangs while jboss is not ready.
\at Arne Burmeister: the listener approach doesen't help. the listener is called to early in the process: I can connect to the backendWsdlUrl but backenWsdlUrl.getConnection().getOutputstream() hangs
I think I'll give the ear a try. Is there a good documentation on how
to pack things together in an ear? (skaffman already pointed me into the right direction)
Thanks a lot to all who help so far,
Jan

Categories

Resources