I have an android project and i wrote some Robolectric test cases.
I import a 3-rd party SDK (I will call it x SDK)and that SDK has an api reference on another 3rd party SDK(I will call it y SDK).
But my test cases does not involve the missing jar file.
When i am running robolectric test cases I will get ClassNotFound error .
Caused by:
java.lang.ClassNotFoundException: com.baidu.android.pushservice.PushMessageReceiver
Is it possile to make robolectric infrastucture ignore the missing JAR and let the test succeed?
Thanks a lot!
Related
I am migrating my application from log4j to log4j2. For this I have replaced the jar files for log4j with log4j2 and updated the corresponding API calls to use the new jar.
We also have cassandra noSQL db which has slf4j-log4j12-1.7.6.jar as dependency which in turn uses log4j APIs. I would need to replace slf4j-log4j12-1.7.6.jar with a new jar which is compatible with log4j2. Can someone suggest the correct jar to be used?
I am getting below exception while building cassandra components.
Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: org/apache/log4j/Level
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
The NoClassDefFound error indicates SLF4J is looking for Log4j 1.x. You need to replace the slf4j-log4j12 jar with Log4j 2's log4j-slf4j-impl jar.
This is resolved now by adding log4j-to-slf4j-2.9.1.jar and removing slf4j-log4j12-1.7.6.jar.
Below links helped.
https://logging.apache.org/log4j/2.0/log4j-slf4j-impl/index.html
http://slf4j.42922.n3.nabble.com/trouble-migrating-from-log4j-1-2-to-log4j-2-0-td4025759.html
I have activemq-client-5.13.3.jar on my class path, but i keep getting
Exception in thread "main" java.lang.NoClassDefFoundError: javax/jms/JMSException
If i use activemq-all-5.13.3.jar on my class path, every thing works.
however I am not allowed to use the activemq-all jar.
added jms-api-1.1-rev-1.jar
and now Exception in thread "main" java.lang.NoClassDefFoundError: javax/management/j2ee/statistics/Stats
You can use maven to determine this with the mvn dependency:tree command or use other maven centric tools to explore the artifacts dependencies.
At a minimum you would need these for v5.13.3
slf4j-api.jar geronimo-jms_1.1_spec.jar hawtbuf.jar
Then you can add an slf4j binding like log4j or logback to get proper logs. There are some others that you might want depending on where / how you are using it like the geronimo-j2ee-management_1.1_spec jar.
Of course if you use maven to build you can make this simpler since it will manage the deps for you.
I found same problem with my java application. I needed to insert Spring Boot for rest web service (Jetty Server) and now ActiveMQ for others data exchange.
With
activemq-client-5.15.11.jar; geronimo-jms_1.1_spec-1.1.1.jar; geronimo-j2ee-management_1.1_spec-1.0.1.jar; hawtbuf-1.11.jar;
all works.
I'm trying to decrypt a file using Bouncy Castle v1.53 PGP and Using PGPUtil class.
The program works fine in my Eclipse, but given following error when integrated inside a war file and deployed onto a weblogic server.I'm using following dependencies:
1)bcpg-jdk15on
2)bcprov-jdk15on
Error
java.lang.NoSuchMethodError:
org.bouncycastle.util.Strings.newList()Lorg/bouncycastle/util/StringList;
at org.bouncycastle.bcpg.ArmoredInputStream.<init>(Unknown Source)
at org.bouncycastle.bcpg.ArmoredInputStream.<init>(Unknown Source)
at org.bouncycastle.openpgp.PGPUtil.getDecoderStream(Unknown Source)`
Resolution
This problem is resolved when I copied following classes into my source folder:
org.bouncycastle.util.Strings
org.bouncycastle.util.StringList
org.bouncycastle.bcpg.ArmoredInputStream
org.bouncycastle.openpgp.PGPUtil`
by changing their Class Names
However, I want a better fix than this as I feel this is some Jar Conflict
Please let me know if anyone finds one
That error is likely happening because you are using one version of the bouncycastle .jars when you run with Eclipse, but there is a different version of one of those .jars which is on the classpath that Weblogic is using when running your application.
You will need to investigate how exactly Weblogic sets up the classpath, and make sure the version of the .jars you need are on the classpath before the preexisting version (unless that preexisting version is there by mistake, in which case you can just remove the preexisting one from the classpath).
I'm trying to evaluate CDI on Glassfish 3.1 and even though I have accomplished to make it work well, when I'm trying to split my code in separate deployment modules I get a weird error. More specifically:
I have two classes bundled in the same utility project (let's say the CommonLib.jar); the classnames are UserDatabase and UserDatabaseEntityManager and their definitions are as below (in the PS at the end of this message).
I also have an EAR with an EJB3.1 module in it.
When I choose to deploy the CommonLib.jar as a "Bundled Library" of the EAR, then I get the following error:
Error occurred during deployment: Exception while loading the app : WELD-001408 Unsatisfied dependencies for type [EntityManager] with qualifiers [#UserDatabase] at injection point [[field] #UserDatabase #Inject com.test.TestEJB.itemPersistenceEm]. Please see server.log for more details.
Same error as above I get also when I deploy the CommonLib.jar as a shared library (jar file copied under $glasshfish_installation_path/domains/domain1/lib)
BUT, if I choose to just have the two classes (UserDatabase and UserDatabaseEntityManager) in the EJB project (thus they are compiled within the EJB module), then the injection works fine.
Am I facing a classloader issue? Any ideas how I can get past this issue?
Just a guess, because I faced a very similar problem with Glassfish and CDI a few days ago: Do you have a beans.xml in every JAR, i.e. in the CommonLib.jar and the EJB JAR, so that CDI scans both of them?
My problem resulted from the fact that I thought placing a beans.xml into the EAR would be sufficient, which is not the case.
Sounds like you're running into some of the Glassfish CDI integration issues we've found while working on Seam 3. It could be a couple of them, so you'll have to take a look at see which one it may be. Try testing on JBoss AS7 or Apache TomEE and see if you still have problems.
I have this seam project that a colleague built. I am trying to get it to build in Jboss dev Studio. He uses ant and builds manually. I got the project built in JBDS and deployed on the JBoss server. When i try to run the app, when it is time for the rules to fire, I get this error
Caused by: org.drools.RuntimeDroolsException: Unable to resolve class 'dne.nmst.ciscoconfig.model.ConfigParams_$$_javassist_seam_4'
The offending code is in the drools config file which includes 2 imports
package Config;
import dne.nmst.ciscoconfig.model.ConfigParams;
import dne.nmst.ciscoconfig.action.ConfigSelector;
Perhaps I need more detail here, I don't know what would be useful to post. I'm not even sure I know how to ask the question other than how do I fix this. Advice anyone?
Are you 100% sure the jar containing those imports is available at runtime, rather than just at compile time?