I'm trying to work on a web application that deploys to Weblogic 10.3.5. One of the maven dependencies is Guava.
Unfortunately, upon attempting to publish the project, weblogic throws this exception:
java.lang.ClassNotFoundException: com.google.common.eventbus.EventBus
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
The rest of my maven dependencies SEEM to be working, but I'm unsure what the problem is.
Can anyone assist in troubleshooting? Environment is Eclipse with M2E plugin, Weblogic Server is integrated into Eclipse.
Update: Guava entry in pom.xml:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>11.0.2</version>
</dependency>
I included another library (commons-lang) and it worked fine.
Update 2: This may be a classloader issue. I got a clue from this blog: http://blog.eisele.net/2011/12/running-richfaces-410final-on-weblogic.html. It seems WLS uses some google-commons library.
I'm trying to force it to use my version by making changes in the weblogic.xml file, but it doesn't seem to be working.
Yes it's classloader issue (application vs. WebLogic classloading)
guava libraries and com.google.common contains same classes
WebLogic has com.google.common_1.0.0.0_0-6.jar or com.google.common_1.1.0.0_0-6.jar in it's classpath, in modules directory. (depending on WebLogic version, but the jar content is same, only META-INF\MANIFEST.MF is different)
You cannot find this library in WebLogic Classloader Analysis Tool (CAT). I'm not sure why is that....
Why not using WebLogic built in feature with help of FilteringClassLoaders - prefer-application-packages ?
you need to add something like this to your weblogic.xml or weblogic-application.xml if you are in EAR application
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>com.google.common.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
Then redeploy the application.
It works for us.
pros: no need to replace & rename magic with com.google.common*.jar files... that's a way to suicide...
Hope it helps.
For more info, see the link:
https://www.rational-pi.be/2013/03/guava-and-weblogic12c/
Go to your weblogic folder, weblogic-home >modules and if there is a com.google.common....jar file, just delete it and replace it with a guava.jar file, and you have to rename the guava file with the old com.google.common......jar name (cuz weblogic is looking for this name, but its conflicting with your guava file). i had the same problem here
Related
So I'm new to maven and watching a course on how to download hibernate-core using maven,
and he went online and got the 5.2.11 version
but I downloaded the latest one 6.1.4
the thing is when he opened his local files the jar files were there like this:
but my version only downloaded these files, even when I removed the type pom:
and when I tried the older version it worked for me, so my question is why did maven do that, and does it make any problem?
also, can I now use hibernate if I don't have an internet connection, or do I need to download the jar files anyway?
NOTE: I'm using Eclipse
Your dependency is declared in a different way from the official documentation. They don't specify a <type>pom</type>, which may be the cause of your problem.
They have it like this:
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.1.4.Final</version>
</dependency>
Remove the type and rebuild the project.
Getting java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured, while using gRPC(google pub/sub) to publish/consumes messages from Kafka.
Try adding a runtime dependency on netty-tcnative-boringssl-static. See gRPC's SECURITY.md. Note that the version of netty-tcnative necessary changes over time; you should look at the version of the document for a particular release (e.g., this is for 1.2.0).
Finally, went back to boot class class path approach. Prefixed the jetty-alpn.jar to boot class path and it starts working fine in cloud foundry now.
Adding the ALPN client JAR which matches my JDK version fixed this issue for me. In eclipse, you need to set up the jar as a bootstrap entry for the tomcat server.
You can find more info about it here : https://medium.com/#Parithi/jetty-alpn-npn-has-not-been-properly-configured-solution-418417ee6502
As suggested by google, use jetty container instead of tomcat, this solution works, but in our production, applications deployed on tomcat container, but of course I need it to work on tomcat in production.
On debugging the gRPC code, found that guava version causing the issue, updated the guava version 18.0, (where in some classes missed in previous versions), solved the problem , but failed while deploying in CF
Customized emebed-tomcat-core, and it works fine consistently, but again, team say no to custom tomcat container.
Java –jar apm-asset-xxxx.jar – works fine locally, but need to provide a custom command to CF start, didn’t have luxury to change the CF start process.
Finally, trick, the class loader to use tcnative-boring-ssl, library instead of tomcat-core library at runtime, by providing the following dependency in pom.xml. For the past 3 days, this solution is working CF.
org.springframework.boot
spring-boot-starter-web
org.hibernate
*
org.apache.tomcat.embed
tomcat-embed-core
org.apache.tomcat.embed
tomcat-embed-core
provided
Maven manifest plugin to promote the tc-native library to the top in the classloader.
In POM, try to place the gRPC dependency before the spring boot dependency (the order of dependencies matters). I did that and the issue was solved. For example:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-language</artifactId>
<version>0.13.0-beta</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I experimented with webservices and jboss4 for the last couple of days, and I stumbled over the following problem:
I included this dependency in my pom.xml:
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-jaxws</artifactId>
<version>4.2.2</version>
</dependency>
As it turned out, this caused JBoss4 to fail with the error message
java.lang.IllegalStateException: Cannot find endpoint meta data
Until I added the tiny little line
<scope>provided</scope>
to the dependency. I now understand that this problem was caused by the fact, that JBoss4 brings this library himself, and that it is the double inclusion of the same library (probably 2 different versions) that caused this. But now, when I look into the JBoss lib folder I see the following files:
commons-codec.jar
commons-httpclient.jar
commons-logging.jar
concurrent.jar
endorsed
getopt.jar
jboss-common.jar
jboss-jmx.jar
jboss-system.jar
jboss-xml-binding.jar
log4j-boot.jar
How do I know which jars correspond to which maven artifact? How do I know for any of the million files in my .m2/repository folder which groupid, artifactid and version number they belong to?
All the jar files in provided/included by Jboss are not related to maven. They are there just for the sake for jboss it self to run. Other application who wants to run in the container need to provide they own sets of library. BUT, some time, some of the library provided by JBoss is enough for the application (since they will live on the same VM), so you dont need to provide your own. You use those provided library for your development purpose, and later, when you deploy, you dont include them in your deployment.
So, there are no telling which Jar, provided by JBOSS should relate to which artifactId or groupId or version in the maven repositories, unless for some hint on their names.
For example, if you see that Jboss brings "commons-codec.jar" with it. There are no telling that the jar comes from which artifactId or groupId or version in Maven. You may guess that "commons-codec" should be a name of some artifact. Sites like http://mvnrepository.com/ helps you to find what related maven artifact that may relate to the jar you are investigating.
The artefact name is always ${artifactId}-${version}.${type}
in your case : jboss-jaxws-4.2.2.jar.
You're just looking for it in the bad place, the lib folder you're talking about must be the one of the unified classloader, the library you're looking for must be loaded by the server classloader i.e. it must reside in JBOSS_HOME/modules
[edit]
Ferdinand Neman is right when he says that jboss is not related to maven. Dependencies declaration in pom just allows maven to build and package your project. The runtime behavior depends on your targeted environment, the only things to ensure is that your dependencies must be resolved during classloading whether because they are packaged with your project or provided by the runtime environment.
Anyway the jar jboss-jaxws-4.2.2.jar will necessary be present on your workstation (in the local maven repository) to allow class linkage during maven compilation, as the jar is marked as provided it will not be included in the resulting build artefact.
Maybe you find useful this maven command
mvn dependency:tree -Dverbose
It shows you jar dependencies, classified by group-artifact and it also represents dependencies between them as a tree.
I'm working with EMF on a non-plugin, AppEngine Maven project that has the org.eclipse.core.runtime AND org.eclipse.ocl.ecore dependencies. The project runs perfectly when on the local server (I am using JDK 7). However, when deployed to GAE, I get the following two errors, sometimes one, sometimes the other:
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.core.runtime.Platform
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.ocl.ecore.internal.OCLStandardLibraryImpl
Both classes are indeed present in the JARs in the target folder's lib directory (also unzipped and checked the JARs). Here's how the dependencies look in the POM:
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.runtime</artifactId>
<version>${version.core.runtime}</version>
</dependency>
<dependency>
<groupId>org.eclipse.ocl</groupId>
<artifactId>org.eclipse.ocl.ecore</artifactId>
<version>${version.oclecore}</version>
</dependency>
Where could the problem lie? Am I missing something obvious?
Any help would be greatly appreciated!
Both classes are indeed present in the JARs in the target folder's lib
directory (also unzipped and checked the JARs
I can not see your application structure, but wherever these JARs are, if your application needs them to be the same in GAE as they are on your local machine; then you should make sure you are using the same version as present in the target version of GAE........ I used to have that problem because I started using GAE when it was new and client libraries used to change very fast.
I have a Maven project (ejb container) where I need to use the jcifs library.
I made the entries in pom.xml like:
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
<type>jar</type>
</dependency>
Everything is okay, I see the jar file inside the ear package, I see it also in the dependencies of the project, I can use the classes but at runtime I get:
javax.ejb.EJBException: java.lang.RuntimeException: java.lang.NoClassDefFoundError: jcifs/smb/SmbFile
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
What am I doing wrong?
Right-click the webproject and go to properties -> Java EE Module Dependencies. Check the Maven dependencies is checked.If not check and redeploy .
I would like to help the people who are as stupid as I am. This is not really the about the same scenario as asked for in this question, but this question helped me to figure out my problem.
I wrote a little code in a scratch file, in my case in Intellij. Before that I added the jcifs dependency to my maven project, assuming that the scratch file would find it there, which in hindsight is a bit stupid, because how would the scratch space know.
So my hint is to have a look where the dependency will actually have an effect, i.e. is available - compile time, runtime, scratch space?
Also I wanted to mention that I used this library, which works very fine for me https://github.com/hierynomus/smbj.
So in my case I edited the run configuration so that it would take the maven modules configuration into the classpath.
So my guess is that #SANN3 's answer is correct for the actual question.