3

i have a software which runs on jboss and it requires crypto library which resides in jre/lib/ext. I get the following exception:

Caused by: java.lang.ClassNotFoundException: com.sun.crypto.provider.SunJCE from [Module "deployment.myatrium-intranet-ear.ear.myatrium_intranet.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

i have tried the following solution in this link:

http://www.liferay.com/it/community/wiki/-/wiki/Main/JBoss+AS7+tips/maximized#section-JBoss+AS7+tips-sunjce_provider.jar

but failed to get ext folder scanned.

Really in a desperate situation. A help is really appreciated.

thanks in advance

Ikthiander
  • 3,917
  • 8
  • 37
  • 54
  • are you shure? Maybe you just start jboss with different jdk (without jce)? Or problem can be in security settings (java.policy, java,security, local_policy.jar) But i don;t believe jboss should 'scan' ext folder in jdk. – user1516873 Sep 14 '12 at 08:50
  • @user1516873 ofcourse jboss should not scan in unless you make it find it, but i am not sure how to do it, no good example. – Ikthiander Sep 14 '12 at 10:10
  • @dcernahoschi the link is not broken. – Ikthiander Sep 14 '12 at 10:11
  • there is another link i found, which talks about it, but does not work for me : https://community.jboss.org/thread/196781 – Ikthiander Sep 14 '12 at 10:12
  • The second one is OK, but I cannot access the first one to see what are you trying to do. Do you get any exceptions? – dcernahoschi Sep 14 '12 at 10:12
  • ok exception added in the main post. trust me the first link is also fine, but the second one will give you an idea of what i am trying to do – Ikthiander Sep 14 '12 at 10:24
  • @Ikthiander can you create simple test program with just `Security.addProvider(new com.sun.crypto.provider.SunJCE());` and run it with same jre, as jboss? – user1516873 Sep 14 '12 at 10:57
  • 2
    @user1516873 jre/lib/ext is not included in the classpath of jboss. and yes the test ran fine outside jboss. – Ikthiander Sep 14 '12 at 11:36

4 Answers4

1

You have understand it wrong. JBoss 7 have migrated to full OSGi. You need to add them to boot delegations .

It indeed loads the ext in classpath. The problem is it applies a class filter (to prevent you use non-standard class).

The same problem occur if you use the ODBC driver (sun.jdbc.odbc.*) and other sun.* classes. You have to add it to boot delegration / system package. (this is not the proper way. But you seems to hate the proper way, so....)

See these pages for details:

Community
  • 1
  • 1
J-16 SDiZ
  • 26,473
  • 4
  • 65
  • 84
  • Your answer is really informative, thanks. whats the correct way of doing it you will suggest then? i mean it looked really odd that i would have to add a library that has been packaged with jre by copying it and creating a module out of it (i assume thats what you meant as proper way, is it?). thanks again – Ikthiander Sep 17 '12 at 08:34
  • the correct way is to create a module like dcernahoschi do. But you seems to hate it. – J-16 SDiZ Sep 17 '12 at 11:41
0

I had a very similar problem a few months ago and it seems that the standard approach is not working.

This link solved my problem: https://community.jboss.org/thread/175395

It talks about the bouncycastle provider, but should work for sunjce_provider too.

dcernahoschi
  • 14,968
  • 5
  • 37
  • 59
  • sun jce can not be achieved from maven, the guy is just showing how to get the provider using maven. the problem is getting sun jce! – Ikthiander Sep 14 '12 at 11:54
  • No. It has nothing to do with maven. You should copy the sunjce jar from your `lib/ext` directory to the directory you manually create in the `modules` directory. – dcernahoschi Sep 14 '12 at 12:00
  • i dont want to copy the jar from the jre. rather i want all jre jars along with this jar to be available, as it is available for all the rest of the applications outside jboss scope. i felt your suggestion was not useful and its not an answer. – Ikthiander Sep 14 '12 at 13:34
  • it's up to you if you want or not to copy the jar but this is not a reason for a down vote. the answer might be useful for somebodyelse. or you might have specified in the question you don't want such an answer so no one looses the time to answer for a down vote. it's.not fair – dcernahoschi Sep 14 '12 at 13:54
0

Try putting the following:

Extension-List: crypto
crypto-Extension-Name: javax.crypto

inside the WAR/classes/META-INF/MANIFEST.MF

Usually in a war file the META-INF is inside the root of the war as in

WAR
├── WEB-INF
│   └── classes
└── META-INF   
    └── MANIFEST.MF 

The following seems to work for liferay 6.1 on jboss 7.1.1

WAR
└── WEB-INF
    └── classes
         └── META-INF
              └── MANIFEST.MF
feniix
  • 1,558
  • 2
  • 21
  • 35
  • actually i tried it, but without any success. one of the links i posted has this example. im wondering why it did not work for me. – Ikthiander Sep 17 '12 at 08:24
  • To be honest I have no idea, you may want to ask (if you didn't already ) on the jboss community forums – feniix Sep 17 '12 at 14:17
0

it will work in Jboss 7, by just pointing to the jar, either using jboss-deployment-strcuture.xml or manifest entry.

Jackie
  • 25,199
  • 6
  • 33
  • 24