How can I exclude jbossws libs (in Jboss 5.1.x common/lib) from being loaded by my project? - axis2

I am using JBoss 5.1.0GA which has the jbossws jars in the common/lib folder. My project relies on a connection to a 3rd party system (via web services). The Encryption and Decryption handlers have been delivered to me as a jar file and looking into the jar file the pom has a dependency on axis libs. We have a wsdd defined to point our client to the correct EncryptionHandler.
The problem is when we attempt to make a request on the web service the EncryptionHandler throws the following error:-
Caused by: java.lang.ClassCastException: org.jboss.ws.core.soap.SOAPMessageImpl cannot be cast to org.apache.axis.Message
10:06:15,935 ERROR [STDERR] at org.apache.axis.MessageContext.setMessage(MessageContext.java:648)
It seems that when the EncryptionHandler attempts to create the Message the jbossws lib is being used rather than the Axis lib that is included in our pom (and also in the server lib within jboss).
How can I stop the project picking up the jbossws jar and use the axis one instead? we do not have jbossws as a dependency in the pom.

You should be able to deploy the Axis lib to $JBoss_Home\lib\endorsed\ which would then take precedence over the JBoss libs.
Though there may be other carry-on effects with this depending upon what other JBoss WS related functions are being used.

Related

Mule ClassNotFoundException for class existing in a library in the class path

I have a class in a Mule application which resides in a jar of a third party library. The library gets included in the lib folder after the project builds so it is definitely in the classpath. The class is then used in a Mule component. The applications deploys successfully in AnyPoint Studio'sembedded server. However, when the Mule component is processing data, Mule complains that it can't find the class.
As soon as the line with the following code snippet is encountered it throws the NoClassDefFoundError.
populator.put(ScanType.MRI,container);
Here is a portion of the stacktrace:
Root Exception stack trace:
java.lang.ClassNotFoundException: com.tcfg.utils.defn.Populator
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at org.mule.module.launcher.FineGrainedControlClassLoader.findClass(FineGrainedControlClassLoader.java:175)
at org.mule.module.launcher.MuleApplicationClassLoader.findClass(MuleApplicationClassLoader.java:134)
at org.mule.module.launcher.FineGrainedControlClassLoader.loadClass(FineGrainedControlClassLoader.java:119)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
I also know that this is the only instance of the class in the whole project when I use a tool to search the entire lib folder for instances of the class. This is definitely not a situation of multiple versions of the class or of other classes existing in one of the jars with a similar name. What could be the cause of this and how can I resolve it?
Even though if you add the jar in lib folder you need to manually add that jar to your class path.So, that it will be available.
They are 2 possibilities here one is there might be a need of OS specific library to be downloaded and configured in Anypoint Stduio in Run configurations like for SAP we need to point it to the DLL which windows will refer to. Giving below an example.
-Djava.library.path=C:\Users\adm-snandu\AnypointStudio\workspace\
For most of the Class Notfound errors you need to make sure the maven dependency is given in the pom.xml which takes care of downloading all the relevant libraries and referring to them during run time.

Glassfish application not working with maven library (gf-client)

For a school assignment I received a Netbeans project using JNDI and JMS with Glassfish (3 open source edition). All the Glassfish libraries this application is using are referenced by absolute path and all the other libraries (in the "lib" folder) are referenced by relative path.
Since my group is working with a version control system the "lib" folder is included in the repository. This works fine because it is a small project. However the Glassfish libraries are problematic as I am a Linux user and the others are Windows users. We have worked around this problem by letting Netbeans take care of the library paths.
The chosen solution 'works' but is not the best solution. I thought Maven would be a better solution.
However the "gf-client" library is giving problems. Whenever I use the Maven "gf-client" the application throw an exception:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
Both libraries have "3.1.2" as version. The structures of the libraries look identical and both MANIFEST.MF files too. The size and the md5sum of both files however are not equal.
I've tried all "gf-client" libraries I could find in the default Maven repository and none worked. No other library gives me problems.
Was able to resolve it by adding this to my pom.xml:
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2</version>
</dependency>
The gf-client jar is referring to classes in other jars. The first class it was missing was probably java.naming.factory.initial. But after fixing this it still needed a bunch of other classes. Quickest way for me was to add the glassfish-embedded-all dependency.

