Re: Possible to use newer derby for pax jdbc-config?

2024-04-07 Thread Steinar Bang
>>>>> Steinar Bang :

> Ref.: https://github.com/ops4j/org.ops4j.pax.jdbc/issues/364
> Is it possible to use pax jdbc-config for derby with a newer version of
> derby than the one provided by pax-jdbc 1.5.7?

Not loading the pax-jdbc-derby feature and loading something else that
provides a Derby DataSourceFactory service, would that be enough?

What would the minimum energy path to doing something like that be, I
wonder?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87h6gdtixh.fsf%40dod.no.


Possible to use newer derby for pax jdbc-config?

2024-04-07 Thread Steinar Bang
Ref.: https://github.com/ops4j/org.ops4j.pax.jdbc/issues/364

Is it possible to use pax jdbc-config for derby with a newer version of
derby than the one provided by pax-jdbc 1.5.7?

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87le5ptkk4.fsf%40dod.no.


Re: The pax exam lifecycle explained?

2024-01-02 Thread Steinar Bang
> 'Christoph Läubrich' via OPS4J 
> :

> Just in case you don not need all the fancy magic of pax exam what is
> really only rarely needed in most cases you can use osgi-test
> framework as a lightweight alternative:

> https://github.com/osgi/osgi-test/

Interesting!

What I want, except for one place (the liquibase karaf feature test), is
to test that the karaf feature loads without error.  Doing anything more
is asking for trouble.

So if this framework can do this without too much magic it's very
interesting to me.

(In the liquibase karaf feature test I test that I use liquibase to
create a schema in a database and that I can insert a row and read back
that row, to prove that liquibase loaded by the feature is able to
actually do its job (and problems with this test is what initiated this
thread. Because when this pax exam test fails the reported errors can be
very strange and point in the wrong direction))


> sadly their maven example is a bit overcrowded, you can find a more
> focused example here:

> https://github.com/microsoft/mssql-jdbc/pull/2066/files

> I have even written a small Junit5 extension that allows running it
> with plain surefire here:

> https://github.com/laeubisoft/osgi-test-framework

Hm... with AssertJ as well, maybe...?

Thanks for the pointer!

And happy new year! :-)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87bka4cdrq.fsf%40dod.no.


Re: The pax exam lifecycle explained?

2023-12-12 Thread Steinar Bang
> Grzegorz Grzybek :

> I see your messages about Pax Exam problems and frustrations and while I
> don't have answers for your questions about liquibase OSGi problems

Well... heh!

I worked my way around the liquibase problems yesterday by swapping
derby in the pax exam test of the feature with h2.

So now there is a new version of the liquibase feature post 4.23.0 released.

But then I decided to go back and recreate the error with derby and
bisect my way through the liquibase changes from 4.23.0 to 4.23.1 and
find out which change broke things.

Only: today I couldn't reproduce the pax exam problem that has bugged me
since early autumn this year. The problem I'm getting now is the same
one I saw in h2: the order of the returned objects had changed.

So I'm wondering if what I spent a lot of time looking at was completely
the wrong thing?

Ie. that what I thought was a problem in liquibase/derby in acquiring
the lock, was actually an artifact of the test being restarted because
an assert failed?

So I'm trying to learn the pax exam life cycle to not be fooled again.

It *has* to be possible to understand, doesn't it...? :-)

For the record: Version 4.24.0 of the feature is the newest.
(there is a 4.25.0 version of the feature but that is a mistaken
release, and also version 4.25.0 of liquibase doesn't work right in
OSGi, but there is a fix underway

>(I simply would have to setup the environment, but I'm super-busy at
>the end of 2023), I can only say I went the hard way with Pax Exam.

> I didn't use documentation, just good old debugger... After some time spent
> hitting continue/step in/step out, I came up with a class like
> https://github.com/ops4j/org.ops4j.pax.web/blob/main/pax-web-itest/pax-web-itest-common/src/main/java/org/ops4j/pax/web/itest/AbstractControlledTestBase.java
> which I use in several projects (Pax Web, Pax Logging, ...).

Thanks! I'll take a look at that!

> And yes - setting it up correctly with proper logging (with conflicting
> classloaders from Pax Exam, maven-failsafe-plugin and OSGi itself) is very
> tricky...

Indeed it is!

And everytime I think I've understood it I'm hit by something
unexpected.

But right now, what I don't like, is that an error that has been stable
for several months, an error that was reproducable on several machines
and in gitlab actions, have gone away and I can't bring it back by going
back in my git history.

I have a feeling this has happened to me in my pax exam years...?

So it would be nice to actually understand how pax exam works! :-)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87zfyfrb4g.fsf%40dod.no.


The pax exam lifecycle explained?

2023-12-12 Thread Steinar Bang
Does an explanation of the pax exam lifecycle exist somewhere?

Both the life cycle of the OSGi process under test and the life cycle of
the test itself.

I've been using pax exam tests since 2015 but the behaviour of the tests
have often been a mystery for me...

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/874jgnsrcy.fsf%40dod.no.


Re: Searching for bean gives classNotFoundException

2023-12-11 Thread Steinar Bang
>>>>> Steinar Bang :

> So I guess it has something to do with function scopes?

I am thinking the clue is in one word in the error message:
> [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.93 
> s <<< FAILURE! - in 
> no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest
> [ERROR] 
> testLoadFeature(no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest)
>   Time elapsed: 0.061 s  <<< ERROR!
> java.lang.ClassNotFoundException: 
> no.priv.bang.karaf.liquibase.sample.services.Account not found by 
> PAXEXAM-PROBE-37daa15f-5c4f-4a37-b284-8ef8ac7cb232 [77]

The word is "PROBE".

I think this happens in code that check if the test is runnable, and not
when it actually runs.

As long as the test method itself will run in OSGi, then both the
stream/filter/findFirst example and the separate method example would
run fine in OSGi (because they would end up in the same .class file and
be loaded by the same classloader).

Oh well!

The current, clumsy, example works.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/878r5zsz3m.fsf%40dod.no.


Is a failing Pax Exam test run twice?

2023-12-11 Thread Steinar Bang
(I have a feeling I've asked this before but google doesn't find it)

Is a failing pax exam test run twice?

The reason I'm asking is that I saw this earlier today:
 https://gist.github.com/steinarb/640801f57b4bbec3cfa6d2aaefa37b16

First I get an assertion error in line 67 of the test:
 
https://gist.github.com/steinarb/640801f57b4bbec3cfa6d2aaefa37b16#file-gistfile1-txt-L33

I.e. here:
 
https://github.com/steinarb/liquibase-karaf-feature/blob/8a0b7aed6a9b1ae351963e2f443d18fc995e17e2/liquibase-integration-test/karaf.liquibase.tests/src/test/java/no/priv/bang/karaf/liquibase/tests/LiquibaseKarafFeatureIntegrationTest.java#L67

Then I get an assertion error in line 60 of the test:
 
https://gist.github.com/steinarb/640801f57b4bbec3cfa6d2aaefa37b16#file-gistfile1-txt-L107

I.e. here:
 
https://github.com/steinarb/liquibase-karaf-feature/blob/8a0b7aed6a9b1ae351963e2f443d18fc995e17e2/liquibase-integration-test/karaf.liquibase.tests/src/test/java/no/priv/bang/karaf/liquibase/tests/LiquibaseKarafFeatureIntegrationTest.java#L60

This is consistent with the test being run twice, with two accounts in
place in the database on the second run.

I see the same thing in the karaf.log of the pax exam run:
 First "FAILED: 
testLoadFeature(no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest)
 , cause: expected:<2> but was:<1>"
  
https://gist.github.com/steinarb/941996be35b53cb6f66a4535ba5bb4ae#file-karaf-log-L395

 Then: "FAILED: 
testLoadFeature(no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest)
 , cause: expected:<1> but was:<2>"
  
https://gist.github.com/steinarb/941996be35b53cb6f66a4535ba5bb4ae#file-karaf-log-L432

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87o7ewsjev.fsf%40dod.no.


Re: Searching for bean gives classNotFoundException

2023-12-11 Thread Steinar Bang
This is clumsy, but it worked:

@Test
public void testLoadFeature() throws Exception { // NOSONAR this test has 
an assert, just not an assert sonar recognizes
installAndAssertFeature("karaf-liquibase-sample-datasource-receiver");
var service = 
getOsgiService(SampleLiquibaseDatasourceReceiverService.class);
var initialAccounts = service.accounts();
assertEquals(1, initialAccounts.size());
var initialAccount = initialAccounts.get(0);
assertEquals("jod", initialAccount.getUsername());
var newAccount = Account.with().username("jad").build();
var accountsAfterAdd = service.addAccount(newAccount);
assertEquals(2, accountsAfterAdd.size());
Account addedAccount = null;
for (var a : accountsAfterAdd) {
if ("jad".equals(a.getUsername())) {
addedAccount = a;
}
}
assertEquals(initialAccount.getId() + 1, addedAccount.getId());
assertEquals("jad", addedAccount.getUsername());
}

So I guess it has something to do with function scopes?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87sf48sl2y.fsf%40dod.no.


Re: Searching for bean gives classNotFoundException

2023-12-11 Thread Steinar Bang
So I tried a simple for loop instead:
@Test
public void testLoadFeature() throws Exception { // NOSONAR this test has 
an assert, just not an assert sonar recognizes
installAndAssertFeature("karaf-liquibase-sample-datasource-receiver");
var service = 
getOsgiService(SampleLiquibaseDatasourceReceiverService.class);
var initialAccounts = service.accounts();
assertEquals(1, initialAccounts.size());
var initialAccount = initialAccounts.get(0);
assertEquals("jod", initialAccount.getUsername());
var newAccount = Account.with().username("jad").build();
var accountsAfterAdd = service.addAccount(newAccount);
assertEquals(2, accountsAfterAdd.size());
var addedAccount = findAccountWithUsername(accountsAfterAdd, "jad");
assertEquals(initialAccount.getId() + 1, addedAccount.getId());
assertEquals("jad", addedAccount.getUsername());
}

private Account findAccountWithUsername(List accounts, String 
username) {
for (var a : accounts) {
if (username.equals(a.getUsername())) {
return a;
}
}

return null;
}

But that gave me the same ClassNotFoundException:
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.943 s 
<<< FAILURE! - in 
no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest
[ERROR] 
testLoadFeature(no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest)
  Time elapsed: 0.068 s  <<< ERROR!
java.lang.ClassNotFoundException: 
no.priv.bang.karaf.liquibase.sample.services.Account not found by 
PAXEXAM-PROBE-a4ad3d47-fbfa-48c6-a000-2a24fed9ffbf [77]

How come I can call Account.getUsername() in an assert but not in code
that iterates through a for loop?

When outputing trace debug I was able to call Account.toString() just fine.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87wmtkslil.fsf%40dod.no.


Searching for bean gives classNotFoundException

2023-12-11 Thread Steinar Bang
I need some pax exam help.

I get a ClassNotFoundException I don't know how to fix.

I can access the bean Account for use in asserts without errors.

But once I use stream, filter and findFirst to find a particular account
I get ClassNotFoundException on the account.

I have the following pax exam test:
 
https://github.com/steinarb/liquibase-karaf-feature/blob/master/liquibase-integration-test/karaf.liquibase.tests/src/test/java/no/priv/bang/karaf/liquibase/tests/LiquibaseKarafFeatureIntegrationTest.java#L55

Here I access beans of type Account in the pax exam test.

However if I try searching for a bean using stream and filter, like this:
@Test
public void testLoadFeature() throws Exception { // NOSONAR this test has 
an assert, just not an assert sonar recognizes
installAndAssertFeature("karaf-liquibase-sample-datasource-receiver");
var service = 
getOsgiService(SampleLiquibaseDatasourceReceiverService.class);
var initialAccounts = service.accounts();
assertEquals(1, initialAccounts.size());
var initialAccount = initialAccounts.get(0);
assertEquals("jod", initialAccount.getUsername());
var newAccount = Account.with().username("jad").build();
var accountsAfterAdd = service.addAccount(newAccount);
assertEquals(2, accountsAfterAdd.size());
var addedAccount = accountsAfterAdd.stream().filter(a -> 
"jad".equals(a.getUsername())).findFirst().orElseThrow();
assertEquals(initialAccount.getId() + 1, addedAccount.getId());
assertEquals("jad", addedAccount.getUsername());
}

Then I get the following error:
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.93 s 
<<< FAILURE! - in 
no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest
[ERROR] 
testLoadFeature(no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest)
  Time elapsed: 0.061 s  <<< ERROR!
java.lang.ClassNotFoundException: 
no.priv.bang.karaf.liquibase.sample.services.Account not found by 
PAXEXAM-PROBE-37daa15f-5c4f-4a37-b284-8ef8ac7cb232 [77]


I googled the error message and found this: https://stackoverflow.com/a/43009600

I have tried adding a probeConfiguration to the test, by adding this
method to the test:

@ProbeBuilder
public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
probe.setHeader(Constants.IMPORT_PACKAGE, 
"*,no.priv.bang.karaf.liquibase.sample.services.*");
return probe;
}

But that just gave me a different error message:
ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 13.32 s 
<<< FAILURE! - in 
no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest
[ERROR] no.priv.bang.karaf.liquibase.tests.LiquibaseKarafFeatureIntegrationTest 
 Time elapsed: 11.865 s  <<< ERROR!
java.lang.RuntimeException: Bundle cannot be installed
Caused by: org.osgi.framework.BundleException: Unable to resolve 
PAXEXAM-PROBE-20d166e8-9d0f-41f0-86b8-79228ed20833 [77](R 77.0): missing 
requirement [PAXEXAM-PROBE-20d166e8-9d0f-41f0-86b8-79228ed20833 [77](R 77.0)] 
osgi.wiring.package; 
(osgi.wiring.package=no.priv.bang.karaf.liquibase.sample.services.*) Unresolved 
requirements: [[PAXEXAM-PROBE-20d166e8-9d0f-41f0-86b8-79228ed20833 [77](R 
77.0)] osgi.wiring.package; 
(osgi.wiring.package=no.priv.bang.karaf.liquibase.sample.services.*)]

Does anyone know why I get the ClassNotFoundException when I use the
stream, but not when accessing the Account variables in the asserts?

Does anyone know what to do to fix this?

Thanks!

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/871qbsu8oj.fsf%40dod.no.


Re: Wrong assert displayed as failing when having a failing assert

2023-06-27 Thread Steinar Bang
> Grzegorz Grzybek :
>> Where does the log affected by this config end up?

> It should be a test log from Pax Exam itself in target directory of Maven
> module: target/logs/pax-exam-test.log

I wasn't able to make it work, unfortunately.

I did the following:
 1. Added the log4j2-test.properties file to the /src/test/resources
directory of the integration test
 
https://github.com/steinarb/scratch/tree/liquibase-karaf-feature/add-debug-logging
 
https://github.com/steinarb/scratch/commit/27cdec12366fd7f6fd4cef481b9299756ff74015
 2, Ran "mvn clean install" on the project's top level

Unfortunately the target directory of the integration test doesn't seem
to have a logs subdirectory:

  
/home/sb/workspaces/liquibase-karaf-feature/liquibase-integration-test/karaf.liquibase.tests/target:
  total used in directory 48 available 371.1 GiB
  drwxr-xr-x 10 sb sb 4096 Jun 27 19:17 .
  drwxr-xr-x  5 sb sb 4096 Jun 27 19:16 ..
  drwxr-xr-x  3 sb sb 4096 Jun 27 19:16 classes
  drwxr-xr-x  3 sb sb 4096 Jun 27 19:16 exam
  drwxr-xr-x  3 sb sb 4096 Jun 27 19:16 generated-test-sources
  drwxr-xr-x  2 sb sb 4096 Jun 27 19:17 javadoc-bundle-options
  -rw-r--r--  1 sb sb 5236 Jun 27 19:17 
karaf.liquibase.tests-4.19.1-SNAPSHOT.jar
  drwxr-xr-x  2 sb sb 4096 Jun 27 19:17 maven-archiver
  drwxr-xr-x  3 sb sb 4096 Jun 27 19:16 maven-status
  drwxr-xr-x  2 sb sb 4096 Jun 27 19:16 surefire-reports
  drwxr-xr-x  4 sb sb 4096 Jun 27 19:16 test-classes

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87sfacak5c.fsf%40dod.no.


Re: Wrong assert displayed as failing when having a failing assert

2023-06-24 Thread Steinar Bang
> Grzegorz Grzybek :

> Hello
> Sorry, but I didn't have time to check/run your integration tests.
> You've mentioned that the test may be run twice - that's possible depending
> on the configuration of maven-surefire/failsafe-plugin. I don't know.
> Usually in such cases I turn on quite detailed logging, so I can see how
> all the threads interact. For example in Pax Web I use this logging
> configuration:
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.20/pax-web-itest/pax-web-itest-karaf/src/test/resources/log4j2-test.properties#L38

> appender.file.layout.pattern = %d{HH:mm:ss.SSS} [%thread] %-5level (%F:%L)
> %logger - %msg%n

Thanks!

Where does the log affected by this config end up?

I assume it isn't the karaf.log of the started karaf instance, and it
doesn't seem to affect the console log format?

> The most important part is to ensure you have full thread name (%thread),
> so you can see how the threads interact. I've detected many deadlocks and
> thread synchronization problems in last years simply by looking at the logs.

> If the green tests are fine, you're half way to success ;)

True. :-)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87edm1ulm7.fsf%40dod.no.


Re: Wrong assert displayed as failing when having a failing assert

2023-06-11 Thread Steinar Bang
>>>>> Steinar Bang :
>> You seem to be testing everything including verification of database
>> content. Getting assertion exceptions in your tests code _may_ lead to
>> transaction rollback (I have no idea if this is true - I'd have to see
>> your entire test setup).

> Maybe...? There shouldn't be any open transactions across the asserts or
> even across the methods called between the asserts.

> I wrap all of my read and write interactions with JDBC in a
> try-with-resource for a JDBC Connection instance.

I think it is related to the test somehow being run twice, when an
assert fails...?

That would explain both the non-causal behaviour of breaking a late
assert making an earlier assert fail, and the database constraints
failure caused by trying to add the same username twice (see other,
related thread).

I think maybe, if I make each run of the integration test have an unique
database name, then both the weird non-causal asserts, and the database
constraint failures will go away, and then, maybe, the correct failing
assert will be highlighted.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87o7lmgla7.fsf%40dod.no.


Re: How to fix ClassNotFoundExceptions for exceptions thrown in pax exam test?

2023-06-07 Thread Steinar Bang
> Grzegorz Grzybek :

> `RemoteBundleContextClientImpl` in the stack trace means that it (the stack
> trace) comes from client side of the test.

> Pax Exam is not difficult if it comes about writing @Test-annotated
> methods, but it is very difficult when trying to set everything up
> correctly, so jars not conflict with actual bundles and client/server side
> of things behaves as expected.

> In your stack trace you obviously miss the exception class on client-side
> classpath (when running from Eclipse).

Thanks!  When posting this message I thought I had tried adding a maven
dependency to the project (which should be the client side) and it
didn't work.

But maybe I added the wrong dependency, because when I later tried
adding a dependency, the classNotFound exception went away and I got the
underlying database constraint violation instead.
 
