Bouncy castle no such method error - encryption

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).

Related

Can't compile servlet using command line

I'm trying to compile a servlet which sets session data for my site. However I'm having big problems trying to import other class files which the servlet relies on.
I need to import my custom made MySQL class file which is located in evo.net. (WEB-INF/classes/evo/net). This is already compiled and works perfectly.
And I also need to import my custom made Encryption class for encrypting passwords using it's md5() method. This is located in evo.common (WEB-INF/classes/evo/common). This is already compiled and works perfectly too.
My Session servlet is located in the same package as my MySQL class (evo.net or WEB-INF/classes/evo/net).
I'm setting the classpaths as follows:
set classpath=;D:\Apache Software Foundation\Tomcat
7.0\lib\servlet-api.jar;D:\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\WEB-INF\classes\evo\common\Encryption;D:\Apache Software Foundation\Tomcat
7.0\webapps\ROOT\WEB-INF\classes\evo\net\MySQL
Is this the wrong way to set multiple classpaths? As its throwing 'cannot find symbol' errors. If I just set the classpath pointing at the servlet-api.jar it fixes the javax cannot find symbol errors, but when I add the others on the classpath it doesnt work. Help much appreciated. Thanks!

encryption of the war using Spring

I hava met some problems .
I want to encrypt the war using Spring by a tool named ClassGuard ,but when I deploy it to Tomcat and started to launch it , some problems(seemed to be A fatal error has been detected by the Java Runtime Environment) arised .
have anyone used ClassGuard and met problems like this?
please help me...thanks in advance!
Although without the exception we can only speculate, the ClassGuard FAQ section clearly states that:
As of Version 1.5, ClassGuard supports Tomcat containers.
To use ClassGuard in combination with tomcat, you have to configure your web application for using the ClassGuard tomcat class
loader. This can be set in the context of the web application.
So make sure that:
You are using the latest stable version.
You are using the appropriate class loader.
A probably (although not sure if it is what you are after) easier way to discourage usage of your code would be through Obfuscation Tools such as these.

CDI on GlassFish 3.1.1 b12 generates error "WELD-001408 Unsatisfied dependencies"

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.

How to set order of jars in WebLogic?

In my application I am using Joda-Time 2.0 but in my WebLogic path there is library Joda-Time 1.2.
How can I change the order and tell WebLogic to use my library? Now it is using its own library, not mine. I just added a Maven project dependency to Joda-Time 2.0.
There are several ways of doing this.
Change your startWeblogic.cmd(sh) in the bin folder for your domain, look for the classpath setting and add the new joda before any other WebLogic jars
as was said above, you can change your weblogic.xml if the application is a web application and chose to prefer any lib that comes inside the war.
If you are using an Enterprise application, you can set the following options in your weblogic-application.xml:
<prefer-application-packages>
<package-name>org.apache.*</package-name>
<package-name>antlr.*</package-name>
</prefer-application-packages>
And set your package name for joda in there.
Please note that the first option might result in strange behavior from WebLogic.
Note for some reason I can't get the code to work with the XML.
As your class is present in your war, WEB-INF/lib,
can you try using the weblogic.xml setting to force the WEB-INF/lib class to get loaded in preference to that in server/lib with
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

ASP.NET MVC 2.0 NHibernate Configure() issue

I have installed NHibernate for my ASP.NET web app although I'm getting a problem in real-time on the following line of code:
if (_sessionFactory == null)
{
_sessionFactory = new Configuration().Configure().BuildSessionFactory();
}
Looking at the inner exception the problem is this:
{"Could not find file 'D:\Websites\Test\Test\Test\bin\hibernate.cfg.xml'.":"D:\Websites\Test\Test\Test\bin\hibernate.cfg.xml"}
This makes sense, as the file doesnt exist in that location. This line of code is within my Core project. File hibernate.cfg.xml is currently in my Infrastucture project, not my Core. Should this be? I have copied the file into this location although I still get problems. If I manually copy the file into this location within windows explorer I then get the following error during runtime.
{"Could not load file or assembly
'Infrastructure' or one of its
dependencies. The system cannot find
the file specified.":"Infrastructure"}
Also, I'm missing DynamicProxy.dll as I'm using castle and I couldnt see a version of the DynamicProxy in the castle folder that I downloaded from http://sourceforge.net/projects/nhibernate/
any suggestions? I can see LinFu.DynamicProxy.dll within the download although it says I only need one of the folders, Linfu or Castle, and I'm using Castle for this experiment. Not sure if this has anything to do with it, just thought it might help.
any ideas? Many thanks,
James
About "Could not find hibernate.cfg.xml": you can either set it to "Copy to Output" (see this) or configure it as an embedded resource.
About "Could not load assembly Infrastructure": you're missing Infrastructure.dll in your bin, or one of its dependencies, just as the error says.
About missing DynamicProxy.dll: if you're using NHibernate 3.x all you need to use the Castle bytecode provider is NHibernate.ByteCode.Castle.dll and Castle.Core.dll

Resources