Google Guava with WSO2 Application Server 4.1.0 - guava

I'm trying to use Google guava with Application Server 4.1.0, but I'm running into conflicts. I'm including the guava jar in the .aar file that uses it, but I get an error saying that com.google.common.collect.ImmutableList does not have a method called copyOf. After looking around, WSO2 has a jar in the repository/components/plugins directory called google-collect-1.0.0.wso2v2.jar. This jar contains com.google.common.collect.ImmutableList, but does not have the copyOf method. It looks like jars from the plugin directory get loaded before jars in the .aar when I try to access the service.
What would need to be done so that WSO2 uses the jar included in the .aar file instead of the jar in the plugins folder?

Did you try, enabling the ChildFirstClassLoading in your axis2, .aar file. If you haven't you can enable it in service level by putting the parameter,
<parameter name="EnableChildFirstClassLoading">true</parameter>
in your .aar, services.xml file.
Can you please try this and get back with the result ?
Cheers.

Related

Getting java.lang.NoClassDefFoundError: org/apache/ws/commons/schema/utils/NamespacePrefixList on creating the web service in eclipse

I am trying to create a web service using axis2.
I have created it.
I am following the below steps for getting the wsdl info.
Right click Project -> Run on server -> Next.
No class found error is coming. Is any jar file is required.
Please guide me how to resolve this.
Error: java.lang.NoClassDefFoundError: org/apache/ws/commons/schema/utils/NamespaceMap at org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:437) at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:396) at org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:109) at org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:232) at org.apache.axis2.deployment.ServiceDeployer.deploy(ServiceDeployer.java:154) at
You can download and include the XmlSchema jar in the lib folder of your dynamic web project /WebContent/WEB_INF folder.
But, this will only solve the problem temporarily. On creating WS client the XMLSchema jar will not get included. So check the compatibility of the version of your server with axis2 version (like Tomcat 6 created problem with axis2 1.7 but works fine with axis2 1.5.2).
On successful compatibility the XMLSchema jar will get included in the respective folder automatically.
You can correct your issue by referencing the XmlSchema jar in the lib folder. You can find the latest version of the jar file in the link below.
http://www.java2s.com/Code/Jar/x/DownloadXmlSchema142jar.htm

How to give external jar dependency in Jboss Server?

Hai i am developing a web application my project need to refer lib(jar) file from server, So I do not want to keep my jar file in project i need to refer the path of the jar files available in server by this i can reduce my .war file size. How can i make this reference in Jboss Server.
the first step you have to add your lib in jboss server like a module, have a look at :
http://www.mastertheboss.com/jboss-server/jboss-as-7/how-to-install-a-module-on-jboss-as-7
Next if you use Maven for dependencies, add provided to your lib dependency, in that way while packaging the .war maven will keep the jar in your lib and it will be provided by the server.
this can also be helpful : https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Development_Guide/Add_an_Explicit_Module_Dependency_to_a_Deployment1.html
Have a look at the class loading documentation. That should give you the information you need.

Appengine endpoint client library creation in eclipse

I have a java based appengine endpoint project in eclipse.
When I generate client library using command line tool.
https://developers.google.com/appengine/docs/java/endpoints/endpoints_tool
I'm getting only source based jar file ('project_name_version'.java-1.18.0-rc-sources.jar). It does not work fine in Android Studio when I add as a Library.
How can I get class based jar client library (google-api-services-'project_name_verison'-1.18.0-rc.jar)?
I tried searching online but no luck yet.
You could always zip up the sources file and use them in Android Studio. However , note that in the build.gradle file, you will have to reference the other dependent JAR files + versions that will be needed by the sources that you have generated in Eclipse via the Generate Cloud Endpoint Library option.
Build your app engine back end with JRE 7. You can change this from windows->preferences->java->installed JREs. You'll find an Add button at the right side of the pane. For more detail refer this Tutorial
This will solve most of your problems.

Using external jars in GWT projects (server-side)

I am trying to use an external jar in a Google Web Toolkit project.
The jar is for use only on the server side. For reference it is the jbcrypt jar packaged as org.mindrot.jbcrypt.
I have included the jar in my project's build path, and eclipse finds it and resolves the BCrypt class in my project.
When I try to use the service that relies on this jar (a login service that extends RemoteServiceServlet), I get a com.google.gwt.user.server.rpc.UnexpectedException which is caused by a NoClassDefFoundError for org.mindrot.jbcrypt.BCrypt.
Does the development server need the jar to be somewhere else? What should I do? Thanks.
Turns out, it goes in project/war/WEB-INF/lib

JBoss 5.x and Axis2

What libraries are required to run a Web Service Client that has been generated from Axis 2 on JBoss. So far I have not found anything in my searches.
I assume that the following error:
org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser
Is due to the fact that I have place every jar file from Axis lib folder into my projects
My Solution
Did it the hard way - added and subtracted jars from my lib directory until I got it to deploy and run with no exceptions
Is what you have pasted the root cause of the stack trace? In case it is not, the problem is that probably your app is deployed with xerces related jar files in it (ex: xercesImpl-x.x.x.jar). JBoss is shipped with the xerces jars in its JBOSS_HOME/lib/endorsed folder. If the same classes are deployed with your web app this may result in class loading issues.
You can try to remove the xerces libs from your app and then test the web service client again.
Cheers!