https://github.com/steinarb/liquibase-karaf-feature/commit/fff4b1a0ff88cc2270fe4934e5ec50cc9347e094

And when I fixed it in this way, I forgot about this message to the
mailing list.

On a side note: the constraint violation here is related to the "wrong
assert triggered".

Like you said, this may be caused by database rollback in some way, but
I don't see how this could be caused by the asserts, since the asserts
happens outside of the try-with-resource clauses determining the life
cycle of the JDBC Connection instances interacting with the database.

If I get a constraint violation here there is really only one thing that
could cause it, and that would be me trying to add the same account
username twice.

And my integration test only add the account once.

One thing that would cause this would be if the test itself is run more
than once against the same database.

Could a failing assert cause the test to be re-run somehow?

> To be honest I never run such tests from Eclipse/IDEA, I always run
> from Maven (surefire/failsafe) and do a remote debugging. You can
> debug Maven, surefire itself or Karaf container started from surefire
> (3 separate JVMs involved...).

The test here was originally a minimal karaf application I used to test
my liquibase feature.  But testing the feature manually was boring, so I
decided to automate it and put the automated test into the maven build
of the fature.

If I want to test the application in a regular karaf instance, where I
can easily debug, I can still load the feature from the integration
test:
 
https://github.com/steinarb/liquibase-karaf-feature#testing-and-debugging-in-karaf

See the neighbouring thread for a description of the integration test.

> In your case I'd first look at the server side logs - you're running
> pax-exam-container-karaf, so you should have logs in the Karaf instance
> started by Pax Exam - don't forget to call
> org.ops4j.pax.exam.karaf.options.KarafDistributionOption#keepRuntimeFolder()
> in your Pax Exam configuration method.

The karaf.log of the pax exam test had the
org.apache.derby.shared.common.error.DerbySQLIntegrityConstraintViolationException
with the actual constraints message.

> And to really get
> org.apache.derby.shared.common.error.DerbySQLIntegrityConstraintViolationException
> at client side, be sure to have Derby driver on the classpath.

Yep.  Just had to add the right derby dependency...

Thanks!

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87mt1bhrbx.fsf%40dod.no.


Re: Wrong assert displayed as failing when having a failing assert

2023-06-07 Thread Steinar Bang
> Grzegorz Grzybek :

> Hello
> I'd like to help, but seeing this in your shared test:

> final MavenArtifactUrlReference sampleappFeatureRepo = maven()
>> .groupId("no.priv.bang.karaf")
>> .artifactId("karaf.liquibase.sample.datasource.receiver")
>> 

> doesn't help - this is your private artifact and you'd have to share entire
> project and not a @Test method.

Ah, sorry!  It is the integration test for my liquibase karaf feature
 https://github.com/steinarb/liquibase-karaf-feature

Liquibase is a database migration tool, similar to flyway.

The integration test is here:
 
https://github.com/steinarb/liquibase-karaf-feature/tree/master/liquibase-integration-test

The test consists of three OSGi bundles and a karaf pax exam test that
loads the feature, and tries to use the database enough to prove that
the loaded feature actually works and can be used to create a database
schema.

The integration test used to be just loading the feature, but I found
out a while back that that was not enough to signal if the new karaf
release I was creating was actually working in an OSGi context: create a
row in a database and reading the results back.

So now the test consists of three bundles:
 karaf.liquibase.sample
  Contains a pax jdbc PreHook DS component

 karaf.liquibase.sample.services
  The OSGi service used in the pax exam test to add data to the database
  and read data back from the database

 karaf.liquibase.sample.datasource.receiver
  Contains a DS component exposing the OSGi service used in the karaf
  pax exam test, with feature dependencies to both of the above bundles'
  attached feature repositories

 karaf.liquibase.tests
  The karaf pax exam test where the asserts are weird

> I completely support red-green-red-green-... cycle. But I'm pretty sure
> Martin Fowler didn't have integration tests in mind. It was about unit
> tests.

Oh I agree, but it looked like a JUnit test, and when the behaviour got
weird I started looking for problems in the code being executed by the
test (and this code is just dummy code, since what I'm trying to do is
verify that the liquibase loaded by the karaf feature is actually able
to create a database schema).

> You seem to be testing everything including verification of database
> content. Getting assertion exceptions in your tests code _may_ lead to
> transaction rollback (I have no idea if this is true - I'd have to see
> your entire test setup).

Maybe...? There shouldn't be any open transactions across the asserts or
even across the methods called between the asserts.

I wrap all of my read and write interactions with JDBC in a
try-with-resource for a JDBC Connection instance.

> I can't help with any particular issue here - I recommend you to check
> Karaf's own Pax Exam integration tests:
> https://github.com/apache/karaf/tree/main/itests/test - see how the tests
> are structured.
> I also can suggest Pax Web tests where I tried very hard to put as many
> comments/explanations I could:
> https://github.com/ops4j/org.ops4j.pax.web/tree/main/pax-web-itest/pax-web-itest-karaf

Thanks!

FWIW the pax exam test works fine for me, when all of the asserts are green.

It's just the 

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87r0qnhs8l.fsf%40dod.no.


Wrong assert displayed as failing when having a failing assert

2023-06-04 Thread Steinar Bang
Platform: debian 11.7 "bullseye", amd64
  openjdk-17-jdk:amd64 17.0.6+10-1~deb11u1 (ie. java 17)
  karaf 4.4.3
  pax-exam 4.13.5
  eclipse  2023-03 (4.27.0)

What I usually do when creating JUnit tests is to run in a
red-green-red-green... rythm, the way Martin Fowler taught me.

I.e. I create the test first to be failing and then I make the test
green, create a new failure situation, fix the failure to make the test
green and so on.

When doing this on a pax exam test I saw some weird behaviour: the first
assert in the test was failing, and when I changed the expected value to
satisfy the test, the assert failed in the opposite way.

When I commented out the test, the test failed in an even more drastic
way: it failed in uniqueness constraints in the derby database used in
the test.

And the behaviour was completely repeatable, remove this and see this
error.  I got the same behaviour inside eclipse as I did when running
with surefire in maven.

So I figured there had to be some bug in my code: some value or array
that was reused somehow, and I spent some time digging into that without
being able to figure it out.  As far as I could tell I created new
ArrayLists containing new data objects.

I eventually figured it had to be related to my new
expected-to-be-failing asserts: and when I made them green, the entire
test ran green.

I tought that was weird and google found me nothing, so I thought I'd
ask here: is triggering the wrong assert when having a failing assert,
normal behaviour in pax exam?

Or is it just me? :-)

Here is what happened/happens (I can reproduce this behaviour at will):

Here is my test: 
https://gist.github.com/steinarb/fbfb78c8b69a61c92d66bde6b9994573

If I change the assert on line 32 to fail, ie.: 
https://gist.github.com/steinarb/ecdf40e201c85b671e301e9fea5a09e5
(change "jad" in the expected value to be "jod")
then what fails, is the assert on line 24, ie
assertEquals(1, initialAccounts.size());

The failure stack trace looks like this: 
https://gist.github.com/steinarb/5792ab35596e47cbca8f086a9bcfde2b

If I change the expected value on line 24 from 1 to 2, ie.
assertEquals(2, initialAccounts.size());
then the test fails because it gets 1 when 2 is expected (ie. you can't win! 
:-) )
 https://gist.github.com/steinarb/8b971ee7729bcaeecfdbc2254b8f9caf

If I comment out the first assert, ie. like this:
//assertEquals(2, initialAccounts.size());
then I get an DerbySQLIntegrityConstraintViolationException exception
that has deserialization issues, but is a constraints error in the table
(what I would get if I tried ti insert an account with an existing
username)
 https://gist.github.com/steinarb/ce5f845ca7d67754281b1f42f35fa92e

If I continue to comment out asserts further downn in the test I
continue to get DerbySQLIntegrityConstraintViolationException
exceptions.

But if I change all asserts so that they are green, then everything runs
normal.

Weird!

The project with the karaf pax exam integration test, is here:
 https://github.com/steinarb/liquibase-karaf-feature

The pax exam test is here:
 
https://github.com/steinarb/liquibase-karaf-feature/blob/master/liquibase-integration-test/karaf.liquibase.tests/src/test/java/no/priv/bang/karaf/liquibase/tests/LiquibaseKarafFeatureIntegrationTest.java

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87mt1fjhiz.fsf%40dod.no.


How to fix ClassNotFoundExceptions for exceptions thrown in pax exam test?

2023-06-03 Thread Steinar Bang
Platform: debian 11.7 "bullseye", amd64
  openjdk-17-jdk:amd64 17.0.6+10-1~deb11u1 (ie. java 17)
  karaf 4.4.3
  pax-exam 4.13.5
  eclipse  2023-03 (4.27.0)

I am trying to run a pax exam test that runs a liquibase changelist to
set up a schema and then add a row to a table in that schema and reads
it back out.

What I'm trying to do is add more asserting to this test to verify that
the database schema was actually created and is working:
 
https://github.com/steinarb/liquibase-karaf-feature/blob/master/liquibase-integration-test/karaf.liquibase.tests/src/test/java/no/priv/bang/karaf/liquibase/tests/LiquibaseKarafFeatureIntegrationTest.java#L55

When the tests fails in the database I get a classnotfoundexception on 
org.apache.derby.shared.common.error.DerbySQLIntegrityConstraintViolationException
and the following stack trace:
 https://gist.github.com/steinarb/e80ec79aa66bf48e58e441d172931989

Is it possible to get a stack trace for the actual failure, instead of a
stack trace for not finding the exception class (which this seems to
be...?).

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87a5xglcvd.fsf%40dod.no.


Re: Will ServletContext OSGi service injections be available in the OSGi 7 compatible web whiteboard

2020-04-02 Thread Steinar Bang
Injection of ServletContext worked (as can be seen earlier in this
thread).

But it turns out it wasn't needed because the Shiro AbstractFilter class[1]
extends ServletContextSupport[2], and saves the ServletContext when
receiving the FilterConfig[3].

So shiro filters already have the ServletContext (and automatically get
the right one).

References:
 [1] 

 [2] 

 [3] 


-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/867dyxsx9e.fsf%40dod.no.


Re: Will ServletContext OSGi service injections be available in the OSGi 7 compatible web whiteboard

2020-03-23 Thread Steinar Bang
>>>>> Steinar Bang :

>> [snip!]
>>> objectClass = [javax.servlet.ServletContext]
>>> osgi.web.contextname = authservice
>>> osgi.web.contextpath = /authservice
>>> osgi.web.symbolicname = no.priv.bang.authservice.web.security

>>> Hm... so why don't I get service injections when trying to filter on the 
>>> properties

>> Because I tried the following:
>> osgi.web.symbolicname=authservice
>> osgi.web.contextpath=/authservice

>> It's pretty obvious why osgi.web.symbolicname didn't work. :-)

>> But osgi.web.contextpath should have worked.  Why didn't it work?  Did I
>> fool myself while testing?  I think I will try that one again.

> Didn't help.
>  @Reference(target = "(osgi.web.webcontext=/authservice)")
> doesn't match.

> A breakpoint in the setter is never triggered and the bundle is never
> activated (since the reference isn't satisfied).

I started thinking maybe it was the leading / on the match value that
was the problem? Maybe the / has special significance for the LDAP
syntax? Maybe the match has to start with an alphanumeric character...?
Or something...?

So I tried
@Reference(target = "(osgi.web.contextname=authservice)")
and that worked just fine: the setter was called and the @Activate
method was called and the bundle became active.

The problem with using this was that osgi.web.contextname wasn't in the
list of properties mentioned in what I assume will be the next
generation of the web web whiteboard.

So what to do?

Presumably
@Reference(target = 
"(osgi.web.symbolicname=no.priv.bang.authservice.web.security)")
will also work, but I don't like it (it's long, cluttered and sort of
misleading)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86ftdyu566.fsf%40dod.no.


Re: Will ServletContext OSGi service injections be available in the OSGi 7 compatible web whiteboard

2020-03-23 Thread Steinar Bang
>>>>> Steinar Bang :

> [snip!]
>> objectClass = [javax.servlet.ServletContext]
>> osgi.web.contextname = authservice
>> osgi.web.contextpath = /authservice
>> osgi.web.symbolicname = no.priv.bang.authservice.web.security

>> Hm... so why don't I get service injections when trying to filter on the 
>> properties

> Because I tried the following:
>  osgi.web.symbolicname=authservice
>  osgi.web.contextpath=/authservice

> It's pretty obvious why osgi.web.symbolicname didn't work. :-)

> But osgi.web.contextpath should have worked.  Why didn't it work?  Did I
> fool myself while testing?  I think I will try that one again.

Didn't help.
 @Reference(target = "(osgi.web.webcontext=/authservice)")
doesn't match.

A breakpoint in the setter is never triggered and the bundle is never
activated (since the reference isn't satisfied).

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86k13au725.fsf%40dod.no.


Re: Will ServletContext OSGi service injections be available in the OSGi 7 compatible web whiteboard

2020-03-23 Thread Steinar Bang
>>>>> Steinar Bang :
[snip!]
> objectClass = [javax.servlet.ServletContext]
> osgi.web.contextname = authservice
> osgi.web.contextpath = /authservice
> osgi.web.symbolicname = no.priv.bang.authservice.web.security

> Hm... so why don't I get service injections when trying to filter on the 
> properties

Because I tried the following:
 osgi.web.symbolicname=authservice
 osgi.web.contextpath=/authservice

It's pretty obvious why osgi.web.symbolicname didn't work. :-)

But osgi.web.contextpath should have worked.  Why didn't it work?  Did I
fool myself while testing?  I think I will try that one again.

osgi.web.contextname sounds like the one I would like to filter on, but
it's not listed here:
 https://osgi.org/specification/osgi.cmpn/7.0.0/service.war.html#i3078599

Does that mean that it is deprecated?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86o8snszjd.fsf%40dod.no.


Re: Will ServletContext OSGi service injections be available in the OSGi 7 compatible web whiteboard

2020-03-23 Thread Steinar Bang
> Grzegorz Grzybek :

> As you can see, the properties you're looking for are there. Please
> check `bundle-services -p` command (or Karaf 4 equivalent) to check
> what can you filter by.

Thanks, Grzegorz!

Yep, the properties are present:

karaf@root()> bundle:services -p 63

Authentication webapp web whiteboard Shiro filter (63) provides:

component.id = 6
component.name = 
no.priv.bang.authservice.web.security.AuthserviceServletContextHelper
objectClass = [org.osgi.service.http.context.ServletContextHelper]
osgi.http.whiteboard.context.name = authservice
osgi.http.whiteboard.context.path = /authservice
service.bundleid = 63
service.id = 118
service.scope = bundle

objectClass = [javax.servlet.ServletContext]
osgi.web.contextname = authservice
osgi.web.contextpath = /authservice
osgi.web.symbolicname = no.priv.bang.authservice.web.security
osgi.web.version = 1.12.0.SNAPSHOT
service.bundleid = 63
service.id = 133
service.scope = singleton