Axis2 Class Cast Exception

I am currently using JBoss6.0 and have an webapplication deployed that makes use of an WebService on a remote system. Now after deploying and when trying to call a method on the webservice, I get the following error.
java.lang.ClassCastException:
org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver cannot be cast
to org.apache.axis2.engine.MessageReceiver
The error occurs when the Axis2 jar files are located in multiple locations within the classpath (perhaps even with different versions) of the JBoss server.
If you use maven you can add <scope>provided</scope> to the Axis2 dependencies of your project to ensure the libs exist only in one single location within the classpath.

Unable to load dialect 'org.drools.rule.builder.dialect.mvel.MVEL DialectConfiguration:mvel

I am using drools for processing rules. Web-service calls a method in a class which is in jar included in lib directory of web-service. And this method in turn uses drools. Now the problem is web-service is able to find jar that is using drools but not the drools-compiler jar which is residing in same lib directory. And it gives Unable to load dialect 'org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel' error. It works if I copy all jars in web-service.aar/lib to axis2/WEB_INF/lib. I also tried to set classpath in a way to take web-service.aar/lib jars first then the one's in axis2/WEB_INF/lib by setting classpath in setenv.sh and catalina configurations. But that didn't help either.
What can be the reason/solution?
You probably need to add a newer version of the mvel jar. I added the mvel-1.3.3-java1.5.jar and it did the trick for me, but just remember to restart your IDE.

Glassfishv3 not adding jars in ear to the classpath

I have been working on this problem for one whole day but in vain without any effective solution.
I have an ear file packaged with an ejb and a handful of jar files (including hibernate and the other dependent jar files).The ejb is stateless and enabled as a web service.
The ear file has been packaged using maven and has the below structure
ear->projectrelatedejb.jar
->hibernate.jar
->otherdependent. jar
->META-INF/application.xml
->META-INF/manifest.mf
The application.xml and manifest file are automatically generated by maven when I do a package.
When I deploy this ear file on glassfish it gets deployed with the ejb methods being accessible using web services. However when accessing the application (using soapui),
the ejb methods that perform some database functionality using hibernate throw java.lang.NoClassDefFoundError for the hibernate api during runtime.
It is obvious from the error that the hibernate jars are not on the classpath during runtime but since the jars are within the ear Glassfish should have
added it to the application classpath.
I tried various options like adding the classpath entries to the manifest.mf during the package (by using the element addClasspath with the maven-ear-plugin) which didn't do any good.Also with Glassfish we cannot add the dependent jars as modules to the application.xml unless the jars are application client jars
(Glassfish wouldn't deploy the ear file if the application.xml has the dependent jars declared as modules).
I also tried placing the jars in the lib directory within the ear (which isn't actually required) and with the manifest Class-Path header referencing the jars in the lib directory which also didn't fix the problem.
The quick and dirty fix which I can do to get this working is to place the hibernate and the other the dependent jars in Glassfish's lib directory.However,this is a bad practice
and I am somewhat reluctant to do it.
I would really appreciate if someone can provide me with a working solution to this problem.I have gone through the net looking for this problem
but couldn't find any solution.
Wondering if its a bug with glassfish or does glassfish need something special to reference the jars in an ear.
Thanks in advance.
I found a similar problem which is discussed here: http://www.tricoder.net/blog/?p=59.
Simply put, try putting the libraries in EAR/lib directory and according to JEE5 spec, glassfish will add them to class path automatically.
I used Server Library option to deploy application JARs and it worked for me.
Right click on your EAR-> Properties -> Libraries-> Add Library -> Create -> give name and change type in Library Type to Server Libraries then add JARs that should be deployed and confirm.
I work with NetBeans 7.0.1 and GlassFish server 3.1
When you say you added classpath entries to manifest.mf, which manifest.mf do you refer to? The one in ear-root/META-INF/manifest.mf ? Try adding a META-INF/MANIFEST.MF to your ejb module with Class-Path entries!