Unable to resolve reference to Class loaded via External library - mule-studio

I am using Anypoint studio 7.9
Mule runtime 4.3
I have class with static method as a package jar. I have added the same via Configure build path external library (not in pom xml or mule artifact json)
While invoking static method I am getting from Datweave
Unable to resolve module with identifier (package name)
Has anyone faced similar issue
PS : I have another similar jar and method. I have added via pom xml and it is working fine

Studio 7.x projects are Maven based. While you can edit the build path in the UI, that doesn't update the pom.xml, and cause libraries to be missed at build time. Don't configure build path and always use the pom.

Related

Adding external jars in netbeans for rest service in glassfish

I'm trying to create a simple REST Service using the Web App project type in Netbeans 8.1, with JDK 1.8 and to be deployed in Glassfish Server 4.1.1.
I need to use external libraries to provide the service functionality, i.e. tika and lucene.
My problem is that If I add any jar (Right-click -> Add jar/folder: tika-app-1.12.jar) in the Libraries of my Nb project I get:
An error when deploying:
Grave: Class [ javax/cache/configuration/Configuration ] not found.
Error while loading [ class
org.apache.cxf.jaxrs.client.cache.CacheControlFeature ]
An error when invoking:
Advertencia: StandardWrapperValve[BusquedaApplication]:
Servlet.service() for servlet BusquedaApplication threw exception
java.lang.NullPointerException at
org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInInterceptor.filter(JAXRSBeanValidationInInterceptor.java:64)
at
org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:132)
...
I have tried adding the jar file in glassfish/lib, glassfish/domains/<mydomain>/lib and glassfish/domains/<mydomain>/lib/ext but the error persists.
Note that these errors show up as soon as I add the jar in the Nb libraries folder, whether I reference them in my code or not.
If I remove the jars the service gets deployed without error and I can also invoke it correctly and get the appropiate response.
Any insight in the correct way to deal with these external libraries is greatly appreciated.
Ok, I think I have figured it out.
To be able to use the external libraries:
Don't package them in the war file. In Nb: go to Project Properties -> Libraries -> Compile-time libraries. Then uncheck the Package box for all the listed libraries.
Copy all the .jar libraries to the <domains-folder>/<your-domain-name>/lib. Be aware that your domain folder may not be in the installation directory of Glassfish. You can check the Server properties in Nb (Go to Services tab -> right-click Glassfish server -> Properties -> Common -> Domains Folder)
Use delegation inversion model in the Servlet. To do this, set delegate="false" in the class-loader element of the glassfish-web.xml file.
This worked for me. I hope I can help anyone else in a similar situation.

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

Walkthrough the spring source code

I wanted to walkthrough the spring code. For that I cloned the code and built it using ./import-into-eclipse.sh command. There are some instructions given in README.md file for checking out source in eclipse.
After following above instructions I was able to see the spring code in my eclipse workspace. To refer the spring source from my project I added all of spring projects (like spring-beans, spring-aop etc) in my project's Java build path. I was able to use spring code in my project.
Now the issue is that whenever I run the test cases in my project, I get initialization error. I removed spring projects from my java build path and junit test started working.
I tried to dig into the issue. For that I tried to run some of the test cases of spring projects itself like BeanUtilsTests.
but I got:
Class not found org.springframework.beans.BeanUtilsTests
java.lang.ClassNotFoundException: org.springframework.beans.BeanUtilsTests
I verified that classpath is set:
Don't know what is the issue. Can someone please tell me that what I did wrong.
Is there any better way to view/edit spring code?
Usually the below error,
Class not found org.springframework.beans.BeanUtilsTests
java.lang.ClassNotFoundException: org.springframework.beans.BeanUtilsTests
occurs when the corresponding jar is missing in the classpath. Since you have already added the spring-beans jar manually, I suspect you are using an incompatible version of the spring-beans jar with your spring-boot.
You can check the Maven repo Spring Beans to check the compatible version. But I would suggest using a dependency management tool like Gradle or Maven to include the required dependency jars. Spring-Boot Gradle file

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

GWT: Using External Jar

I am trying to figure out how to use external jar in GWT project.
I referred http://www.vogella.com/articles/GWTModules/article.html and it worked perfectly.
But the example explained using another project being included in the GWT project's build path instead of including the jar of that project.
I know this should not make a difference but when I created the jar of the external project (including sources) and used it in the client GWT gave me following error:
The import com.person cannot be resolved
What would be the problem?
For using external gwt library jar file in your gwt eclipse project you have to add that jar file in library tab from java build path:
If you want to use external jar and use that jar classes in your client side. you have to inherit module package entry in client gwt module.gwt.xml
Just example a. com.test.Module2.xml so you have do entry like
<inherits name='com.test.Module2'/>