component.id = 5
component.name = no.priv.bang.authservice.web.security.AuthserviceServlet
objectClass = [javax.servlet.Servlet]
osgi.http.whiteboard.context.select = 
(osgi.http.whiteboard.context.name=authservice)
osgi.http.whiteboard.servlet.name = authservice
osgi.http.whiteboard.servlet.pattern = /*
service.bundleid = 63
service.id = 148
service.scope = bundle
karaf@root()>

Hm... so why don't I get service injections when trying to filter on the 
properties

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86sghzt0r2.fsf%40dod.no.


Re: Will ServletContext OSGi service injections be available in the OSGi 7 compatible web whiteboard

2020-03-22 Thread Steinar Bang
> Grzegorz Grzybek :

>> Will it be possible to get a ServletContext OSGi service injected into a
>> @Reference, when using the web whiteboard of OSGi 7?
>> 

> Sure - it's described in 128.3.4 Publishing the Servlet Context chapter of
> CMPN specification and I think it should already be a case (at least that's
> what I remember from JBoss Fuse (based on Karaf)).

Thanks Grzegorz!

I've been successful in injecting the service, but not in filtering to
get the right service.

I got injections in this variant:
@Reference
public void setServletContext(ServletContext context) {
this.context = context;
}

But I got no injections in:
@Reference(target = "(osgi.web.symbolicname=authservice)")
public void setServletContext(ServletContext context) {
this.context = context;
}

And I got no injections in:
@Reference(target = "(osgi.web.contextpath=/authservice)")
public void setServletContext(ServletContext context) {
this.context = context;
}

The ServletContextHelper creating the context, is:
@Component(
property= {
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME+"=authservice",
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH+"=/authservice"},
service=ServletContextHelper.class,
immediate=true
)
public class AuthserviceServletContextHelper extends ServletContextHelper { }

> About actual Whiteboard R7 annotations - support for those has yet to be
> added to Pax Web.

Looking forward to this happening.

Thanks again!

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86zhc8t1ji.fsf%40dod.no.


Will ServletContext OSGi service injections be available in the OSGi 7 compatible web whiteboard

2020-02-11 Thread Steinar Bang
I'm currently using shiro 1.5.0 with web whiteboard in karaf 4.2.8.

I'm using some deprecated Shiro classes to set up shiro, and I want to
get rid of using the deprecated classes.

The first snag I've encountered when replacing the deprecated classes is
that the IniWebEnvironment class needs a ServletContext reference, and
that's not something I have.

In the karaf 4.2.8 version of the whiteboard I create a
ServletContextHelper DS component to create the context the servlets and
filters relate to.

But the ServletContextHelper doesn't implement the ServletContext
interface, so I can't use that with the IniWebEnviroment.

Will it be possible to get a ServletContext OSGi service injected into a
@Reference, when using the web whiteboard of OSGi 7?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86o8u5165h.fsf%40dod.no.


Re: Derby is looking for assistance with OSGi compatibility

2019-10-19 Thread Steinar Bang
> "'Mark Raynsford' via OPS4J" 
> :

> Yes, I'm going to get the OSGi headers into the published Derby
> artifacts (at a minimum) this weekend. Implementing the OSGi JDBC
> service also looks pretty easy, so I'll be attempting that too.

Another nice thing to have for us karaf users, is if the JDBC service
has a karaf feature it can be loaded and activated with.

For reference: Here's my issue and PR to the PostgreSQL JDBC maintainers
that was accepted into version 42.2.7 of the PostgreSQL JDBC driver:
 https://github.com/pgjdbc/pgjdbc/issues/1552
 https://github.com/pgjdbc/pgjdbc/pull/1554

(I'm also a derby user.  I use in-memory derby from pax-jdbc for test
databases and PostgreSQL for production use.  I use liquibase to set up
the schema and initial data for both derby and PostgreSQL)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/861rv9mag3.fsf%40dod.no.


Re: Problems running pax exam with openjdk-11

2019-06-18 Thread Steinar Bang
> Freeman Fang :

> You run into this error when building latest karaf master branch with JDK11?

Yes.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/867e9ioqjm.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-17 Thread Steinar Bang
> Freeman Fang :

> FYI, I’m using OpenJDK11, Karaf tests work for me with OpenJDK11
> Btw, my env is

> Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 
> 2018-10-24T14:41:47-04:00)
> Maven home: /Users/ffang/kit/apache-maven-3.6.0
> Java version: 11, vendor: Oracle Corporation, runtime: 
> /Users/ffang/kit/jdk-11.jdk/Contents/Home
> Default locale: en_CA, platform encoding: UTF-8
> OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
> More details for java version

> java -version
> openjdk version "11" 2018-09-25
> OpenJDK Runtime Environment 18.9 (build 11+28)
> OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

That's very similar to my setup:
 1. same maven version (3.6.0)
 2. slightly older (I think) openjdk-11 than what I have:
 sb@lorenzo:~$ java -version
 openjdk version "11.0.3" 2019-04-16
 OpenJDK Runtime Environment (build 11.0.3+7-Debian-1bpo92)
 OpenJDK 64-Bit Server VM (build 11.0.3+7-Debian-1bpo92, mixed mode, 
sharing)
 3. same processor architecture
 4. different os, but both are unix'is systems, and file and socket
operations and semantics should be similare, virtual management
semantics should be similar, so I doubt that make any difference

Hm...  I basically have no idea what's missing in my setup...:-)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86fto8net8.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-16 Thread Steinar Bang
> Jean-Baptiste Onofré 
> :

> Did you try with a clean maven repo ?

Yes.
 rm -rf ~/.m2/repository
 cd ~/workspaces/karaf/karaf
 git checkout master
 mvn clean install

Fails in this integration test:
 ...
 [INFO] Running org.apache.karaf.itests.EquinoxTest
 2019-06-16 19:20:40,563 | INFO  | j.pax.exam.spi.DefaultExamSystem  127 | Pax 
Exam System (Version: 4.13.1) created.
 2019-06-16 19:20:40,596 | INFO  | .pax.exam.junit.impl.ProbeRunner   74 | 
creating PaxExam runner for class org.apache.karaf.itests.EquinoxTest
 Port 1099 not available, trying next one
 Port 4 not available, trying next one
 Port 8101 not available, trying next one
 2019-06-16 19:20:40,625 | INFO  | .pax.exam.junit.impl.ProbeRunner   94 | 
running test class org.apache.karaf.itests.EquinoxTest
 2019-06-16 19:20:40,626 | INFO  | iner.internal.KarafTestContainer  142 | 
Creating RMI registry server on 127.0.0.1:21000
 2019-06-16 19:20:41,124 | INFO  | iner.internal.KarafTestContainer  205 | 
Found 0 options when requesting OverrideJUnitBundlesOption.class
 2019-06-16 19:20:41,147 | INFO  | iner.internal.KarafTestContainer  258 | Wait 
for test container to finish its initialization [ RelativeTimeout value = 
18 ]
 2019-06-16 19:20:41,148 | INFO  | rn.RemoteBundleContextClientImpl  240 | 
Waiting for remote bundle context.. on 21000 name: 
dcc2fec6-4390-42c0-8255-7f7d24469da8 timout: [ RelativeTimeout value = 18 ]
 WARNING: package org.apache.karaf.specs.locator not in java.base
 Error starting karaf activator org.apache.karaf.specs.activator.Activator: 
org/apache/karaf/specs/locator/OsgiLocator

 EquinoxTest: simpleTest
 info
 2019-06-16 19:21:16,853 | INFO  | exam.spi.reactors.ReactorManager  444 | 
suite finished
 [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 36.407 
s - in org.apache.karaf.itests.EquinoxTest
 [INFO] 
 [INFO] Results:
 [INFO] 
 [ERROR] Errors: 
 [ERROR]   RestExampleTest.testWithCxfClient » WrappedTestContainer 
[org.apache.karaf.ite...
 [INFO] 
 [ERROR] Tests run: 284, Failures: 0, Errors: 1, Skipped: 5

> It's certainly an environment issue as both Jenkins at Apache and my
> machine are ok.

Could you share some details about your build environments? OS? maven
version?  Java version?

> By the way, both machines use jdk 11.0.3 (Oracle).

Hm... that could be the difference.

But I would still like to get things working with openjdk.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86sgs9nz7t.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-16 Thread Steinar Bang
> Jean-Baptiste Onofré 
> :

> You can't use Felix framework 6 as it's OSGi R7.

I switched to 5.6.12 which is the one that karaf master currently uses,
but got the same failure as with 6.0.3 ("Error installing bundle listed
in startup.properties..."). 

Stack trace included below.

> I will take a look on your branch. I can confirm that karaf itests,
> including pax jdbc work in itest.

Thanks!

I've tried building karaf (both the master branch and the jdk12 branch)
on my development system, and I get test errors, so it could be
something with my setup...?

My setup:
 debian 9.9 "stretch" (ie. current stable), amd64
 openjdk-11:amd64 11.0.3+1-1~bpo9+2 (installed with apt-get)
 maven 3.6.0 (installed from tar-ball)

Stack trace from pax exam startup failure:
Exception in thread "KarafEmbeddedRunner" java.lang.RuntimeException: 
java.lang.reflect.InvocationTargetException
at 
org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:96)
Caused by: java.lang.reflect.InvocationTargetException
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at 
org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:86)
Caused by: java.lang.RuntimeException: Error installing bundle listed in 
startup.properties with url: 
mvn:org.apache.karaf.features/org.apache.karaf.features.extension/4.2.5 and 
startlevel: 1
at org.apache.karaf.main.Main.installAndStartBundles(Main.java:530)
at org.apache.karaf.main.Main.launch(Main.java:273)
... 5 more
Caused by: org.osgi.framework.BundleException: Could not create bundle object.
at org.apache.felix.framework.Felix.installBundle(Felix.java:3095)
at 
org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:167)
at org.apache.karaf.main.Main.installAndStartBundles(Main.java:523)
... 6 more
Caused by: java.lang.UnsupportedOperationException: Unable to add extension 
bundle.
at 
org.apache.felix.framework.ExtensionManager.addExtensionBundle(ExtensionManager.java:439)
at org.apache.felix.framework.Felix.installBundle(Felix.java:3061)
... 8 more

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86d0jeoy9g.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-14 Thread Steinar Bang
> Freeman Fang :

> Hi,
> Please see the attached patch file, with it, that test can pass with jdk11.

Thanks!  No luck on my side, unfortunately...:-(

It still fails with the error messages below (However, I had to apply
everything except the top pom manually, and I may have done something
wrong...?
 
https://github.com/steinarb/scratch/commit/0e3f91871eadff73414879a165e3675a43143088)

I tried bumping felix framework to 6.0.3 but I still got the error
below.

...
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) @ authservice.tests 
---
[INFO] 
[INFO] ---
[INFO]  T E S T S
[INFO] ---
[INFO] Running no.priv.bang.authservice.tests.AuthserviceIntegrationTest
[org.ops4j.pax.exam.spi.DefaultExamSystem] : Pax Exam System (Version: 4.13.1) 
created.
[org.ops4j.store.intern.TemporaryStore] : Storage Area is /tmp/1560536800700-0
[org.ops4j.pax.exam.junit.impl.ProbeRunner] : creating PaxExam runner for class 
no.priv.bang.authservice.tests.AuthserviceIntegrationTest
[org.ops4j.pax.exam.spi.PaxExamRuntime] : Found TestContainerFactory: 
org.ops4j.pax.exam.karaf.container.internal.KarafTestContainerFactory
[org.ops4j.pax.exam.spi.DefaultExamSystem] : creating default probe
[org.ops4j.pax.exam.spi.reactors.ReactorManager] : No User defined probe hook 
found
[org.ops4j.pax.exam.spi.intern.DefaultTestAddress] : NEW ADDRESS= 
PaxExam-2efc4605-9051-47a5-bc0e-3c5676cb3145 parent=null 
root=[TestAddress:PaxExam-2efc4605-9051-47a5-bc0e-3c5676cb3145 
root:PaxExam-2efc4605-9051-47a5-bc0e-3c5676cb3145] 
args=[Ljava.lang.Object;@71a794e5
[org.ops4j.pax.exam.spi.DefaultExamReactor] : Staging reactor with probes: 1 
using strategy: org.ops4j.pax.exam.spi.reactors.PerClass@b59d31
[org.ops4j.store.intern.TemporaryStore] : Storage Area is /tmp/1560536800700-0
[org.ops4j.pax.exam.spi.intern.DefaultTestAddress] : NEW ADDRESS= 
PaxExam-dd25136e-4bdb-497a-ae3c-52e91e1c33e8 
parent=[TestAddress:PaxExam-2efc4605-9051-47a5-bc0e-3c5676cb3145 
root:PaxExam-2efc4605-9051-47a5-bc0e-3c5676cb3145] 
root=[TestAddress:PaxExam-2efc4605-9051-47a5-bc0e-3c5676cb3145 
root:PaxExam-2efc4605-9051-47a5-bc0e-3c5676cb3145] 
args=[Ljava.lang.Object;@12405818
[org.ops4j.pax.exam.junit.impl.ProbeRunner] : running test class 
no.priv.bang.authservice.tests.AuthserviceIntegrationTest
[org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Creating RMI 
registry server on 127.0.0.1:21000
[org.ops4j.store.intern.TemporaryStore] : Storage Area is /tmp/1560536800700-0
[org.ops4j.pax.url.mvn.internal.Connection] : Resolving 
[mvn:org.apache.karaf/apache-karaf/4.2.5/zip]
[shaded.org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider] : 
Using manager SimpleLocalRepositoryManager with priority 0.0 for 
/home/sb/.m2/repository Ignored FQCN: 
shaded.org.eclipse.aether.internal.impl.slf4j.Slf4jLoggerFactory$Slf4jLoggerEx
[org.ops4j.pax.url.mvn.internal.AetherBasedResolver] : Resolved 
(org.apache.karaf:apache-karaf:zip:4.2.5) as 
/home/sb/.m2/repository/org/apache/karaf/apache-karaf/4.2.5/apache-karaf-4.2.5.zip
[shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager] : 
Connection manager is shutting down Ignored FQCN: 
shaded.org.apache.commons.logging.impl.SLF4JLocationAwareLog
[shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager] : 
Connection manager shut down Ignored FQCN: 
shaded.org.apache.commons.logging.impl.SLF4JLocationAwareLog
[org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Found 0 
options when requesting OverrideJUnitBundlesOption.class
[org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Test 
Container started in 1 millis
[org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Wait for 
test container to finish its initialization [ RelativeTimeout value = 12 ]
[org.ops4j.pax.exam.rbc.client.RemoteBundleContextClient] : Waiting for remote 
bundle context.. on 21000 name: 77cb317d-cfc4-4e90-ba44-40c39fc860e7 timout: [ 
RelativeTimeout value = 12 ]
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by 
org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender
 
(file:/home/sb/workspaces/ws03/authservice/authservice.tests/target/exam/8330247c-009b-4577-98a0-e1d506c2cc2b/system/org/apache/felix/org.apache.felix.framework/5.6.12/org.apache.felix.framework-5.6.12.jar)
 to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of 
org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender
WARNING: Use --illegal-access=warn to enable warnings of further illegal 
reflective access operations
WARNING: All illegal access operations will be denied in a future release
[org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Shutting 
down the test container (Pax Runner)
[ERROR] Tests run: 2, 

Re: Problems running pax exam with openjdk-11

2019-06-08 Thread Steinar Bang
>>>>> Steinar Bang :

>>>>> Steinar Bang :
>> Side note: I did not intentionally use the eclipse OSGi framework for
>> the pax exam test.

>> I pulled in the pax-exam-container-karaf which does not pull in an OSGi
>> framework, and then needed to make a reference to the pax jdbc karaf
>> feature, which *does* have a (unintentional?) maven transitive
>> dependency to the eclipse OSGi framework, and then things started
>> working, and I didn't investigate anymore.

> So I tried using the same osgi framework I'm using for regular karaf
> usage
[snip!]
> But I just got a similar stack trace, but with "felix" instead of "eclipse" 
> in the package names:

I noticed that the osgi.core version 6.0.0 artifact I have been using, was 
pretty old (July 2014):
 https://mvnrepository.com/artifact/org.osgi/org.osgi.core

So I looked for OSGi 7 and found this:
 https://mvnrepository.com/artifact/org.osgi/osgi.core

The version 6.0.0 osgi.core artifact is from January 2015.
The version 7.0.0 osgi.core artifact is from April 2018.

I've tried with both of them, but got the same stack trace (or very
similar stack trace) as the org.osgi.core 6.0.0 framework (the one below
is from osgi.core 7.0.0):
Jun 08, 2019 9:17:26 AM org.apache.karaf.main.Main launch
INFO: Installing and starting initial bundles
Exception in thread "KarafEmbeddedRunner" java.lang.RuntimeException: 
java.lang.reflect.InvocationTargetException
at 
org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:96)
Caused by: java.lang.reflect.InvocationTargetException
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at 
org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:86)
Caused by: java.lang.RuntimeException: Error installing bundle listed in 
startup.properties with url: 
mvn:org.apache.karaf.features/org.apache.karaf.features.extension/4.2.5 and 
startlevel: 1
at org.apache.karaf.main.Main.installAndStartBundles(Main.java:530)
at org.apache.karaf.main.Main.launch(Main.java:273)
... 5 more
Caused by: org.osgi.framework.BundleException: Could not create bundle object.
at org.apache.felix.framework.Felix.installBundle(Felix.java:3078)
at 
org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:167)
at org.apache.karaf.main.Main.installAndStartBundles(Main.java:523)
... 6 more
Caused by: java.lang.UnsupportedOperationException: Unable to add extension 
bundle to FrameworkClassLoader - Maybe not an URLClassLoader?
at 
org.apache.felix.framework.ExtensionManager.addExtensionBundle(ExtensionManager.java:453)
at org.apache.felix.framework.Felix.installBundle(Felix.java:3044)
... 8 more

So this Java-11 change is possibly something that affects all OSGi 
frameworks...?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/861s04h71p.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-08 Thread Steinar Bang
>>>>> Steinar Bang :
>>>>> Freeman Fang 
>>>>> :

>> Hi,
>> If you can send a reproducer project which I can build and run to reproduce 
>> this problem, I will take a close look.

> git clone https://github.com/steinarb/authservice.git
> cd authservice
> git checkout work/use-java-11
> mvn clean install

> If your Java is java-11, then the maven build will fail in the
> authservice.tests project, that contains the pax exam test.

Side note: I did not intentionally use the eclipse OSGi framework for
the pax exam test.

I pulled in the pax-exam-container-karaf which does not pull in an OSGi
framework, and then needed to make a reference to the pax jdbc karaf
feature, which *does* have a (unintentional?) maven transitive
dependency to the eclipse OSGi framework, and then things started
working, and I didn't investigate anymore.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86a7esh8o6.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-07 Thread Steinar Bang
> Freeman Fang :

> Hi Steinar,
> Good catch, and this is a known issue in 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=515286 
> 

> And this issue has already been fixed.

Thanks for the info!  Good to hear! :-)

> To run your test with JDK11+eclipse, I think you should use

> 
> org.eclipse.tycho
> org.eclipse.osgi
> 3.13.0.v20180226-1711
> 
> Which contains the fix.

No luck, unfortunately.  

I get a different stack trace, but it still fails:

[org.ops4j.pax.exam.rbc.client.RemoteBundleContextClient] : Waiting for remote 
bundle context.. on 21000 name: 8b9e87d5-afb6-440e-8231-83de5e653557 timout: [ 
RelativeTimeout value = 72 ]
Jun 07, 2019 10:15:23 PM org.apache.karaf.main.Main launch
INFO: Installing and starting initial bundles
Exception in thread "KarafEmbeddedRunner" java.lang.RuntimeException: 
java.lang.reflect.InvocationTargetException
at 
org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:96)
Caused by: java.lang.reflect.InvocationTargetException
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at 
org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:86)
Caused by: java.lang.RuntimeException: Error installing bundle listed in 
startup.properties with url: 
mvn:org.apache.karaf.features/org.apache.karaf.features.extension/4.2.5 and 
startlevel: 1
at org.apache.karaf.main.Main.installAndStartBundles(Main.java:530)
at org.apache.karaf.main.Main.launch(Main.java:273)
... 5 more
Caused by: org.osgi.framework.BundleException: Could not create bundle object.
at org.apache.felix.framework.Felix.installBundle(Felix.java:3078)
at 
org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:167)
at org.apache.karaf.main.Main.installAndStartBundles(Main.java:523)
... 6 more
Caused by: java.lang.UnsupportedOperationException: Unable to add extension 
bundle to FrameworkClassLoader - Maybe not an URLClassLoader?
at 
org.apache.felix.framework.ExtensionManager.addExtensionBundle(ExtensionManager.java:453)
at org.apache.felix.framework.Felix.installBundle(Felix.java:3044)
... 8 more

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86imthgnfa.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-06 Thread Steinar Bang
>>>>> Steinar Bang :

>>>>> Steinar Bang :
>>> And the reason it tries to throw an exception tin the first place, is
>>> that ADD_FWK_URL_METHOD is because the "addUrl" method is missing from
>>> the URL class.

>> From the google searches I've made addUrl() hasn't appeared on the list
>> of removed stuff in java >= 9.

> And it looks like there was no URL.addUrl() method in the URL class of
> java-8:
>  https://docs.oracle.com/javase/8/docs/api/java/net/URL.html

Not sure if this is a karaf bug or a pax exam bug, but it is a bug when
running under java 11.

The method the code setting up ADD_FWK_URL_METHOD is looking for, isn't
a method on URL.

The code looks for, and doesn't find, the method
 sun.misc.Launcher.AppClassLoader#addUrl(java.net.URL)

So I googled for AppClassLoader and java 11 and found this:
 https://blog.codefx.org/java/java-11-migration-guide/#symptoms-2

With Java-11 AppClassLoader no longer is a URLClassLoader, and therefore
(presumably) no longer has an addUrl() method and that's why the pax
exam boot of OSGi fails.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86pnnqh2pj.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-02 Thread Steinar Bang
>>>>> Steinar Bang :

>> And the reason it tries to throw an exception tin the first place, is
>> that ADD_FWK_URL_METHOD is because the "addUrl" method is missing from
>> the URL class.

> From the google searches I've made addUrl() hasn't appeared on the list
> of removed stuff in java >= 9.

And it looks like there was no URL.addUrl() method in the URL class of
java-8:
 https://docs.oracle.com/javase/8/docs/api/java/net/URL.html

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/867ea3kjge.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-02 Thread Steinar Bang
>>>>> Steinar Bang :

> And the reason it tries to throw an exception tin the first place, is
> that ADD_FWK_URL_METHOD is because the "addUrl" method is missing from
> the URL class.

>From the google searches I've made addUrl() hasn't appeared on the list
of removed stuff in java >= 9.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86blzfkjnl.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-02 Thread Steinar Bang
>>>>> Steinar Bang :

>>>>> Steinar Bang :
>> I've added the VMOptions to the startup but I still get the same stack
>> trace, ie. a NullPointerException thrown from here:
>> public class FrameworkExtensionInstaller {
>> ...
>> void addExtensionContent0(Collection revisions, Module 
>> systemModule) throws BundleException {
>> if (CL == null || ADD_FWK_URL_METHOD == null) {
>> // use the first revision as the blame
>> ModuleRevision revision = revisions.isEmpty() ? null : 
>> revisions.iterator().next();
>> ==>  throw new BundleException("Cannot support framework 
>> extension bundles without a public addURL(URL) method on the framework class 
>> loader: " + revision.getBundle()); //$NON-NLS-1$
>> }

>> The exception happens in the throw, and the only thing I can see causing
>> the NPE, is that revisions isn't empty, but contains at least one null
>> element.

> Er no... the collection revision is empty so revision becomes null and
> fails in revision.getBundle() in the throw.

And the reason it tries to throw an exception tin the first place, is
that ADD_FWK_URL_METHOD is because the "addUrl" method is missing from
the URL class.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86ftosj7cx.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Problems running pax exam with openjdk-11

2019-06-02 Thread Steinar Bang
>>>>> Steinar Bang :

> I've added the VMOptions to the startup but I still get the same stack
> trace, ie. a NullPointerException thrown from here:
> public class FrameworkExtensionInstaller {
>   ...
>   void addExtensionContent0(Collection revisions, Module 
> systemModule) throws BundleException {
>   if (CL == null || ADD_FWK_URL_METHOD == null) {
>   // use the first revision as the blame
>   ModuleRevision revision = revisions.isEmpty() ? null : 
> revisions.iterator().next();
> ==>   throw new BundleException("Cannot support framework 
> extension bundles without a public addURL(URL) method on the framework class 
> loader: " + revision.getBundle()); //$NON-NLS-1$
>   }

> The exception happens in the throw, and the only thing I can see causing
> the NPE, is that revisions isn't empty, but contains at least one null
> element.

Er no... the collection revision is empty so revision becomes null and
fails in revision.getBundle() in the throw.

I made the following JIRA for the problem:
 https://ops4j1.jira.com/browse/PAXEXAM-927

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86k1e4jaa0.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Problems running pax exam with openjdk-11 (Was: Problems running pax exam with openjdk-8)

2019-06-02 Thread Steinar Bang
(hm... my mind crosswired and wrote the wrong subject, but it looks like
the meaning got though anyway... subject corrected)

> Freeman Fang :

> You need to add some VMOption by yourself, something like
[snip!]
> You can take a look at [1] to get more details about how we do it in Karaf.

> [1]https://github.com/apache/karaf/blob/master/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java

I'll give it a look and report back how it worked out. Thanks!

(the pax exam tests were the last thing keeping me on openjdk-11,
everything else seems to be working, up to and including running my
applications in karaf.  Debian has dropped openjdk-8 from their current
testing, meaning it will be gone from the next stable, and this
energized me into finally making the transition to "new-style Java")

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/86sgssjy49.fsf_-_%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Problems running pax exam with openjdk-8

2019-06-01 Thread Steinar Bang
This pax exam test, using the karaf runner, with karaf 4.2.5, runs with 
openjdk-8 but fails with openjdk-11:
 
https://github.com/steinarb/scratch/blob/authservice/use-java-11/authservice.tests/src/test/java/no/priv/bang/authservice/tests/AuthserviceIntegrationTest.java#L25

Will pax exam work with openjdk-11?  Should switching JDK have worked
out of the box?  Or will the test code or dependencies need to be
modified?

Here's the error message from the failing build:
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ authservice.tests 
---
[INFO] 
[INFO] ---
[INFO]  T E S T S
[INFO] ---
[INFO] Running no.priv.bang.authservice.tests.AuthserviceIntegrationTest
[org.ops4j.pax.exam.spi.DefaultExamSystem] : Pax Exam System (Version: 4.13.1) 
created.
[org.ops4j.store.intern.TemporaryStore] : Storage Area is /tmp/1559417194161-0
[org.ops4j.pax.exam.junit.impl.ProbeRunner] : creating PaxExam runner for class 
no.priv.bang.authservice.tests.AuthserviceIntegrationTest
[org.ops4j.pax.exam.spi.PaxExamRuntime] : Found TestContainerFactory: 
org.ops4j.pax.exam.karaf.container.internal.KarafTestContainerFactory
[org.ops4j.pax.exam.spi.DefaultExamSystem] : creating default probe
[org.ops4j.pax.exam.spi.reactors.ReactorManager] : No User defined probe hook 
found
[org.ops4j.pax.exam.spi.intern.DefaultTestAddress] : NEW ADDRESS= 
PaxExam-014331d4-de30-4465-8f96-892a167e3d09 parent=null 
root=[TestAddress:PaxExam-014331d4-de30-4465-8f96-892a167e3d09 
root:PaxExam-014331d4-de30-4465-8f96-892a167e3d09] 
args=[Ljava.lang.Object;@276438c9
[org.ops4j.pax.exam.spi.DefaultExamReactor] : Staging reactor with probes: 1 
using strategy: org.ops4j.pax.exam.spi.reactors.PerClass@7181ae3f
[org.ops4j.store.intern.TemporaryStore] : Storage Area is /tmp/1559417194161-0
[org.ops4j.pax.exam.spi.intern.DefaultTestAddress] : NEW ADDRESS= 
PaxExam-e162e3b7-1659-436b-9231-95d124345ca1 
parent=[TestAddress:PaxExam-014331d4-de30-4465-8f96-892a167e3d09 
root:PaxExam-014331d4-de30-4465-8f96-892a167e3d09] 
root=[TestAddress:PaxExam-014331d4-de30-4465-8f96-892a167e3d09 
root:PaxExam-014331d4-de30-4465-8f96-892a167e3d09] 
args=[Ljava.lang.Object;@2d127a61
[org.ops4j.pax.exam.junit.impl.ProbeRunner] : running test class 
no.priv.bang.authservice.tests.AuthserviceIntegrationTest
[org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Creating RMI 
registry server on 127.0.0.1:21000
[org.ops4j.store.intern.TemporaryStore] : Storage Area is /tmp/1559417194161-0
[org.ops4j.pax.url.mvn.internal.Connection] : Resolving 
[mvn:org.apache.karaf/apache-karaf-minimal/4.2.5/zip]
[shaded.org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider] : 
Using manager SimpleLocalRepositoryManager with priority 0.0 for 
/home/sb/.m2/repository Ignored FQCN: 
shaded.org.eclipse.aether.internal.impl.slf4j.Slf4jLoggerFactory$Slf4jLoggerEx
[org.ops4j.pax.url.mvn.internal.AetherBasedResolver] : Resolved 
(org.apache.karaf:apache-karaf-minimal:zip:4.2.5) as 
/home/sb/.m2/repository/org/apache/karaf/apache-karaf-minimal/4.2.5/apache-karaf-minimal-4.2.5.zip
[org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Found 0 
options when requesting OverrideJUnitBundlesOption.class
[shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager] : 
Connection manager is shutting down Ignored FQCN: 
shaded.org.apache.commons.logging.impl.SLF4JLocationAwareLog
[shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager] : 
Connection manager shut down Ignored FQCN: 
shaded.org.apache.commons.logging.impl.SLF4JLocationAwareLog
[org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Test 
Container started in 2 millis
[org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Wait for 
test container to finish its initialization [ RelativeTimeout value = 72 ]
[org.ops4j.pax.exam.rbc.client.RemoteBundleContextClient] : Waiting for remote 
bundle context.. on 21000 name: 274d833b-3fe3-4120-846b-e093d33a7543 timout: [ 
RelativeTimeout value = 72 ]
Exception in thread "KarafEmbeddedRunner" java.lang.RuntimeException: 
java.lang.reflect.InvocationTargetException
at 
org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:96)
Caused by: java.lang.reflect.InvocationTargetException
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at 
org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:86)
Caused by: java.lang.NullPointerException
at 

Re: Question to pax-jdbc devs: how do you handle DataSourceFactory bundle restart?

2019-06-01 Thread Steinar Bang
> Grzegorz Grzybek :

> Hello
> I added a comment to
> https://github.com/pgjdbc/pgjdbc/issues/1476#issuecomment-497635922

Thanks for working on this!

(I've worked around this by using a karaf feature to load the PostgreSQL
JDBC driver, because then I can avoid reloading the PostgreSQL JDBC
bundle when loading a new application needing it... most of the
time...:-) )

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/864l59ksbm.fsf%40dod.no.
For more options, visit https://groups.google.com/d/optout.


Re: Question to pax-jdbc devs: how do you handle DataSourceFactory bundle restart?

2019-05-01 Thread Steinar Bang
> 'Christoph Läubrich' via OPS4J 
> :

> DriverManger.register/unregister can't work reliable in OSGi
> (especially with static insitilizer), thus always the
> DataSourceFactory should be used instead!

PGDataSourceFactory is currently implemented using the regular PG JDBC
driver, ie. the Driver class, which in turn uses the DriverManager in
rt.jar.

So the fix should be to change the implementation of PGDataSourceFactory
to not use the Driver class via DriverManager?  Maybe
PGDataSourceFactory should create and own a Driver instance?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question to pax-jdbc devs: how do you handle DataSourceFactory bundle restart?

2019-04-30 Thread Steinar Bang
> Christian Schneider 
> :

> I see no calls to DriverManager in
> https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java

The DriverManager isn't called directly from the PGBundleActivator.

 1. DriverManager.registerDriver() is called from Driver.register()
 
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/Driver.java#L720
 2. Driver.register() is called from a static initializer in the Driver class
 
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/Driver.java#L72
 3. DriverManager.deregisterDriver() is called from Driver.deregister()
 
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/Driver.java#L737
 4. Driver.deregister() is called from the PGBundleActivator.stop() method
 
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java#L56

> It only registers and unregisters the DataSourceFactory service which looks
> correct.

Yes, that bit is correct, and populates to my DS components that has
@Reference to DatasourceFactory (the old service is unbound and the
activate methods are called using the new service).

> Not sure about the call to Driver.deregister though.
> This might cause the issue.

See comment in the issue
 https://github.com/pgjdbc/pgjdbc/issues/1476#issuecomment-487370634

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Question to pax-jdbc devs: how do you handle DataSourceFactory bundle restart?

2019-04-29 Thread Steinar Bang
I ran into a problem with the PostgreSQL JDBC driver running as an OSGi
bundle in karaf:
 https://github.com/pgjdbc/pgjdbc/issues/1476

In short: the bundle works before restart, but after restart
DataSouce.getConnection() is unable to find the JDBC driver.

I've debugged through what happens, and the PGBundleActivator() seems to
do the right thing:
 1. Call DriverManager.registerDriver() on bundle start
 2. Call DriverManagerderegisterDriver() on bundle stop
 3. Call DriverManager.registerDriver() again when the bundle restarts
(all of these in rt.jar)

However, after the second DriverManager.registerDriver() the 
DriverManager.getConnection(String url, java.util.Properties info, Class 
caller)
method fails because DriverManager.isDriverAllowed(Driver driver, ClassLoader 
classLoader)
fails (all of these in rt.jar).

And what fails in the isDriverAllowed() method is the comparison between
driver.getClass() and Class.forName(driver.getClass().getName()) fails.

Sounds like an OSGi classloader issue...?

How does the pax-jdbc bundles providing a DataSourceFactory handle JDBC
driver registration and unregistration?

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Announce] Shiro-based "poor man's SSO" for Apache Karaf applications

2019-04-15 Thread Steinar Bang
 https://github.com/steinarb/authservice

I wrote this to cover my own usecase, which was to have the same login
for nginx itself, as well as a couple of web whiteboard webapps running
in the same apache karaf, behind the nginx server through a reverse
proxy setup.

Cross-webapp SSO works by providing the shiro interfaces Realm[1] and
SessionDAO[2] as OSGi services to shiro web sessionmanagers.  

Nginx authentication is handled by providing an nginx with a URL
suitable for the nginx auth_request module[3], that shares Realm and
SessionDAO with the karaf webapps.

Authservice is based on Shiro 1.3.1 (I can't remember why it isn't
1.3.2.  I will try with 1.3.2 and if it works, release a new version of
authservice to maven central shortly), and it will be upgraded to the
first OSGi-friendly 1.4.x or 1.5 version released by Francois Papon.

The authservice license is Apache v2, and authservice has been deployed
to maven central.

To try it out:
 1. From a karaf console, give the following commands:
 feature:repo-add 
mvn:no.priv.bang.authservice/authservice/LATEST/xml/features
 feature:install authservice-with-derby-dbrealm-and-session
 2. Open the URL http://localhost:8181/authservice in a web browser and
log in with username/password: jad/1ad
 3. Verify that the "User administration UI" is inaccessible and use the
back button in the browser to get back to the main authservice page
 4. Click on the "Change your own password" link and try changing the
password
 5. After changing the password click on the back button in the browser
to get back to the main authservice page
Note: don't use the "Back to top" link because that links to two
levels up
 6. Click on the "Change your own email and real name" and try changing
them
 7. Click on the back button in the browser to get back to the main
authservice page (here also "Back to top" link, links two levelse
up, because both of these URLs are intended as self service URLs
linked to from the main nginx page)
 8. Click on "Logout" and then login again as username/password:
admin/admin
 9. Click on the "User administration UI" and try giving user jad the
useradmin role
10. Click on the "Up to authservice top" link and then click the
"Logout" link
11. Log in with username/password: jad/1ad
12. Verify that user jad now can use the "User administration UI"

The authservice-with-derby-dbrealm-and-session feature uses an in-memory
database that will disappear when karaf is stopped and restarted.

"Production" authservice uses PostgreSQL.


Authservice feature summary
 - Based on Apache Shiro
 - Apache Karaf application based on pax web whiteboard and OSGi Declarative
   Services (DS)
 - Plain HTML "self-service" pages for letting users change their
   passwords and personal information 
 - A small user administration UI written in react and styled with
   bootstrap v4
 - A Shiro JDBC realm that supports base64 encoded password salt
 - JDBC database schema and initial data setup provided by a liquibase
   script, which means that in theory any JDBC database supported by
   liquibase can be used to replace PosgreSQL (some code required, the
   README has suggestions)

References:
 [1] 

 [2] 

 [3] 

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Web whiteboard: is the order of filter and servlet registration signifikant?

2019-02-18 Thread Steinar Bang
> "'Achim Nierbeck' via OPS4J" 
> :

> afaik, at least I think I or someone else tried to implement it, the rank
> of a service is taken into account when
> registering a filter for a servlet. Servlets itself don't have a "Ordering"
> so the rank of the servlet filter can be used for odering.

FWIW the problem that made me wonder if the order was significant wasn't
related to the order of registration at all.

My problem was the way I was trying to set the PassThruAuthenticationFilter
 
https://github.com/steinarb/authservice/commit/c5d95243081f4ccda51c45c3e746c8d998d48aa7#diff-7919b6a74d97bc8ddad3b036272f147bL86

The original part of that diff sets PassThruAuthenticationFilter as
authc way too late.  It needs to be set befor the shiro.ini file is
parsed and loaded.

The way I got it working was setting PassThruAuthenticationFilter as in
the defaultbeans, instead of setting it explicitly.  Then it is used as
authc filter when the shiro.ini file is loaded and parsed.

The only thing I use from shiro.ini is the [urls] section.  I do the
config explicitly in code, because doing it from shiro.ini doesn't work
in an OSGi context (the classloader doesn't find the classes).
 
https://github.com/steinarb/authservice/blob/master/authservice.web.security/src/main/resources/shiro.ini

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Web whiteboard: is the order of filter and servlet registration signifikant?

2019-02-12 Thread Steinar Bang
(Here's another registration order question from me)

The question this time is about filters and servlets: must filters be
registered before the servlets they are filtering?  Or doesn't the order
of registration matter?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: web whiteboard construction order?

2019-01-13 Thread Steinar Bang
> "'Achim Nierbeck' via OPS4J" 
> :

> yes please open an issue for it ;)

Here is the issue:
 https://ops4j1.jira.com/browse/PAXEXAM-925

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need ops4j JIRA user to report a bug

2019-01-13 Thread Steinar Bang
> "'Achim Nierbeck' via OPS4J" 
> :

> Done,
> welcome aboard ;)

Thanks! :-)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Need ops4j JIRA user to report a bug

2019-01-11 Thread Steinar Bang
Hi,

I need an ops4j JIRA user to report a bug.

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: web whiteboard construction order?

2019-01-09 Thread Steinar Bang
> "'Achim Nierbeck' via OPS4J" 
> :

> Hi Steinar,
> yes please open an issue for it ;)

Will do! It looks like self service is switched off again. Could you
create a user for me.  This email address is fine.

Thanks!

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: web whiteboard construction order?

2019-01-09 Thread Steinar Bang
> "'Achim Nierbeck' via OPS4J" :

> Hi Steinar,
> yes please open an issue for it ;)

Will do! It looks like self service is switched off again. Could you
create a user for me.  This email address is fine.

Thanks!

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: web whiteboard construction order?

2019-01-07 Thread Steinar Bang
> Nhut Thai Le :

> I had this question a few months ago. You don't need to control the
> registration order of ServletContextHelper and ServletFilter. Just use
> osgi.http.whiteboard.context.select propery to wire the servlet, filter to
> the context.

Ok.  Thanks!   My problem is probably something else then...?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: web whiteboard construction order?

2019-01-07 Thread Steinar Bang
>>>>> Steinar Bang :

> When using pax web whiteboard, is it necessary for a
> ServletContextHelper creating a webcontext to be created before any
> servlets or filters using it?

> If so: is there a way of enforcing construction order when the
> ServletContextHelper, a shiro filter using the context, and a jersey
> servlet both using the context all reside in the same bundle and are
> instantiated as DS components?

> Can the ServletContextHelper expose a service and the servlet and filter
> @Reference this service? (what can be used as the service?)

I tried adding a @Reference to ServletContextHelper to the servlet (the
ServletContextHelper exposed this as a service already).

But adding ServletContextHelper as a @Reference didn't help with the
issue I'm seeing, so I'm guessing the construction order isn't the issue
with the problem I'm seeing (which is a problem with the Jersey servlet:
2019-01-07T19:12:52,045 | WARN  | paxweb-config-1-thread-1 | authservice
  | 87 - org.eclipse.jetty.util - 9.3.21.v20170918 | unavailable
org.glassfish.jersey.server.internal.scanning.ResourceFinderException: The URI 
scheme bundleentry of the URI 
bundleentry://26.fwk843/no/priv/bang/authservice/web/security/resources/AuthserviceResource.class
 is not supported. Package scanning deployment is not supported for such URIs.
Try using a different deployment mechanism such as explicitly declaring root 
resource and provider classes using an extension of javax.ws.rs.core.Application
at 
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.addResourceFinder(PackageNamesScanner.java:285)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.init(PackageNamesScanner.java:199)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.(PackageNamesScanner.java:155)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.internal.scanning.PackageNamesScanner.(PackageNamesScanner.java:111)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:893) 
~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:863) 
~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:772) 
~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.(ResourceConfig.java:1199)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.(ResourceConfig.java:1172)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1168)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.ApplicationHandler$RuntimeConfigConfigurator.init(ApplicationHandler.java:205)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$0(ApplicationHandler.java:313)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at java.util.Arrays$ArrayList.forEach(Arrays.java:3880) ~[?:?]
at 
org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:313)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:282)
 ~[108:org.glassfish.jersey.core.jersey-server:2.27.0]
at 
org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:335) 
~[105:org.glassfish.jersey.containers.jersey-container-servlet-core:2.27.0]
at 
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:178) 
~[105:org.glassfish.jersey.containers.jersey-container-servlet-core:2.27.0]
at 
no.priv.bang.authservice.web.security.AuthserviceServlet.init(AuthserviceServlet.java:77)
 ~[26:no.priv.bang.authservice.web.security:1.0.0.SNAPSHOT]
at 
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:370) 
~[105:org.glassfish.jersey.containers.jersey-container-servlet-core:2.27.0]
at javax.servlet.GenericServlet.init(GenericServlet.java:244) 
~[19:javax.servlet-api:3.1.0]
at 
org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:643) 
~[85:org.eclipse.jetty.servlet:9.3.21.v20170918]
at 
org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:422) 
~[85:org.eclipse.jetty.servlet:9.3.21.v20170918]
at 
org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892) 
~[85:

web whiteboard construction order?

2019-01-07 Thread Steinar Bang
When using pax web whiteboard, is it necessary for a
ServletContextHelper creating a webcontext to be created before any
servlets or filters using it?

If so: is there a way of enforcing construction order when the
ServletContextHelper, a shiro filter using the context, and a jersey
servlet both using the context all reside in the same bundle and are
instantiated as DS components?

Can the ServletContextHelper expose a service and the servlet and filter
@Reference this service? (what can be used as the service?)

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Adding provided dependencies makes pax exam tests fail

2019-01-04 Thread Steinar Bang
>>>>> Steinar Bang :
>>>>> Steinar Bang :

>> Platform:
>> debian 9.6 "stretch",
>> openjdk-8 8u181-b13-2~deb9u1,
>> maven 3.3.9,
>> pax exam 4.10.0

>> When I add some maven dependencies with provided, without
>> changing anything else, my karaf-based pax exam test starts failing.  

>> Is this expected? 

> To condense my question: is there a way adding two provided scope
> dependencies to the  element of the POM, could affect the
> pax exam container startup?

A transient dependency to nekohtml:nekohtml:jar:0.9.5:compile was what
stopped karaf before it startet loading features.

When the added dependencies looked like this, the pax exam test ran
wothout failure:

com.mockrunner
mockrunner-core
provided


nekohtml
nekohtml




com.mockrunner
mockrunner-servlet
provided


nekohtml
nekohtml




com.mockrunner
mockrunner-servlet
${mockrunner.version}
xml
features


-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Adding provided dependencies makes pax exam tests fail

2018-12-29 Thread Steinar Bang
>>>>> Steinar Bang :

> Platform:
>  debian 9.6 "stretch",
>  openjdk-8 8u181-b13-2~deb9u1,
>  maven 3.3.9,
>  pax exam 4.10.0

> When I add some maven dependencies with provided, without
> changing anything else, my karaf-based pax exam test starts failing.  

> Is this expected? 

To condense my question: is there a way adding two provided scope
dependencies to the  element of the POM, could affect the
pax exam container startup?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Adding provided dependencies makes pax exam tests fail

2018-12-28 Thread Steinar Bang
Platform:
 debian 9.6 "stretch",
 openjdk-8 8u181-b13-2~deb9u1,
 maven 3.3.9,
 pax exam 4.10.0

When I add some maven dependencies with provided, without
changing anything else, my karaf-based pax exam test starts failing.  

Is this expected? 

My initial feeling was that adding "provided" dependencies would make it
possible to compile classes with those dependencies, but should not
affect the runtime.

Some details
 1. The pax exam test that worked before I added my dependencies (and
returns to working if I remove them)
 
https://github.com/steinarb/ukelonn/blob/master/ukelonn.tests/src/test/java/no/priv/bang/ukelonn/tests/UkelonnServiceIntegrationTest.java#L45
 2. I am working on a pull request to make MockHttpServletRequest and
MockHttpServletResponse of mockrunner-servlet become available to
pax exam tests, by making mockrunner-servlet and its dependency
mockrunner-core become OSGi bundles
 https://github.com/mockrunner/mockrunner/issues/56
 3. My fix-branch for creating a pull request for the mockrunner
issue. Note! This branch may be squashed and rebased before making
it into a pull request
 https://github.com/steinarb/mockrunner/tree/make-jars-be-osgi-bundles
 4. I've added dependencies to the dependencyManagement section of the
parent POM:
 
 2.0.2-SNAPSHOT
 
 
 
 
 com.mockrunner
 mockrunner-core
 ${mockrunner.version}
 test
 
 
 com.mockrunner
 mockrunner-servlet
 ${mockrunner.version}
 test
 
 
 
(the "test" scope is because I'm using the MockHttpServletRequest
and MockHttpServletResponse in regular unit tests)
 5. I've added dependencies to the pom of the ukelonn.tests projects (no
Java code changes yet, those were to come next):
 
 
 com.mockrunner
 mockrunner-core
 provided
 
 
 com.mockrunner
 mockrunner-servlet
 provided
 
 
 6. The test shows normal output for karaf starting up and then quiet
for a long time until the tests time out
 [INFO] ---
 [INFO]  T E S T S
 [INFO] ---
 [INFO] Running no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
 SLF4J: Defaulting to no-operation (NOP) logger implementation
 SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.
 Dec 28, 2018 10:48:42 AM org.apache.karaf.main.Main launch
 INFO: Installing and starting initial bundles
 Dec 28, 2018 10:48:42 AM org.apache.karaf.main.Main launch
 INFO: All initial bundles installed and set to start
 Dec 28, 2018 10:48:42 AM org.apache.karaf.main.lock.SimpleFileLock lock
 INFO: Trying to lock 
/home/sb/workspaces/ws03/ukelonn/ukelonn.tests/target/exam/d0af686b-4731-47fa-aab1-3a1b19127934/lock
 Dec 28, 2018 10:48:42 AM org.apache.karaf.main.lock.SimpleFileLock lock
 INFO: Lock acquired
 Dec 28, 2018 10:48:42 AM org.apache.karaf.main.Main$KarafLockCallback 
lockAquired
 INFO: Lock acquired. Setting startlevel to 100
 [ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 
720.545 s <<< FAILURE! - in 
no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest
 [ERROR] no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest  Time 
elapsed: 720.543 s  <<< ERROR!
 java.lang.RuntimeException: Cannot get the remote bundle context
 Caused by: java.rmi.NotBoundException: 66b548e0-d5ef-4830-b25a-7c709e11b9d5
 
 [ERROR] no.priv.bang.ukelonn.tests.UkelonnServiceIntegrationTest  Time 
elapsed: 720.545 s  <<< ERROR!
 java.lang.RuntimeException: Container never came up
at 
org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at 
org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272)
at 
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236)
at 
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
 7. The karaf.log shows initial output and that it stops before loading
any features:
 Dec 28, 2018 10:48:42 AM org.apache.karaf.main.Main launch
 INFO: Installing and starting initial bundles
 Dec 28, 2018 10:48:42 AM org.apache.karaf.main.Main launch
 INFO: All initial bundles installed and set to start
 Dec 28, 2018 10:48:42 AM org.apache.karaf.main.lock.SimpleFileLock lock
 INFO: Trying to lock 
/home/sb/workspaces/ws03/ukelonn/ukelonn.tests/target/exam/d0af686b-4731-47fa-aab1-3a1b19127934/lock
 Dec 28, 2018 10:48:42 AM org.apache.karaf.main.lock.SimpleFileLock 

Re: Is it possible to use servlet 3.0 api annotations with pax web whiteboard?

2018-10-30 Thread Steinar Bang
> "'Achim Nierbeck' via OPS4J" :

> depends on who will pickup the task :)

Ok.  What's in OSGi 7 is just a spec, and is an extension to OSGi core
(that's what "compendium" means?), so it will never be in the OSGi core
of e.g. equinox or Apache Felix?  It will need to be implemented by
something like pax web?

(I've assumed it is that way, but I haven't been able to google up a
place where it is stated clearly...)

Is there a JIRA issue for adding OSGi 7 web support to pax web on the
OPS4?  Yes there is:
 https://ops4j1.jira.com/browse/PAXWEB-1181

Heh! Created yesterday...:-)  Targeted for pax web 8.

> You're more then welcome to join and add your efforts to it

Maybe I will.  At least the odd pull request or 2...:-)

The web whiteboard annotation syntax of OSGi 7 looks like what I was
hoping for.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it possible to use servlet 3.0 api annotations with pax web whiteboard?

2018-10-29 Thread Steinar Bang
> "'Achim Nierbeck' via OPS4J" :

> OSGi 7? Not yet.

Ok.  Any idea when?

Thanks!

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it possible to use servlet 3.0 api annotations with pax web whiteboard?

2018-10-29 Thread Steinar Bang
> "'Achim Nierbeck' via OPS4J" :

> you have to decide if you want to do the Whiteboard approach, or
> Servlet 3 annotations.

Ok.

> If you want to use Whiteboard do as you alsready did.
> If you want to use Servlet 3.0 annotations, make shure to define your
> application to be a WebApplicationBundle (WAB).

Right, thanks for the clarification!  I've been moving away from that
during the last year and a half or so... won't be going back. :-)

But what about the fancy new annotations from the OSGi 7 Http Whiteboard
Specification that google has found me?
 https://osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html

Is this something that will be in a future version of pax web?  

Or is it already present in the OSGi 7 framework, and I can get it in
karaf simply by switching from my current karaf 4.1.5 and OSGi 6, to
karaf 4.2.x and OSGi 7?

Thanks!

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Is it possible to use servlet 3.0 api annotations with pax web whiteboard?

2018-10-28 Thread Steinar Bang
Is it possible to use servlet 3.0 api annotations with pax web whiteboard?
Is it possible to define the whiteboard context in a simple manner?

I'm currently using pax web whiteboard in apache karaf 4.1.5 (pax web
6.0.3, I think).

But the current annotations are a bit cumbersome and clumsy, and example:
 
https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.frontend/src/main/java/no/priv/bang/ukelonn/web/frontend/UkelonnServlet.java#L36
 @Component(
 property= {
 HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN+"=/*",
 HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + "=(" + 
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME +"=ukelonn)",
 HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME+"=ukelonn"},
 service=Servlet.class,
 immediate=true
 )
 public class UkelonnServlet extends HttpServlet {
 ...
 }

I've defined the whiteboard context using a ServletContextHelper
 
https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.security/src/main/java/no/priv/bang/ukelonn/web/security/UkelonnServletContextHelper.java#L7

>From google searches I've seen indicated that servelet 3.0 api
annotations will be picket up and used
 https://nierbeck.de/2014/12/pax-web-4-1-whats-next/

However, I can't figure out how to configure the servlet to use a
whiteboard context?  The servlet 3.0 API doesn't seem to have a context
as a concept.

And I don't know if the resulting syntax will be nicer than the above
example?  (if the syntax isn't nicer there isn't any point in
switching...)

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Web Whiteboard with DS: problems with making context path work

2018-04-01 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

>> The handler for the ServletContextHelper service seems to do stuff with
>> both HTTP_WHITEBOARD_CONTEXT_NAME and HTTP_WHITEBOARD_CONTEXT_PATH, but
>> I havn't yet determined how it works and how to connect things to a
>> servlet, and (hopefully also) a Filter.

> Ok, now I've got it working[1].

[snip!]
> References:
> [1] 
> <https://github.com/steinarb/ukelonn/commit/b1cece3ff166d62e5eb52ec8b5c51d2304025c2f>
[snip!]
> [4] 
> <https://github.com/steinarb/ukelonn/blob/b1cece3ff166d62e5eb52ec8b5c51d2304025c2f/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnShiroFilter.java#L41>

I had to make an additional change to UkelonnShiroFilter to get rid of
an annoying issue where Shiro kept adding "login.jsp" to the URL:
  
https://github.com/steinarb/ukelonn/commit/153fd423a9316c415664adbdfbd5647d82dafd1e

(FWIW it still worked even with the login.jsp in place, since the Vaadin
servlet doesn't care about other local paths than the top / and
/VAADIN/*, but it didn't look good)

The change is to make sure the IniFilterChainResolverFactory get the Map
from the WebIniSecurityManagerFactory.getBeans() method. The Map
contains the results from the [main] section on the shiro.ini file
(eg. the authc.loginUrl setting, ie. without the authc.loginUrl the
FormAuthenticationFilter will get the default loginUrl, which is
"logn.jsp").

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Web Whiteboard with DS: problems with making context path work

2018-03-31 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> The handler for the ServletContextHelper service seems to do stuff with
> both HTTP_WHITEBOARD_CONTEXT_NAME and HTTP_WHITEBOARD_CONTEXT_PATH, but
> I havn't yet determined how it works and how to connect things to a
> servlet, and (hopefully also) a Filter.

Ok, now I've got it working[1].

The changes are:
 1. Added a ServletContextHelper OSGi component[2] whose only purpose is
to add an OSGi service that has a service attribute named
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH
(ie. "osgi.http.whiteboard.context.path") with the value of the web
applications context path
 2. Changed the servlet pattern of the servlet component, and added a
property HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT
(ie. "osgi.http.whiteboard.context.select") containing a select
expression that will find the ServletContextHelper[3]
 3. Made the same changes for the Shiro filter component as for the
servlet component (change the URL pattern to "/*" and add an
expression that will find the ServletContextHelper)[4]

I found an example of how to do this in the blog article "Http
Whiteboard – Simply Simple – Part II"[5]

Another blog article with some useful clues (but with an approach that
doesn't currently work on the Pax Web Whiteboard Extender), is "Access
OSGi Services via web interface"[6].


References:
[1] 
<https://github.com/steinarb/ukelonn/commit/b1cece3ff166d62e5eb52ec8b5c51d2304025c2f>
[2] 
<https://github.com/steinarb/ukelonn/blob/b1cece3ff166d62e5eb52ec8b5c51d2304025c2f/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnServletContextHelper.java#L6>
[3] 
<https://github.com/steinarb/ukelonn/blob/b1cece3ff166d62e5eb52ec8b5c51d2304025c2f/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnServlet.java#L39>
[4] 
<https://github.com/steinarb/ukelonn/blob/b1cece3ff166d62e5eb52ec8b5c51d2304025c2f/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnShiroFilter.java#L41>
[5] <https://blog.osoco.de/2016/09/http-whiteboard-simply-simple-part-ii/>
[6] <http://blog.vogella.com/2017/04/20/access-osgi-services-via-web-interface/>

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Web Whiteboard with DS: problems with making context path work

2018-03-31 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

>> I have now tried to add a context path to the property argument of
>> the @Component annotation, but that doesn't seem to work: the Vaadin
>> servlet now matches everything from the top (because of the "/*"
>> pattern) and I don't see the context anywhere.

>> The servlet annotation looks like this:
>> @Component(
>> property= {
>> HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN+"=/*",
>> HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME+"=ukelonn",
>> HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME+"=ukelonn",
>> HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH+"=/ukelonn"},
>> service=Servlet.class,
>> immediate=true
>> )
>> public class UkelonnServlet extends TouchKitServlet {

> As far as I can tell from the code that is called when a Servlet service
> is registered, there is nothing using the HTTP_WHITEBOARD_CONTEXT_NAME
> or WHITEBOARD_CONTEXT_PATH properties:
>  
> https://github.com/ops4j/org.ops4j.pax.web/blob/master/pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/tracker/ServletTracker.java#L81

>> The filter annotation looks like this:
>> @Component(
>> property= {
>> HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN+"=/*",
>> "servletNames=ukelonn",
>> HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=ukelonn",
>> HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH + "=/ukelonn"},
>> service=Filter.class,
>> immediate=true
>> )
>> public class UkelonnShiroFilter extends AbstractShiroFilter {

> Nothing in the code handling Filter services directly supports the
> HTTP_WHITEBOARD_CONTEXT_NAME or HTTP_WHITEBOARD_CONTEXT_PATH
> properties, either:
>  
> https://github.com/ops4j/org.ops4j.pax.web/blob/master/pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/tracker/FilterTracker.java#L52

The handler for the ServletContextHelper service seems to do stuff with
both HTTP_WHITEBOARD_CONTEXT_NAME and HTTP_WHITEBOARD_CONTEXT_PATH, but
I havn't yet determined how it works and how to connect things to a
servlet, and (hopefully also) a Filter.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pax Web Whiteboard with DS: problems with making context path work

2018-03-31 Thread Steinar Bang
I'm in the process of transitioning a Vaadin war web application with
web.xml to the Pax Web Whiteboard extender.

One thing that was lost in the transition, was the web application
context path.  The web.xml of the original webapp let the Vaadin servlet
match everything from "/*" which matched both the application itself and
the static resources from "/VAADIN/*".
 
https://github.com/steinarb/ukelonn/blob/ef57228437a305ef1d15b5671ddc82c59a04d572/ukelonn.bundle/src/main/webapp/WEB-INF/web.xml#L36

In the maven-bundle-plugin config (this was a war bundle meant for
karaf), I set the Web-ContextPath header in the manifest.mf of the war:
 
https://github.com/steinarb/ukelonn/blob/ef57228437a305ef1d15b5671ddc82c59a04d572/ukelonn.bundle/pom.xml#L179

Because the application context was "ukelonn", the actual path of the
web application was "/ukelonn/*", with the Vaadin static resources being
under "/ukelonn/VAADIN/*".

I've now got the Pax Web Whiteboard version working.  However, in the
Pax Web Whiteboard version, the application context was gone and I had
to let the servlet match two paths from the top, ie.: "/ukelonn/*"
(containing the webapp) and "/VAADIN/*" (containing the static resources
of Vaadin).
 
https://github.com/steinarb/ukelonn/blob/7b69f7f081f56541d58f1dc8a4c619cd18ac02d6/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnServlet.java#L39
and the Shiro filter (handling authentication and authorization)
 
https://github.com/steinarb/ukelonn/blob/7b69f7f081f56541d58f1dc8a4c619cd18ac02d6/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnShiroFilter.java#L41

The downside of this, is that if I have two webapps that use VAADIN, the
webapps will have to use the exact same version of VAADIN.

I have now tried to add a context path to the property argument of the
@Component annotation, but that doesn't seem to work: the Vaadin servlet
now matches everything from the top (because of the "/*" pattern) and I
don't see the context anywhere.

The servlet annotation looks like this:
@Component(
property= {
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN+"=/*",
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME+"=ukelonn",
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME+"=ukelonn",
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH+"=/ukelonn"},
service=Servlet.class,
immediate=true
)
public class UkelonnServlet extends TouchKitServlet {


The filter annotation looks like this:
@Component(
property= {
HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN+"=/*",
"servletNames=ukelonn",
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=ukelonn",
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH + "=/ukelonn"},
service=Filter.class,
immediate=true
)
public class UkelonnShiroFilter extends AbstractShiroFilter {


Does anyone know how to set the context on a servlet (and a filter) when
using Pax Web Whiteboard Extender with OSGi Declarative Services (DS)?

Thanks!

- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Whiteboard, ShiroFilter and error message: "No WebEnvironment found: no EnvironmentLoaderListener registered?"

2018-03-26 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:
>>>>> Александр <pro...@gmail.com>:

>> Thats right.
>> My solution is to build shiro infrastructure (securitymanager, realms,
>> filterchainresolver) by myself as a beans in blueprint, because I can
>> inject to them other services (like Datasource, or EntityManager). I do not
>> use ini file, and actually I do not use shiro in standard servlet
>> container, because there is Spring for it :)
>> But if you use shiro before, and have ini file, you can create
>> SecurityManager by IniSecurityManagerFactory
>> <https://shiro.apache.org/static/1.3.2/apidocs/src-html/org/apache/shiro/config/IniSecurityManagerFactory.html#line.46>
>> and
>> FilterChainResolver by IniFilterChainResolverFactory
>> <https://shiro.apache.org/static/1.3.2/apidocs/src-html/org/apache/shiro/web/config/IniFilterChainResolverFactory.html#line.43>
>> and
>> set them to your filter. All of this is better to do in activate() method
>> of your filter.
>> And dont forget to install shiro bundles (shiro-core, shiro-web...)

> Thanks!  I'm part of the way there.  I needed the
> WebIniSecurityManagerFactory class instead, because AbstractShiroFilter
> needs WebSecurityManager.

> However I ran into a problem in that WebIniSecurityManagerFactory
> doesn't like my custom realm.  I get the following error message in
> karaf.log of the pax exam test:
>  2018-03-24T18:40:56,944 | ERROR | features-1-thread-1 | ukelonn  
> | 21 - no.priv.bang.ukelonn - 1.0.0.SNAPSHOT | 
> [no.priv.bang.ukelonn.impl.UkelonnShiroFilter(4)] The activate method has 
> thrown an exception
> org.apache.shiro.config.ConfigurationException: Unable to set property 
> 'realms' with value [[no.priv.bang.ukelonn.impl.UkelonnRealm@7eb8a95d]] on 
> object of type org.apache.shiro.web.mgt.DefaultWebSecurityManager.  If 
> '[no.priv.bang.ukelonn.impl.UkelonnRealm@7eb8a95d]' is a reference to another 
> (previously defined) object, prefix it with '$' to indicate that the 
> referenced object should be used as the actual value.  For example, 
> $[no.priv.bang.ukelonn.impl.UkelonnRealm@7eb8a95d]
>[snip!]
>  Caused by: java.lang.ClassCastException: 
> no.priv.bang.ukelonn.impl.UkelonnRealm cannot be cast to 
> org.apache.shiro.realm.Realm

> Could this be OSGi class loader issue...?

Probably a class loader issue.  It now works:
 
https://github.com/steinarb/ukelonn/blob/4be88dab9fd97d449592cd46fb1ab9b5762b3b36/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnShiroFilter.java#L64

I had to create the realm using code rather than in the shiro.ini file:
 
https://github.com/steinarb/ukelonn/blob/4be88dab9fd97d449592cd46fb1ab9b5762b3b36/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnShiroFilter.java#L92
 
https://github.com/steinarb/ukelonn/commit/4be88dab9fd97d449592cd46fb1ab9b5762b3b36#diff-d4776a0758751afbed78ab9a334bc8ce

I also ran into a problem with Shiro's Ini file loading from the
classpath.  It actually worked in karaf in the pax exam integration
test, but not in karaf actual.  So I had to explicitly find the
shiro.ini resource from the classloader of my AbstractShiroFilter DS
component:
 
https://github.com/steinarb/ukelonn/blob/4be88dab9fd97d449592cd46fb1ab9b5762b3b36/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnShiroFilter.java#L51

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Whiteboard, ShiroFilter and error message: "No WebEnvironment found: no EnvironmentLoaderListener registered?"

2018-03-24 Thread Steinar Bang
> Александр :

> Thats right.
> My solution is to build shiro infrastructure (securitymanager, realms,
> filterchainresolver) by myself as a beans in blueprint, because I can
> inject to them other services (like Datasource, or EntityManager). I do not
> use ini file, and actually I do not use shiro in standard servlet
> container, because there is Spring for it :)
> But if you use shiro before, and have ini file, you can create
> SecurityManager by IniSecurityManagerFactory
> 
> and
> FilterChainResolver by IniFilterChainResolverFactory
> 
> and
> set them to your filter. All of this is better to do in activate() method
> of your filter.
> And dont forget to install shiro bundles (shiro-core, shiro-web...)

Thanks!  I'm part of the way there.  I needed the
WebIniSecurityManagerFactory class instead, because AbstractShiroFilter
needs WebSecurityManager.

However I ran into a problem in that WebIniSecurityManagerFactory
doesn't like my custom realm.  I get the following error message in
karaf.log of the pax exam test:
 2018-03-24T18:40:56,944 | ERROR | features-1-thread-1 | ukelonn
  | 21 - no.priv.bang.ukelonn - 1.0.0.SNAPSHOT | 
[no.priv.bang.ukelonn.impl.UkelonnShiroFilter(4)] The activate method has 
thrown an exception
org.apache.shiro.config.ConfigurationException: Unable to set property 'realms' 
with value [[no.priv.bang.ukelonn.impl.UkelonnRealm@7eb8a95d]] on object of 
type org.apache.shiro.web.mgt.DefaultWebSecurityManager.  If 
'[no.priv.bang.ukelonn.impl.UkelonnRealm@7eb8a95d]' is a reference to another 
(previously defined) object, prefix it with '$' to indicate that the referenced 
object should be used as the actual value.  For example, 
$[no.priv.bang.ukelonn.impl.UkelonnRealm@7eb8a95d]
   [snip!]
 Caused by: java.lang.ClassCastException: 
no.priv.bang.ukelonn.impl.UkelonnRealm cannot be cast to 
org.apache.shiro.realm.Realm

Could this be OSGi class loader issue...?

The shiro.ini file looks like this:
 [main]
 authc.loginUrl = /
 user.loginUrl = /
 credentialsMatcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
 # base64 encoding, not hex in this example:
 credentialsMatcher.storedCredentialsHexEncoded = false
 credentialsMatcher.hashIterations = 1024
 ukelonnRealm = no.priv.bang.ukelonn.impl.UkelonnRealm
 ukelonnRealm.credentialsMatcher = $credentialsMatcher
 securityManager.realms = $ukelonnRealm
 [users]

 [urls]
 / = authc
 /* = user


The realm definition is:
 public class UkelonnRealm extends AuthorizingRealm
Following the inheritance:
 AuthorizingRealm extends AuthenticatingRealm
 AuthenticatingRealm extends CachingRealm implements Initializable
 CachingRealm implements Realm, Nameable, CacheManagerAware, LogoutAware

The Realm interface in the last line is org.apache.shiro.realm.Realm.

I have checked the Import-Package of the manifest.mf in my application's
bundle, and as far as I can tell, it imports the org.apache.shiro.realm
package:
Import-Package: no.priv.bang.ukelonn,javax.servlet.http;version="[2.6.0,
 4.0.0)",com.vaadin.server;version="[7.6,8)",com.vaadin.addon.touchkit.s
 erver,com.vaadin.addon.touchkit.ui,com.vaadin.annotations;version="[7.6
 ,8)",com.vaadin.data;version="[7.6,8)",com.vaadin.data.util;version="[7
 .6,8)",com.vaadin.data.util.converter;version="[7.6,8)",com.vaadin.data
 .validator;version="[7.6,8)",com.vaadin.navigator;version="[7.6,8)",com
 .vaadin.ui;version="[7.6,8)",javax.servlet;version="[3.1,4)",org.apache
 .karaf.shell.api.action;version="[4.1,5)",org.apache.karaf.shell.api.ac
 tion.lifecycle;version="[4.1,5)",org.apache.shiro;version="[1.3,2)",org
 .apache.shiro.authc;version="[1.3,2)",org.apache.shiro.authz;version="[
 1.3,2)",org.apache.shiro.config;version="[1.3,2)",org.apache.shiro.cryp
 to;version="[1.3,2)",org.apache.shiro.crypto.hash;version="[1.3,2)",org
 .apache.shiro.realm;version="[1.3,2)",org.apache.shiro.subject;version=
 "[1.3,2)",org.apache.shiro.util;version="[1.3,2)",org.apache.shiro.web.
 config;version="[1.3,2)",org.apache.shiro.web.filter.mgt;version="[1.3,
 2)",org.apache.shiro.web.mgt;version="[1.3,2)",org.apache.shiro.web.ser
 vlet;version="[1.3,2)",org.osgi.service.log;version="[1.3,2)",com.vaadi
 n.addon.touchkit.gwt.client,VAADIN.widgetsets.com.vaadin.addon.touchkit
 .gwt.TouchKitWidgetSet,com.vaadin.addon.touchkit.gwt.client.theme,com.v
 aadin.addon.touchkit.gwt.client.vcom.popover,assets,com.vaadin.addon.to
 uchkit.settings,com.vaadin.addon.touchkit.gwt.client.ui,com.vaadin.addo
 n.touchkit.gwt,com.vaadin.addon.touchkit.gwt.client.vcom,com.vaadin.add
 on.touchkit.annotations,com.vaadin.addon.touchkit.gwt.client.communicat
 ion,com.vaadin.addon.touchkit.gwt.client.theme.fonts,com.vaadin.addon.t
 

Re: Code example for accessing the ServletContext in pax whiteboard?

2018-03-21 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> I guess one way to do this would be to create a @Component that
> implements the Filter interface and wraps a ShiroFilter.  Ie. it creates
> a ShiroFilter instance and calls init(FilterConfig) on the ShiroFilter
> and then does its own thing.

> It should work... but it feels cumbersome...

Nope! Doesn't work!

It just returned me to the original problem, ie:
 java.lang.IllegalStateException: No WebEnvironment found: no 
EnvironmentLoaderListener registered?

Caused by: java.lang.IllegalStateException: No WebEnvironment found: no 
EnvironmentLoaderListener registered?
at 
org.apache.shiro.web.util.WebUtils.getRequiredWebEnvironment(WebUtils.java:276) 
~[?:?]
at 
no.priv.bang.ukelonn.impl.UkelonnShiroFilter.init(UkelonnShiroFilter.java:67) 
~[?:?]
at 
org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:137) ~[?:?]
at 
org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:873) 
~[?:?]
at 
org.eclipse.jetty.servlet.ServletHandler.updateMappings(ServletHandler.java:1565)
 ~[?:?]

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Code example for accessing the ServletContext in pax whiteboard?

2018-03-21 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:
[snip!]
> Is there any guarantee that activate() won't be called until after
> init(FilterConfig) has been called?

Nope.  When activate() was called, getFilterConfig() returned null:
@Activate
public void activate() {
WebEnvironment env = 
WebUtils.getRequiredWebEnvironment(getFilterConfig().getServletContext());

setSecurityManager(env.getWebSecurityManager());

FilterChainResolver resolver = env.getFilterChainResolver();
if (resolver != null) {
setFilterChainResolver(resolver);
}
}

I guess one way to do this would be to create a @Component that
implements the Filter interface and wraps a ShiroFilter.  Ie. it creates
a ShiroFilter instance and calls init(FilterConfig) on the ShiroFilter
and then does its own thing.

It should work... but it feels cumbersome...

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Code example for accessing the ServletContext in pax whiteboard?

2018-03-21 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> Does anyone have a code example for how to get the ServletContext in a
> filter?

> I tried adding a @Reference for javax.servlet.ServletContext in a DS
> component, but that @Reference never received a service injection.

I've found this
 http://blog.vogella.com/2017/04/20/access-osgi-services-via-web-interface/
(search for "Register Filters")

@Component(
property = "osgi.http.whiteboard.filter.pattern=/invert",
scope=ServiceScope.PROTOTYPE)
public class SimpleServletFilter implements Filter {
 
@Override
public void init(FilterConfig filterConfig) throws ServletException { }
...
}

Unfortunately, for the AbstractShiroFilter class the init(FilterConfig)
method is made final in a base class:
 
https://github.com/apache/shiro/blob/master/web/src/main/java/org/apache/shiro/web/servlet/AbstractFilter.java#L94
and the onFilterConfgSet() method
 
https://github.com/apache/shiro/blob/master/web/src/main/java/org/apache/shiro/web/servlet/AbstractFilter.java#L121
is made final in the AbstractShiroFilterClass:
 
https://github.com/apache/shiro/blob/master/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java#L149

Is there any guarantee that activate() won't be called until after
init(FilterConfig) has been called?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Code example for accessing the ServletContext in pax whiteboard?

2018-03-21 Thread Steinar Bang
Does anyone have a code example for how to get the ServletContext in a
filter?

I tried adding a @Reference for javax.servlet.ServletContext in a DS
component, but that @Reference never received a service injection.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Whiteboard, ShiroFilter and error message: "No WebEnvironment found: no EnvironmentLoaderListener registered?"

2018-03-20 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

>>>>> Steinar Bang <s...@dod.no>:
>>> Do you register WebSecurityManager and FilterChainResolver as a services?

>> No I haven't.  Should I? I thought Pax Whiteboard Extender handles
>> creating the appropriate services?
[snip!]
> (ie. FilterChainResolver was missing)

Right! Both WebEnvironment and FilterChainResolver are shiro classes, so
of course I (or something else) would need to create something that
provides those services.

There is no way my code earlier could have actually worked, so something
in how I'm testing it is fooling myself (running old code, probably...).


-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Whiteboard, ShiroFilter and error message: "No WebEnvironment found: no EnvironmentLoaderListener registered?"

2018-03-20 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

>> Do you register WebSecurityManager and FilterChainResolver as a services?

> No I haven't.  Should I? I thought Pax Whiteboard Extender handles
> creating the appropriate services?

Hm... it did seem to work earlier, but now I did an experiment that
failed, and when I rolled things back the pax exam test failed and I
found this in pax exam's karaf.log:
 2018-03-20T18:55:44,193 | ERROR | pool-1-thread-2  | BootFeaturesInstaller 
   | 7 - org.apache.karaf.features.core - 4.1.2 | Error installing boot 
features
 org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing 
requirement [root] osgi.identity; osgi.identity=ukelonn; type=karaf.feature; 
version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; 
filter:="(&(osgi.identity=ukelonn)(type=karaf.feature)(version>=1.0.0.SNAPSHOT)(version<=1.0.0.SNAPSHOT))"
 [caused by: Unable to resolve ukelonn/1.0.0.SNAPSHOT: missing requirement 
[ukelonn/1.0.0.SNAPSHOT] osgi.identity; osgi.identity=no.priv.bang.ukelonn; 
type=osgi.bundle; version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; 
resolution:=mandatory [caused by: Unable to resolve 
no.priv.bang.ukelonn/1.0.0.SNAPSHOT: missing requirement 
[no.priv.bang.ukelonn/1.0.0.SNAPSHOT] osgi.service; effective:=active; 
filter:="(objectClass=org.apache.shiro.web.filter.mgt.FilterChainResolver)"]]
at 
org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42) 
~[?:?]
at 
org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:389) ~[?:?]
at 
org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:375) ~[?:?]
at 
org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:347) ~[?:?]
at 
org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:218)
 ~[?:?]
at 
org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:291) 
~[?:?]
at 
org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1233)
 ~[?:?]
at 
org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$0(FeaturesServiceImpl.java:1132)
 ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[?:?]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]

(ie. FilterChainResolver was missing)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Whiteboard, ShiroFilter and error message: "No WebEnvironment found: no EnvironmentLoaderListener registered?"

2018-03-20 Thread Steinar Bang
>>>>> Alexander Rotnov <pro...@gmail.com>:

> On Tuesday, March 20, 2018 at 1:17:29 AM UTC+3, Steinar Bang wrote:
>> 
>> 
>> 3. The filter fails when the application is loaded into karaf 4.1.5 

> What kind of fails? 

Well, now the pax exam tests works from inside eclipse as well as when
building with maven.

I don't know why it failed before and suddenly started working.  Maybe
something was finally updated all the way into eclipse, after I had
built the project with maven from the command line.

Now it's only inside karaf it fails but when I look at the stack trace
the failure is in a different place.

> In Karaf (in Felix) DS component became active and @Activate method
> invoked, when all dependecies are resolved. I think pax exam also
> waits until all dependencies are resolve. Actually, I'm unfamiliar
> with pax exam :)

Well, Pax Exam is like karaf in this case, because I use the pax exam
karaf configuration, except for one thing: the @Inject of the services
in the pax exam test ensures that DS components are created.

> Do you register WebSecurityManager and FilterChainResolver as a services?

No I haven't.  Should I? I thought Pax Whiteboard Extender handles
creating the appropriate services?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Whiteboard, ShiroFilter and error message: "No WebEnvironment found: no EnvironmentLoaderListener registered?"

2018-03-19 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

>>>>> Alexander Rotnov <pro...@gmail.com>:
>> I also faces this problem, while adopt Shiro to Karaf and Pax Web. My 
>> solution - do not try to initialize filter from WebEnvironment, as in 
>> ShiroFilter. 
>> Try to extend AbstractShiroFilter and inject to it WebSecurityManager and 
>> FilterChainResolver.

> Thanks! I will try this.

It tried it, but it's kind of weird:
 1. The pax exam test that loads the servlet and filter works when run
from maven
 2. The pax exam test fails when run from inside eclipse
 3. The filter fails when the application is loaded into karaf 4.1.5

That the pax exam test works in one setting and fails in another hints
at something timing releated...?

But I didn't think DS components would have timing issues?  They either
become active, or they don't... and a pax exam test with @Inject members
don't actually run anything until all injections have been satisifed.

Anyway, here's the component:

@Component(
property= {
HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN+"=/ukelonn/*",
"servletNames=ukelonn"},
service=Filter.class,
immediate=true
)
public class UkelonnShiroFilter extends AbstractShiroFilter {

private static UkelonnShiroFilter instance;
private UkelonnDatabase database;
WebSecurityManager securitymanager;
FilterChainResolver resolver;

public UkelonnShiroFilter() {
instance = this;
}

@Activate
public void activate() {
setSecurityManager(securitymanager);

if (resolver != null) {
setFilterChainResolver(resolver);
}
}

@Reference
public void setUkelonnDatabase(UkelonnDatabase database) {
this.database = database;
}

public UkelonnDatabase getDatabase() {
return database;
}

@Reference
public void setSecuritymanager(WebSecurityManager securitymanager) {
this.securitymanager = securitymanager;
}

@Reference
public void setResolver(FilterChainResolver resolver) {
this.resolver = resolver;
}

public static UkelonnShiroFilter getInstance() {
return instance;
}

}

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax Whiteboard, ShiroFilter and error message: "No WebEnvironment found: no EnvironmentLoaderListener registered?"

2018-03-19 Thread Steinar Bang
> Alexander Rotnov :

> I also faces this problem, while adopt Shiro to Karaf and Pax Web. My 
> solution - do not try to initialize filter from WebEnvironment, as in 
> ShiroFilter. 
> Try to extend AbstractShiroFilter and inject to it WebSecurityManager and 
> FilterChainResolver.

Thanks! I will try this.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pax Whiteboard, ShiroFilter and error message: "No WebEnvironment found: no EnvironmentLoaderListener registered?"

2018-03-18 Thread Steinar Bang
Has anyone else been using apache shiro with the pax web whiteboard
extender?  Has anyone else succeeded in making it work?

Shiro uses a filter to handle authentication and authorization for a
paths of a webapp.

I'm trying to create a ShiroFilter DS component to front a servlet
(also a DS component) when using the Pax Web Whiteboard Exctender.

It seemed to work at first, ie. I got a login windown in my application
and was able to log in (which means that shiro is working as it is
supposed to), but when I changed the name of the filter DS component it
started failing.

I don't know *why* it fails when the name is changed, but I know *how*
it fails: it fails with the error message:
  No WebEnvironment found: no EnvironmentLoaderListener registered?

This is a well known and dreaded error message when using apache shiro,
see eg.
 
https://stackoverflow.com/questions/15645799/jetty-maven-plugin-unable-to-hot-redeploy-shiro-filter
 
https://stackoverflow.com/questions/15645799/jetty-maven-plugin-unable-to-hot-redeploy-shiro-filter

I have encountered this issue earlier, when I first tried to use the pax
web whiteboard extender, using my home brewed "mini dependency
injection" BundleActivator.  The way I solved it make the ShiroFilter
listen for a service of type WebContainer, and create an
EnvironmentLoaderListener when a WebContainer is enabled, like this:

 @Component(
 property= {
 HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN+"=/ukelonn/*",
 "servletNames=ukelonn"},
 service=Filter.class,
 immediate=true
 )
 public class UkelonnShiroFilter extends ShiroFilter {
 private WebContainer webContainer;
 private HttpContext httpcontext;
 private EnvironmentLoaderListener listener;

 @Reference
 public void setWebContainer(WebContainer webContainer) {
 createEnvironmentLoaderListenerAndDefaultContext(webContainer);
 }

 private void createEnvironmentLoaderListenerAndDefaultContext(WebContainer 
webContainer) {
 if (this.webContainer == webContainer) {
 return; // already registered, nothing to do
 }

 unregisterExistingEnvironmentLoaderListener();

 this.webContainer = webContainer;

 if (webContainer != null) {
 httpcontext = webContainer.createDefaultHttpContext();
 listener = new EnvironmentLoaderListener();
 webContainer.registerEventListener(listener, httpcontext);
 }
 }

 private void unregisterExistingEnvironmentLoaderListener() {
 if (webContainer != null) {
 webContainer.unregisterEventListener(listener);
 listener = null;
 }
 }

 }

This worked at first, but stopped working when I changed the name of the
class.  I can see in the debugger that the UkelonnShiroFilter gets a
WebContainer injection and creates and registers an
EnvironmentLoaderListener.

But even so the ShiroFilter fails during initialization with the
following error message:
 java.lang.IllegalStateException: No WebEnvironment found: no 
EnvironmentLoaderListener registered?

Does anyone know what I can/should do to initialize the WebEnvironment
properly for the shiro filter?

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DS Pax whiteboard example with multiple URL patterns anywhere?

2018-03-18 Thread Steinar Bang
> Александр :

> Pax Web parses @WebServlet and @WebFilter annotations, but a little buggy
> (ignore "name" property of @WebServlet, so if you need a filter on it, use
> whiteboard constant for it).
> In your case, to declare multiple values for property just add two
> properties with same key:
> @Component(
> property= {"osgi.http.whiteboard.servlet.pattern=/ukelonn /*",
>   "osgi.http.whiteboard.servlet.pattern=/VAADIN /*"},
> service=Servlet.class
> )
> or with constans of OSGI Annotations:
> @Component(
> property= { HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN+"=/
> ukelonn /*",
>   HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN+"=/VAADIN /*"},
> service=Servlet.class
> )

Thanks! This worked:
@Component(
property= {
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN+"=/ukelonn/*",
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN+"=/VAADIN/*",
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME+"=ukelonn"},
service=Servlet.class,
immediate=true
)

(the "immediate=true" is to emulate the behaviour of the BundleActivator
I'm replacing. I'll try lazy init once I get things up and working)

> For webfilter do not
> use HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_SERVLET
> ("osgi.http.whiteboard.filter.servlet") because of bug (pax web ignore it)
> use "servletNames" service property for workaround, or @WebFilter
> annotation with specified "servletNames" property.

Ah! I did not see this the first time around.  I used
HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_SERVLET and this seemed
to work, but it was kind of fragile (it stopped working when I changed
the class name of the filter).

I'll try "servletNames" in "property" in @Component instead, and see if
that helps.

Thanks again!

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DS Pax whiteboard example with multiple URL patterns anywhere?

2018-03-16 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:
>>>>> Steinar Bang <s...@dod.no>:

>> I'm in the process of replacing my own home brewed "mini dependency
>> injection"[1] with Declarative Services (DS).

>> I'm wondering how to replace what I was doing here:
>> https://github.com/steinarb/ukelonn/blob/b369b5768c08a1c6bb6fb422e2f462ca797c253f/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnServletProvider.java#L57

>> I can't quite remember what I was thinking about, half a year ago, but
>> what @ServiceProperties contains, is added as service properties when
>> registering the OSGi service:
>> https://github.com/sbang/jsr330activator/blob/master/jsr330activator.implementation/src/main/java/no/steria/osgi/jsr330activator/implementation/ProviderAdapter.java#L161

> I guess I was trying to do something like the activator in the sample
> does:
>  
> https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/whiteboard/src/main/java/org/ops4j/pax/web/extender/samples/whiteboard/internal/Activator.java#L67

> I also think there may be no way of doing this with DS, where the docs
> for the property argument of @Component, say:
[snip!]
>  String[] property() default {};

> Ie. it's limited to what a .properties file can represent, which is a
> list of name=value pairs, and no name=multiple-values.

> But I will be happy to be proved wrong...:-)

Looking at the pax whiteboard code, it looks like I might be able to use
a @WebServlet annotation on a Servlet @Component...?
 
https://github.com/ops4j/org.ops4j.pax.web/blob/master/pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/tracker/ServletTracker.java#L114
 
https://github.com/ops4j/org.ops4j.pax.web/blob/master/pax-web-api/src/main/java/org/ops4j/pax/web/utils/ServletAnnotationScanner.java#L40

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


DS Pax whiteboard example with multiple URL patterns anywhere?

2018-03-16 Thread Steinar Bang
I'm in the process of replacing my own home brewed "mini dependency
injection"[1] with Declarative Services (DS).

I'm wondering how to replace what I was doing here:
 
https://github.com/steinarb/ukelonn/blob/b369b5768c08a1c6bb6fb422e2f462ca797c253f/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnServletProvider.java#L57

I can't quite remember what I was thinking about, half a year ago, but
what @ServiceProperties contains, is added as service properties when
registering the OSGi service:
 
https://github.com/sbang/jsr330activator/blob/master/jsr330activator.implementation/src/main/java/no/steria/osgi/jsr330activator/implementation/ProviderAdapter.java#L161

So my question is, how should what I put on the OSGi service properties
here, ie.
  ExtenderConstants.PROPERTY_URL_PATTERNS = {"/ukelonn/*", "/VAADIN/*"}
  ExtenderConstants.PROPERTY_SERVLET_NAMES = "ukelonn"
into a servlet @Component definition?

The examples I've found, ie. [2] and [3] just list one pattern for the
servlets.

Thanks!


- Steinar


References:
[1] 
[2] 

[3] 


-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pax web whiteboard extender: possible with multiple aliases? Possible with wildcards in alias?

2018-02-21 Thread Steinar Bang
Is it possible to have more than one alias for a servlet when using the
pax web whiteboard extender?

Is it possible to have a wildcard in an alias?

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: pax web and react.js?

2018-02-20 Thread Steinar Bang
> nino martinez wael :

> I havent tried it with react, but done it with different things.. 
> I used the osgi HTTP Service to deliver my static content.. Why not use CXF 
> REST endpoints for the dynamic parts? OR does the frontend need to be 
> "totally" dynamic?

I haven't made up my mind about totally dynamic or frontend served up as
static files.  I'm just exploring the possibilities.

Thanks for the input! :-)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pax web and react.js?

2018-02-18 Thread Steinar Bang
Has anyone on this mailing lists done any experiments in writing a
react.js application and deliver it through pax web?

Has anyone tried dynamic server side rendering on nashorn or rhino?

Has anyone tried packing a react.js application up with webpack and
serving it from a pax web servlet?

Thanks!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Relationship between Pax web whiteboard extender and the OSGi R6 httpextender?

2017-10-21 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> But I'm having a hard time figuring out how to use this stuff.  The
> documentation of Vaadin OSGi doesn't make sense to me...

The ideal thing would have been if I could just expose eg. UIProvider as
a service and Vaadin would pick it up and just use it in a VaadinServlet
it itself had registered...?

(just thinking out loud...)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Relationship between Pax web whiteboard extender and the OSGi R6 httpextender?

2017-10-18 Thread Steinar Bang
I've heard about, and have used, the pax web whiteboard extender[1].

I've tried using Vaadin 8.1.5 with the whiteboard extender, and have run
into some problems[2].

Then I suddenly discovered that the vaadin bundles exposed servies and
googled some more and found "Vaadin OSGi support"[3]

Vaadin uses something called "HttpWhiteboard specification" and googling
for that brought me pages talking about the OSGi R6 Http Service.

The Pax web whiteboard extender[1] says it is OSGi R6 compliant, and [3]
lists karaf console commands, so I guess they are the same thing.

But I'm having a hard time figuring out how to use this stuff.  The
documentation of Vaadin OSGi doesn't make sense to me...

References:
[1] 

[2] 
[3] 

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What scope for maven dependencies for code used in pax exam test?

2017-10-15 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

[snip!]
>> What I would like to do, is to add the dependencies in
>> compile and let karaf-maven-plugin generate a feature
>> file from the compile dependencies, and then use that feature file in
>> the pax exam karaf config.
[snip!]
>> What I would like to do, is to add the dependencies in

> I tried adding mockrunner-server as a compile target:
> 
> com.mockrunner
> mockrunner-servlet
> 1.1.2
> compile
> 

[snip!]
> The feature installs fine in a regular karaf console:
[snip!]

> But karaf in pax exam (that now has a compile dependency
> to mockrunner), fails during startup.  If I remove the compile
> dependency pax exam karaf starts fine.

> Is there a workaround to this issue?

Yes, there is: add an  to the dependency that pulls in the
conflicting xerces version:

com.mockrunner
mockrunner-servlet
1.1.2
compile


com.mockrunner
mockrunner-core




I found it by running "mvn dependency:tree" which outputs the following
for mockrunner-servlet:
 [INFO] +- com.mockrunner:mockrunner-servlet:jar:1.1.2:compile
 [INFO] |  +- com.mockrunner:mockrunner-core:jar:1.1.2:compile
 [INFO] |  |  +- jdom:jdom:jar:1.0:compile
 [INFO] |  |  +- oro:oro:jar:2.0.8:compile
 [INFO] |  |  +- com.kirkk:jaranalyzer:jar:1.2:compile
 [INFO] |  |  |  +- bcel:bcel:jar:5.1:compile
 [INFO] |  |  |  |  \- regexp:regexp:jar:1.2:compile
 [INFO] |  |  |  +- jakarta-regexp:jakarta-regexp:jar:1.4:compile
 [INFO] |  |  |  \- ant:ant:jar:1.6.5:compile
 [INFO] |  |  \- nekohtml:nekohtml:jar:0.9.5:compile
 [INFO] |  | \- xerces:xercesImpl:jar:2.4.0:compile
 [INFO] |  +- commons-logging:commons-logging:jar:1.0.4:compile
 [INFO] |  \- org.apache.tomcat:servlet-api:jar:6.0.37:compile

xerces, which is what the karaf boot message complained about is pulled
in by com.mockrunner:mockrunner-core:jar:1.1.2.

So I'm guessing what happens is that pax exam pulls in all compile scope
and test scope dependencies(*) and offer them up as exported osgi
packages to the pax exam test's OSGi runtime.  And if the packages are
in conflict with something else (in this case the karaf boot), there are
problems.

My original question was: Is it possible to create a karaf feature file
for use in a pax exam test, by adding compile scope dependencies to the
pax exam maven project and use karaf-maven-plugin to generate the
feature file?

The answer to my original question, is: Yes, but only for such top level
dependencies that won't conflict with other OSGi components running in
the pax exam OSGi runtime.  Beware of transitive dependencies of the
packages you're creating feature files for.


(*) I tried test scope as well, got the same boot error there


-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What scope for maven dependencies for code used in pax exam test?

2017-10-14 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> What happens if I put the dependencies in compile?
> Will this mess up the pax exam OSGi runtime startup?

> What I would like to do, is to add the dependencies in
> compile and let karaf-maven-plugin generate a feature
> file from the compile dependencies, and then use that feature file in
> the pax exam karaf config.

> Is this possible?

> Or will, as asked above, using the compile scope on dependencies mess
> up the pax exam OSGi startup somehow?

I tried adding mockrunner-server as a compile target:

com.mockrunner
mockrunner-servlet
1.1.2
compile


This created a feature file that looks ok:
 
 http://karaf.apache.org/xmlns/features/v1.4.0; 
name="fildele.tests">
 
 wrap
 wrap:mvn:com.mockrunner/mockrunner-servlet/1.1.2
 
 

The feature installs fine in a regular karaf console:
 karaf@root()> feature:repo-add 
mvn:no.priv.bang.fildele/fildele.tests/1.0.0-SNAPSHOT/xml/features
 Adding feature url 
mvn:no.priv.bang.fildele/fildele.tests/1.0.0-SNAPSHOT/xml/features
 karaf@root()> feature:install mockrunner
 karaf@root()> bundle:list
 START LEVEL 100 , List Threshold: 50
 ID | State  | Lvl | Version | Name
 
---++-+-+---
 28 | Active |  80 | 4.1.2   | Apache Karaf :: OSGi Services :: Event
 52 | Active |  80 | 0   | 
wrap_file__C__Users_sb_.m2_repository_com_mockrunner_mockrunner-servlet_1.1.2_mockrunner-servlet-1.1.2.jar
 karaf@root()> bundle:capabilities 52
 
wrap_file__C__Users_sb_.m2_repository_com_mockrunner_mockrunner-servlet_1.1.2_mockrunner-servlet-1.1.2.jar
 [52] provides:
 
-
 osgi.wiring.bundle; 
wrap_file__C__Users_sb_.m2_repository_com_mockrunner_mockrunner-servlet_1.1.2_mockrunner-servlet-1.1.2.jar
 0.0.0 [UNUSED]
 osgi.wiring.host; 
wrap_file__C__Users_sb_.m2_repository_com_mockrunner_mockrunner-servlet_1.1.2_mockrunner-servlet-1.1.2.jar
 0.0.0 [UNUSED]
 osgi.identity; 
wrap_file__C__Users_sb_.m2_repository_com_mockrunner_mockrunner-servlet_1.1.2_mockrunner-servlet-1.1.2.jar
 0.0.0 [UNUSED]
 osgi.wiring.package; com.mockrunner.base 0.0.0 [UNUSED]
 osgi.wiring.package; com.mockrunner.example.servlet 0.0.0 [UNUSED]
 osgi.wiring.package; com.mockrunner.mock.web 0.0.0 [UNUSED]
 osgi.wiring.package; com.mockrunner.servlet 0.0.0 [UNUSED]
 karaf@root()>

But karaf in pax exam (that now has a compile dependency
to mockrunner), fails during startup.  If I remove the compile
dependency pax exam karaf starts fine.

Is there a workaround to this issue?


Here's the error message from the karaf.log:

2017-10-14T22:08:32,391 | INFO  | FelixStartLevel  | fileinstall
  | 6 - org.apache.felix.fileinstall - 3.6.0 | Creating configuration from 
jmx.acl.cfg
2017-10-14T22:08:34,172 | ERROR | FelixStartLevel  | BootFeaturesInstaller  
  | 7 - org.apache.karaf.features.core - 4.1.2 | Error installing boot 
feature repository mvn:org.apache.karaf.features/spring/4.1.2/xml/features
java.io.IOException: This DocumentBuilder, 
"org.apache.xerces.jaxp.DocumentBuilderImpl", does not support the reset 
functionality.  Specification "null" version "null" : 
mvn:org.apache.karaf.features/spring/4.1.2/xml/features
at 
org.apache.karaf.features.internal.service.RepositoryImpl.load(RepositoryImpl.java:91)
 ~[7:org.apache.karaf.features.core:4.1.2]
at 
org.apache.karaf.features.internal.service.FeaturesServiceImpl.loadRepository(FeaturesServiceImpl.java:460)
 ~[7:org.apache.karaf.features.core:4.1.2]
at 
org.apache.karaf.features.internal.service.FeaturesServiceImpl.addRepository(FeaturesServiceImpl.java:476)
 ~[7:org.apache.karaf.features.core:4.1.2]
at 
org.apache.karaf.features.internal.service.FeaturesServiceImpl.addRepository(FeaturesServiceImpl.java:471)
 ~[7:org.apache.karaf.features.core:4.1.2]
at 
org.apache.karaf.features.internal.service.BootFeaturesInstaller.installBootFeatures(BootFeaturesInstaller.java:98)
 [7:org.apache.karaf.features.core:4.1.2]
at 
org.apache.karaf.features.internal.service.BootFeaturesInstaller.start(BootFeaturesInstaller.java:87)
 [7:org.apache.karaf.features.core:4.1.2]
at 
org.apache.karaf.features.internal.osgi.Activator.doStart(Activator.java:269) 
[7:org.apache.karaf.features.core:4.1.2]
at 
org.apache.karaf.util.tracker.BaseActivator.start(BaseActivator.java:78) 
[7:org.apache.karaf.features.core:4.1.2]
at 
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
 [?:?]
at org.apache.felix.framework.Felix.acti

What scope for maven dependencies for code used in pax exam test?

2017-10-14 Thread Steinar Bang
What scope should be used for maven dependencies for code used in pax
exam tests?

Should the compilation dependencies be done by using test
and the runtime dependencies be handled by adding a bundle to the pax
exam config?

What happens if I put the dependencies in compile?  Will
this mess up the pax exam OSGi runtime startup?

What I would like to do, is to add the dependencies in compile
and let karaf-maven-plugin generate a feature file from the compile
dependencies, and then use that feature file in the pax exam karaf
config.

Is this possible?

Or will, as asked above, using the compile scope on dependencies mess up
the pax exam OSGi startup somehow?

(If so, I could create a new maven project to produce that feature file,
but it feels like clutter)

Thanks!



-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax-exam karaf test fails to start up because it can't get a BundleContext

2017-10-09 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> The problem is similar to what was seen in this bug, 6 years ago
>  https://ops4j1.jira.com/browse/PAXEXAM-274

> But the bug was 6 years ago, and many versions of everything (OSGi,
> pax-exam, mockito, Java) ago, so I'm not sure if the simiarlities are a
> red herring...?

The more I looked at it, it looked similar.  And the issue is still
open.

So what I've done now is to ditch mockito from the integration test, and
just mock the response and request objects manually (create a base class
implementing the interface with default content created by the IDE, and
then extend that base class and actually implement the methods I
otherwise would have mocked).

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax-exam karaf test fails to start up because it can't get a BundleContext

2017-10-08 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> Is there something else I can try?

Looking closer at the error message:

java.lang.LinkageError: loader constraint violation in interface itable 
initialization: when resolving method 
"$javax.servlet.http.HttpServletRequest$$EnhancerByMockitoWithCGLIB$$22025fbe.newInstance([Ljava/lang/Class;[Ljava/lang/Object;[Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;"
 the class loader (instance of 
org/mockito/internal/creation/util/SearchingClassLoader) of the current class, 
$javax/servlet/http/HttpServletRequest$$EnhancerByMockitoWithCGLIB$$22025fbe, 
and the class loader (instance of 
org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) for interface 
org/mockito/cglib/proxy/Factory have different Class objects for the type 
[Lorg/mockito/cglib/proxy/Callback; used in the signature

Looking closer at the error message: The two classloaders that load
different versions of org.mockito.cglib.proxy.Callback, are:
 1. One classloader belonging to mockito 
(org.mockito.internal.creation.util.SearchingClassLoader),
this is the classloader that has loaded the mock
 2. One classloader belonging to felix 
(org.apache.felix.framework.BundleWiringImpl$BundleClassLoader)

Is the problem that mockito uses its own classloader?

The problem is similar to what was seen in this bug, 6 years ago
 https://ops4j1.jira.com/browse/PAXEXAM-274

But the bug was 6 years ago, and many versions of everything (OSGi,
pax-exam, mockito, Java) ago, so I'm not sure if the simiarlities are a
red herring...?

My versions of the components, are:
 Karaf 4.1.2
 Pax-exam 4.11.0
 Mockito 1.10.19
 Java 1.8
 Windows 10

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax-exam karaf test fails to start up because it can't get a BundleContext

2017-10-08 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

>>>>> Steinar Bang <s...@dod.no>:
>> This worked fine in getting karaf to start and the service to be
>> produced, but actually using mockito mocks failed:
>> java.lang.LinkageError: loader constraint violation in interface itable 
>> initialization: when resolving method 
>> "$javax.servlet.http.HttpServletRequest$$EnhancerByMockitoWithCGLIB$$22025fbe.newInstance([Ljava/lang/Class;[Ljava/lang/Object;[Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;"
>>  the class loader (instance of 
>> org/mockito/internal/creation/util/SearchingClassLoader) of the current 
>> class, 
>> $javax/servlet/http/HttpServletRequest$$EnhancerByMockitoWithCGLIB$$22025fbe,
>>  and the class loader (instance of 
>> org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) for interface 
>> org/mockito/cglib/proxy/Factory have different Class objects for the type 
>> [Lorg/mockito/cglib/proxy/Callback; used in the signature
> [snip!]

>> This is the code that fails:
>> https://gist.github.com/steinarb/5534a87dd42827fad7a461732d6d5684#file-fildeleintegrationtest-java-L64

>> I don't have any idea how to fix this, or even if it's fixable...?

> I tried setting
> frameworkProperty("felix.bootdelegation.implicit").value("false"),
> like what I found here:
>  
> https://github.com/ops4j/org.ops4j.pax.exam2/blob/master/itest/osgi/src/it/regression-multi/src/test/java/org/ops4j/pax/exam/regression/multi/wrap/MockitoTest.java#L100

> But I still got the same error:

Now I've tried the following steps, none of which have fixed the problem:

 1. Created a separate maven project to create the mockito feature file,
and changed the maven dependencies of the pax-exam test project:
 - changed the scope of mockito-core from compile to test
 - removed the dependencies of objenesis and hamcrest from
   the pax-exam test projects
 This did not fix the error

 2. Switched the mockito-core maven test scope dependency of the
pax-exam test project to a mockito-all test scope dependency
This didn't fix the error either
(I didn't really expect it to fix the error, but since this is what
the integration test does[1], it was worth a shot in the dark)

 3. Replaced my karaf feature use in the pax-exam config with
referencing the maven bundles of mockito, objenesis and hamcrest
directly, like the integration test does[2]
This didn't fix the problem either
(I didn't really expect it to, since the karaf feature pulling in
the same bundles, got the error, but it was worth trying to do the
exact same thing as the integration test)

Is there something else I can try?


References:
[1] 
<https://github.com/ops4j/org.ops4j.pax.exam2/blob/master/itest/osgi/src/it/regression-multi/pom.xml#L140>
[2] 
<https://github.com/ops4j/org.ops4j.pax.exam2/blob/master/itest/osgi/src/it/regression-multi/src/test/java/org/ops4j/pax/exam/regression/multi/wrap/MockitoTest.java#L117>

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax-exam karaf test fails to start up because it can't get a BundleContext

2017-10-07 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> This worked fine in getting karaf to start and the service to be
> produced, but actually using mockito mocks failed:
>  java.lang.LinkageError: loader constraint violation in interface itable 
> initialization: when resolving method 
> "$javax.servlet.http.HttpServletRequest$$EnhancerByMockitoWithCGLIB$$22025fbe.newInstance([Ljava/lang/Class;[Ljava/lang/Object;[Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;"
>  the class loader (instance of 
> org/mockito/internal/creation/util/SearchingClassLoader) of the current 
> class, 
> $javax/servlet/http/HttpServletRequest$$EnhancerByMockitoWithCGLIB$$22025fbe, 
> and the class loader (instance of 
> org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) for interface 
> org/mockito/cglib/proxy/Factory have different Class objects for the type 
> [Lorg/mockito/cglib/proxy/Callback; used in the signature
[snip!]

> This is the code that fails:
>  
> https://gist.github.com/steinarb/5534a87dd42827fad7a461732d6d5684#file-fildeleintegrationtest-java-L64

> I don't have any idea how to fix this, or even if it's fixable...?

I tried setting
frameworkProperty("felix.bootdelegation.implicit").value("false"),
like what I found here:
 
https://github.com/ops4j/org.ops4j.pax.exam2/blob/master/itest/osgi/src/it/regression-multi/src/test/java/org/ops4j/pax/exam/regression/multi/wrap/MockitoTest.java#L100

But I still got the same error:
java.lang.LinkageError: loader constraint violation in interface itable 
initialization: when resolving method 
"$javax.servlet.http.HttpServletRequest$$EnhancerByMockitoWithCGLIB$$ec4b6d2f.newInstance([Ljava/lang/Class;[Ljava/lang/Object;[Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;"
 the class loader (instance of 
org/mockito/internal/creation/util/SearchingClassLoader) of the current class, 
$javax/servlet/http/HttpServletRequest$$EnhancerByMockitoWithCGLIB$$ec4b6d2f, 
and the class loader (instance of 
org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) for interface 
org/mockito/cglib/proxy/Factory have different Class objects for the type 
[Lorg/mockito/cglib/proxy/Callback; used in the signature

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax-exam karaf test fails to start up because it can't get a BundleContext

2017-10-07 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> Plan going forward:
>  1. Create a feature file in the test project (ie. a real artifact and
> not a test scope thing), using karaf-maven-plugin and the above
> three bundles as compile dependencies of the test project
>  2. Add the feature file to the pax-exam config and install the mockito
> feature 

This worked fine in getting karaf to start and the service to be
produced, but actually using mockito mocks failed:
 java.lang.LinkageError: loader constraint violation in interface itable 
initialization: when resolving method 
"$javax.servlet.http.HttpServletRequest$$EnhancerByMockitoWithCGLIB$$22025fbe.newInstance([Ljava/lang/Class;[Ljava/lang/Object;[Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;"
 the class loader (instance of 
org/mockito/internal/creation/util/SearchingClassLoader) of the current class, 
$javax/servlet/http/HttpServletRequest$$EnhancerByMockitoWithCGLIB$$22025fbe, 
and the class loader (instance of 
org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) for interface 
org/mockito/cglib/proxy/Factory have different Class objects for the type 
[Lorg/mockito/cglib/proxy/Callback; used in the signature
at 
sun.reflect.GeneratedSerializationConstructorAccessor25.newInstance(Unknown 
Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at 
org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:48)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)
at 
org.mockito.internal.creation.instance.ObjenesisInstantiator.newInstance(ObjenesisInstantiator.java:14)
at 
org.mockito.internal.creation.cglib.ClassImposterizer.createProxy(ClassImposterizer.java:143)
at 
org.mockito.internal.creation.cglib.ClassImposterizer.imposterise(ClassImposterizer.java:58)
at 
org.mockito.internal.creation.cglib.ClassImposterizer.imposterise(ClassImposterizer.java:49)
at 
org.mockito.internal.creation.cglib.CglibMockMaker.createMock(CglibMockMaker.java:24)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:33)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59)
at org.mockito.Mockito.mock(Mockito.java:1285)
at org.mockito.Mockito.mock(Mockito.java:1163)
at 
no.priv.bang.fildele.tests.FildeleIntegrationTest.testServlet(FildeleIntegrationTest.java:66)

This is the code that fails:
 
https://gist.github.com/steinarb/5534a87dd42827fad7a461732d6d5684#file-fildeleintegrationtest-java-L64

I don't have any idea how to fix this, or even if it's fixable...?

This is what I did:
 1. Added the following config to the pom of the test project:
 
https://gist.github.com/steinarb/5534a87dd42827fad7a461732d6d5684#file-fildele-tests-pom-xml-L12
 
https://gist.github.com/steinarb/5534a87dd42827fad7a461732d6d5684#file-fildele-tests-pom-xml-L106
the pluginManagement setting in the parent, is:
 
https://gist.github.com/steinarb/5534a87dd42827fad7a461732d6d5684#file-parent-pom-xml-L163
 2. Added the feature repo and the feature to the pax-exam config:
 
https://gist.github.com/steinarb/5534a87dd42827fad7a461732d6d5684#file-fildeleintegrationtest-java-L44
 
https://gist.github.com/steinarb/5534a87dd42827fad7a461732d6d5684#file-fildeleintegrationtest-java-L59

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pax-exam karaf test fails to start up because it can't get a BundleContext

2017-10-07 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> Can anyone spot what I've missed in the copy/paste...?

I think I did.

> [1] 
> <https://github.com/steinarb/ukelonn/blob/master/ukelonn.tests/src/test/java/no/priv/bang/ukelonn/tests/UkelonnServiceIntegrationTest.java#L45>
> [2] 
> <https://gist.github.com/steinarb/42a269df682e69ce6fb3c413ca91baa6#file-fildeleintegrationtest-java-L29>

The difference between the original[1] and the copy[2], are two things:
 1. The copy has the pax-jdbc feature repository removed
 2. The copy has an additional mockito bundle attempted installed

When I removed the mockito bundle from the pax-exam config, the test was
able to start:
 
https://gist.github.com/steinarb/42a269df682e69ce6fb3c413ca91baa6#file-fildeleintegrationtest-java-L59

So I tried to figure out what else mockito-core would need.

First step was to run "mvn dependency:tree" in the pax-exam test
project, and the output for mockito-core, was:
[INFO] \- org.mockito:mockito-core:jar:1.10.19:test
[INFO]+- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO]\- org.objenesis:objenesis:jar:2.1:test

I then looked at the MANIFEST.MF of the mockito-core jar, and it was an
OSGi bundle.  The only non-optional import packages were from
org.hamcrest and org.objenesis.

mvn:org.objenesis/objenesis/2.4 (the newest objenesis in my local maven
repo) was also an osgi bundle (so was version 2.1 of objenesis).

However, mvn:org.hamcrest/hamcrest-core/1.3 in my local repo was a plain
jar.

I googled "osgi bundle hamcrest" and found:
 
https://mvnrepository.com/artifact/org.apache.servicemix.bundles/org.apache.servicemix.bundles.hamcrest/1.3_1

So I tried out the bundles in a karaf 4.1.2 console:
 karaf@root()> bundle:install 
mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.hamcrest/1.3_1
 Bundle ID: 52
 karaf@root()> bundle:install mvn:org.objenesis/objenesis/2.4
 Bundle ID: 53
 karaf@root()> bundle:install mvn:org.mockito/mockito-core/1.10.19
 Bundle ID: 54
 karaf@root()> bundle:list
 START LEVEL 100 , List Threshold: 50
 ID | State | Lvl | Version | Name
 
---+---+-+-+---
 28 | Active|  80 | 4.1.2   | Apache Karaf :: OSGi Services :: Event
 52 | Installed |  80 | 1.3.0.1 | Apache ServiceMix :: Bundles :: hamcrest-all
 53 | Installed |  80 | 2.4.0   | Objenesis
 54 | Installed |  80 | 1.10.19 | Mockito Mock Library for Java. Core bundle 
requires Hamcrest-core and Objenesis.
 karaf@root()> bundle:resolve 54
 karaf@root()> bundle:list
 START LEVEL 100 , List Threshold: 50
 ID | State| Lvl | Version | Name
 
---+--+-+-+--
 28 | Active   |  80 | 4.1.2   | Apache Karaf :: OSGi Services :: Event
 52 | Resolved |  80 | 1.3.0.1 | Apache ServiceMix :: Bundles :: hamcrest-all
 53 | Resolved |  80 | 2.4.0   | Objenesis
 54 | Resolved |  80 | 1.10.19 | Mockito Mock Library for Java. Core bundle 
requires Hamcrest-core and Objenesis.
 karaf@root()>

This looked promising.

Plan going forward:
 1. Create a feature file in the test project (ie. a real artifact and
not a test scope thing), using karaf-maven-plugin and the above
three bundles as compile dependencies of the test project
 2. Add the feature file to the pax-exam config and install the mockito
feature 

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pax-exam karaf test fails to start up because it can't get a BundleContext

2017-10-07 Thread Steinar Bang
Karaf 4.1.2
Pax-exam 4.11.0
Java 1.8
Windows 10

I'm trying to copy-paste stuff from a working pax-exam karaf test[1],
but the copy-pasted test[2] fails in startup, because it can't find the
BundleContext{3].  Stack trace of the failing unit test is[4].

I have tried commenting out my own stuff in case there are some stuff
missing from the feature, but that didn't help.  Besides, the feature
file[5] works fine when installing the feature from the console of a
regular karaf 4.1.2.

I've also tried bumping the systemTimeout() up to 72 milliseconds,
without that helping either.

Can anyone spot what I've missed in the copy/paste...?

Thanks!


- Steinar

References:
[1] 

[2] 

[3] 

[4] 

[5] 


-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: OPS4J Pax URL, find what maven repository has an artifact?

2017-09-04 Thread Steinar Bang
> Grzegorz Grzybek :

> What you described is implemented in JBoss Fuse 6.x / Fabric8 v1. But it's
> not that big problem to try to implement it.

> 1b) "scan the configured repositories" - you have
> org.ops4j.pax.url.mvn.repositories property in org.ops4j.pa.url.mvn PID
> 1c) entire point is just "aether resolution operation for SNAPSHOT version"
> - see the details here:
> http://ggrzybek.blogspot.com/2016/10/using-maven-with-osgi-part-3.html

Interesting article! (google didn't find it during my searches for
aether and maven stuff)

> In Karaf you can:

> osgi:install mvn:groupId/artifactId/version

> if "version" is X.Y.Z-SNAPSHOT, then simple "osgi:update  symbolic name>" will go through entire Aether/Maven resolution according to
> configured update policy (for example, if local version of metadata is not
> older than 1 day, "org.ops4j.pax.url.mvn.globalUpdatePolicy = daily" will
> prevent redownloading of metadata.

I'm currently using globalUpdatePolicy always, and that's enough to make
 bundle:update bundlesymbolicname
reload the bundle with a new snapshot made by travis-ci:
 
https://github.com/steinarb/ukelonn#oppsett-av-webappen-på-en-server-med-debian-gnulinux
(step 6, text in Norwegian but the config stuff should be readable)

So I'm close to having continous deployment from travis-ci, but I'm
missing some way of tickling the "bundle:update" command on the affected
bundles.

> See http://ggrzybek.blogspot.com/2016/07/using-maven-with-osgi-part-2.html
> for more information about pax-url-aether configuration
> See http://ggrzybek.blogspot.com/2016/10/using-maven-with-osgi-part-3.html
> for more information about SNAPSHOT resolution

Looks like I will rely on karaf cave for this functionality, but this is
interesting stuff, so I will read it anyway.  

Thanks for the URLs, and the explanations!


- Steinar

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: OPS4J Pax URL, find what maven repository has an artifact?

2017-09-04 Thread Steinar Bang
> Jean-Baptiste Onofré :

> it's already what I replied on the Karaf mailing list.
> AFAIR, Steinar wants to avoid bundle:update: he wants an auto-update
> (and bundle:watch can only update from the local repository).

Yes, that is correct.

It's the final building block I need to get continous deployment
working.

(and if karaf cave gets it I'll use that instead of rolling my own)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


OPS4J Pax URL, find what maven repository has an artifact?

2017-09-04 Thread Steinar Bang
I'm thinking about writing an OSGi plugin for karaf that can be
configured to watch a remote repository for snapshot updates.

The idea is to do something like this
 1. For each configured bundle, if the bundle has a snapshot version, intially 
do
a. Get the maven coordinates
b. Scan the configured repositories and chose the first repository
   that has the artifact
c. Download the Repo-URL/groupId/artifactId/version/maven-metadata.xml
   and parse it to find the most recent snapshot, taking note of the
   maven repository, newest snapshot version, newest snapshot
   timestamp, as well as the update time of the maven-metadata.xml
   file
 2. Schedule a job that for each configured bundle, that:
a. Does a conditional GET for the 
Repo-URL/groupId/artifactId/version/maven-metadata.xml
   file
b. If the conditional GET receives content, parse the content and
   extract the snapshot version and timestamp and compare them with
   the save versions to see if they actually have changed
c. If a new snapshot has arrived, tell the bundle to update

Right now I'm reading the Pax-URL documentation[1] trying to figure out
if it's possible to do step 1b.

Does anyone familiar with Pax-Url think this might be feasible? Or is
the actual repo used so hidden away that it is hard to do?

Thanks!


- Steinar

References:
[1] 

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: java.lang.ClassCastException: org.apache.derby.jdbc.ClientDriver cannot be cast to org.apache.derby.jdbc.InternalDriver

2017-08-18 Thread Steinar Bang
>>>>> Steinar Bang <s...@dod.no>:

> I am trying to write the derby database to a derby network server, and
> that doesn't work well:
>  java.lang.ClassCastException: org.apache.derby.jdbc.ClientDriver cannot be 
> cast to org.apache.derby.jdbc.InternalDriver
>   at org.apache.derby.jdbc.BasicEmbeddedDataSource40.findDriver(Unknown 
> Source)
>   at 
> org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource.createPooledConnection(Unknown
>  Source)
>   at 
> org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource.getPooledConnection(Unknown
>  Source)
>   at 
> no.priv.bang.ukelonn.bundle.db.test.UkelonnDatabaseProviderTest.addUkelonnSchemaAndDataToDerbyServer(UkelonnDatabaseProviderTest.java:296)

> Is the problem that I'm trying to use both a in-memory and a network
> client from the same process?

No, the problem was that I tried to use the OPS4J DerbyDataSourceFactory
to create a connection for a derby client JDBC URL[1], and the
DerbyDataSourceFactory can't do that, because it creates a derby
EmbeddedDataSource[2].

And an EmbeddedDataSource can't create a client connection.  That's why
things failed.

So let the test create a client connection using the regular API[3], and
then the test ran fine, and was able to output the liquibase stuff to a
running derby container.

References:
[1] 
<https://github.com/steinarb/ukelonn/blob/f3c8bf2c3cadb931cce414f1619be39b4e44711e/ukelonn.bundle.db.test/src/test/java/no/priv/bang/ukelonn/bundle/db/test/UkelonnDatabaseProviderTest.java#L293>
[2] 
<https://github.com/ops4j/org.ops4j.pax.jdbc/blob/master/pax-jdbc-derby/src/main/java/org/ops4j/pax/jdbc/derby/impl/DerbyDataSourceFactory.java#L41>
[3] 
<https://github.com/steinarb/ukelonn/blob/scratch/derby-test-writing-to-network-server/ukelonn.bundle.db.test/src/test/java/no/priv/bang/ukelonn/bundle/db/test/UkelonnDatabaseProviderTest.java#L284>

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   >