Use jsafeJCEFIPS.jar OSGi - osgi

Has anyone tried using jsafeJCEFIPS.jar OSGi? The jar is signed, I can't convert it to a bundle. I tried to embedded as jar in bundle, but it is always throws
java.lang.SecurityException: "JsafeJCE provider is disabled, a FIPS 140 required self-integrity check failed" when I try to create a instance of JsafeJCE object.
It looks JsafeJCE can't check itself integrity(signature etc.)successfully.
I print out jsafeJCE.class.getProtectionDomain, it is (inputstream:bundle-name.jar ).
Any idea how to get jsafeJCE works in OSGi, I'm using Apache Felix.
Thanks in advance!

An ugly workaround is to add RSA jars in system class path and expose these packages thru org.osgi.framework.bootdelegation

Related

Unable to configure logging in dropwizard. Could not resolve type id 'console'

I am trying to configure console appender in my project. It works fine when I launch my app in debug locally. However, when I build it my jar in Gradle and launch it as a standalone app I get following error:
[0]; Could not resolve type id 'console' into a subtype of [simple type, class io.dropwizard.logging.AppenderFactory]: known type ids = [AppenderFactory]
Here is the snippet of my .yml file:
logging:
appenders:
- type: console
timeZone: UTC
logFormat: '%-5level [%date{ISO8601}] [%X{requestId}] %c: %msg%n%rootException'
I was able to find posts about similar issues. For instance, this thread here suggests to check if file META-INF/services/io.dropwizard.logging.AppenderFactory is in the application jar and if it contents is as following:
io.dropwizard.logging.ConsoleAppenderFactory
io.dropwizard.logging.FileAppenderFactory
io.dropwizard.logging.SyslogAppenderFactory
I have verified it. In my case file is where it supposed to be and it has exactly the same contents.
Any help will be greatly appreciated.
Dropwizard version 0.9.2
Does the Gradle produce a Uber/Fat Jar (A jar with all it's dependencies inside itself) or a simple jar with only your Dropwizard app?
It's advisable to build an Fat-jar for Dropwizard deployments, so do switch over to this style if you're not doing so.
Now while building a Fat-Jar, you need to do the following to solve your problem (this was mentioned in the discussion you linked)
If you use maven-shade plugin for building a fat jar, don't forget about SPI resource transformer for collecting SPI resources into the jar.
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
To do the same in Gradle, check this discussion.
HTH.

Custom Mediator ClassNotFoundException TransactionSynchronization

I make a custom mediator class that used spring jdbc to access data from database. I make a jar from that class and deploy it in WSO2_HOME/repository/components/lib. After that I add the following jar to the same folder : spring-jdbc.jar, spring-tx.jar. But when I tried the custom mediator there is an error "ClassNotFoundException org\springframework\transaction\support\TransactionSynchronization". The problem is I'm pretty sure that "TransactionSynchronization" class is available in the spring-tx.jar. Can anyone help me to solve this problem? :)
One reason may be there are two packages in your class path which has the same 'TransactionSynchronization' class. Can you try the below.
What do you have in your WSO2_HOME/repository/components/dropins directory? Delete all jars inside dropins and restart the server and recheck for the issue.
If the error is still there try deleting spring-tx.jar from WSO2_HOME/repository/components/lib & WSO2_HOME/repository/components/dropins. Then restat the server. Then check whether you are getting the same error or different error?
I am experiencing the same behavior. I have a custom spring mediator that calls out to a database for role based authNZ. I am running esb v 4.7.0.
I downloaded spring-tx-3.1.0.RELEASE.jar from the maven repository and copied it to /usr/local/wso2/wso2esb-4.7.0/repository/components/lib in my environment, then restarted the ESB. When I issue requests to my proxy service, the same class not found exception occurs.
I was examining jar contents today and when I checked the spring-tx jar in /usr/local/wso2/wso2esb-4.7.0/repository/components/lib, the class in present:
jar tf spring-tx-3.1.0.RELEASE.jar | grep TransactionSynchronization
org/springframework/transaction/support/TransactionSynchronization.class
When I do the same in /usr/local/wso2/wso2esb-4.7.0/repository/components/dropins after restart of the esb, the class is not present:
jar tf ../dropins/spring_tx_3.1.0.RELEASE_1.0.0.jar
spring-tx-3.1.0.RELEASE.jar
META-INF/
META-INF/p2.inf
META-INF/MANIFEST.MF
Notice that the spring-tx jar is not included in the OSGi bundle after restart of Synapse.
I will investigate further tomorrow, including building an OSGi bundle that contains the Spring dependencies I need via Eclipse

Setting osgi.configuration.area breaks my Equinox OSGI app

I have an application which uses Equinox as an osgi framework for a while now. Until now I used the system property osgi.install.area to specify where my bundles are like so
${osgi.install.area}/
plugins/
org.eclipse.osgi_3.7.0.v20110613.jar
... my app bundles
Equinox then automatically uses ${osgi.install.area}/configuration as the configuration area.
Everything works fine.
Now I need to move the configuration area out of ${osgi.install.area} because that may be read-only and I thought it was as simple as setting ${osgi.configuration.area} to a suitable path but when I do this the application no longer starts and I have the following stack trace in the logs:
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:150)
...
The path is used because at that location the log file is created and a directory "org.eclipse.osgi".
Paths to bundles are referenced in my config.ini like so:
osgi.bundles=de.mycomp.app-0.6.0.20121116-1834.jar#start, ...
The error message does not really give a hint where to look. It must be something rather simple but I am rather clueless at the moment.
Thanks in advance,
Robert
I tested changing the configuration area an existing osgi app and it worked, with the following argument below in the .ini file in the root of the install. Are you sure you are setting the config param correctly like this:
-Dosgi.configuration.area=c:\mytest
After doing that and running the app again, it created the folder and a new configuration.
Here is a copy of my .ini file that works, also it's important that osgi params come after and vm args.
-loglevel=trace
-vmargs
-Dosgi.configuration.area=c:\mytest
-Dorg.osgi.service.http.port=8094
-Declipse.ignoreApp=true
-Dosgi.noShutdown=true
-Dequinox.ds.print=true

How to setup a proxy for Apache Karaf

Simple one but unable to find anything solid on google. I am running Karaf and I am behind a proxy. I need to add some features to the container by executing the following command:
features:addurl mvn:org.apache.camel.karaf/apache-camel/2.9.0/xml/features
When I do this I get the following exception:
Could not add Feature Repository:
java.lang.RuntimeException: URL [mvn:org.apache.camel.karaf/apache-camel/2.9.0/xml/features] could not be resolved.
This appears to be a proxy authentication issue. Please note I have added proxy information to Maven and I can download dependencies in Maven. I suspect I need to add some information like http.proxyName or http.Proxyxxx to one of the files in the etc directory of the Karaf installation.
Any ideas out there?
UPDATE:
I have found a setting in the org.ops4j.pax.url.mvn.cfg which is
org.ops4j.pax.url.mvn.proxySupport=true
I have uncommented this but I still cant authenticate. So I suspect I need to set my maven home folder somewhere.
UPDATE 2:
Ok very simple thing to do:
In your Apache karaf folder there is a etc folder. Edit the org.ops4j.pax.url.mvn.cfg file. You need to perform two steps for it to work.
Point karaf to your maven installation: find the following string in your cfg file org.ops4j.pax.url.mvn.settings uncomment it and add your maven home path i.e. org.ops4j.pax.url.mvn.settings= /maven/conf/settings.xml
Tell karaf to use the maven proxy settings: find the following string in your cfg file org.ops4j.pax.url.mvn.proxySupport uncomment it and set it to true if needs be i.e. org.ops4j.pax.url.mvn.proxySupport=true
I restarted Karaf and I can now download/install features. I hope this helps someone someday.
So if you follow my post above you will see the two main steps in getting Karaf to work via a proxy. I am not sure if there is anything more to it so I am willing to listen to other answers. But in short edit the org.ops4j.pax.url.mvn.cfg file to point to your maven install and maven proxy settings.
If a local maven instance is not available the below configurations will help :
Java proxy settings will resolve this issue:
-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=80
In my case, i am using Karaf-Wrapper(http://karaf.apache.org/manual/latest-2.3.x/users-guide/wrapper.html) and adding the below settings in etc/KARAF-wrapper.conf worked!!
wrapper.java.additional.10=-Dhttp.proxyHost=127.0.0.1
wrapper.java.additional.11=-Dhttp.proxyPort=80
Note: With this option the web services are also exposed via proxy, so if you want to avoid it, once the purpose is achieved you will have to turn off the proxy.

JDBC Driver class not found: oracle.jdbc.OracleDriver

I have installed a third party java webservice which uses Oralce jdbc thin driver to write data into Oracle database. When i run this, i get the following error;
JDBC Driver class not found: oracle.jdbc.OracleDriver
I have oracle installed and set classpath variable to following value:
*D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar*
and path variable to following value;
*D:\oracle\product\10.2.0\client_1\bin;C:\Program Files\Java\jdk1.7.0\bin\;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip*
Any suggestion why web service is not able to identify jdbc driver?
Thanks
I know 2 ways of turning Java app into Windows service and both do not use CLASSPATH. One is Java Service Wrapper by Tanuki Software. This tool uses wrapper.conf where you can show directories with .jar libraries:
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=c:\jars\*
wrapper.java.classpath.2=myservice.jar
Second tool I know is JSL: Java Service Launcher. In this tool there is jsl.ini where you put command line to run your server. It can use java with -cp option to show location of .jar libraries:
[defines]
MY_LIBS=d:\jars\*
AXIS_LIBS=d:\axis2-1.5.4\lib\*
CLASSPATH=.;%MY_LIBS%;%AXIS_LIBS%
export = CLASSPATH
...
[java]
...
cmdline = -Dfile.encoding=utf8 -cp %CLASSPATH% example.my.server
In both configuration you can use * to add all .jar files or you can show those files one by one (just like in CLASSPATH).
At first you should know what Windows is trying to execute. Check it in the service properties page. Then try to localize its configuration. If it uses one of tools I know then you know what to change. Other tools probably have similar configuration.
Method 1:
Download ojdbc.jar
add ojdbc6.jar to deployment assembly.
Right click on project->properties->select deployment assembly->click on 'Add'
->select 'Archives from File System'->browse to the folder where ojdbc6.jar is saved.->add the jar->click finish->Apply/OK.
Method 2:
if you want to add ojdbc.jar to your maven dependencies you follow this link:
http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/
.
.
Even if you're using a maven project it is not necessary to add ojdbc to maven dependencies(method 2), method 1 (adding directly to deployment assembly) works just fine.
Make sure you have the ojdbc jar file (make sure you are using the correct one because depending on java version you may need to choose a different one).
use ojdbc14.jar for Java 1.4
use ojdbc5.jar for Java 1.5
ojdbc6.jar for Java 1.6
here is linke where you can download ojdbc6.jar file
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
You also have to add the jdbc jar to your server classpath. if tomcat, rigth-click on your Project->run as->run configurations, click on classpath and add your jdbc jar in Add external jars option
add ojdbc-6.jar to your lib directory of tomcat installation. Maven will downlowd this jar for you in .m2 directory, but you need to have this jar in tomcat lib as well.

Resources