Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Plugin with JDBC H2

Joel Suter January 16, 2018

Hello together

I am trying to connect to the Bitbucket Database. I try to do this with the H2 driver. The Problem is it needs a lot of other dependencies. I imported all but osgi can't resolve the package "org.apache.lucene" "lucene-queryparser". I cleary imported it in my POM. Somehow it can't be resolved.

How did you guys do your Database connection? I would be glad if i could see a POM of you.

Info: 

pom.xml

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.194</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.vividsolutions/jts -->
<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>7.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-queryparser -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>7.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-queries -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
<version>7.2.1</version>
</dependency>

Error:

Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle 
com.zuehlke.ams.pss.monitor.bitbucket
[127]: Unable to resolve 127.0: missing requirement [127.0] osgi.wiring.package;
(osgi.wiring.package=org.apache.lucene.queryParser)

Thanks for the Help.

 

2 answers

1 vote
Bryan Turner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2018

@Joel Suter,

The Bitbucket Server database, its schema, and how to connect to it are not part of our API, and are not for plugin developers to use directly. This is true whether the system is using the H2 internal database or has been migrated to an external database such as PostgreSQL or MySQL. As accessing the database directly is unsupported, we won't offer advice or assistance on how to do so.

If your plugin needs to store data in the database in its own tables, you may do so using Active Objects. Active Objects may not be used to access the system's database tables. To access data in the system's database tables, you may use our published service API. Attempting to access the system's tables directly via the database is not supported.

Best regards,
Bryan Turner
Atlassian Bitbucket

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 18, 2018

Ohh, can I quote you in other places?   

It is a very clear explanation of why people should not try direct database access in Bitbucket apps, with good guidance on the right approach (and, I'd like to stretch it if possible - it applies to most of the rest of the Atlassian applications if I've understood it correctly)

Bryan Turner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2018

@Nic Brough -Adaptavist-,

Quote away!

I think in general the same advice applies to all the other products, but I believe some of them have other supported methods to access the database in addition to Active Objects. Jira, for example, has a much looser set of restrictions for their database (see here) than Bitbucket Server does. Their documentation still discourages direct database access, though, so I think it's fair to say my answer applies there as a best practice.

Bitbucket Server in general enforces its API boundaries more strongly than the other products. For example, in Jira it's possible (but not recommended) to access "internal" types in plugins. In Bitbucket Server we enforce that more strictly; our internal API is not exported via OSGi and may not be used by plugins. Attempts to do so fail to resolve internal classes at runtime. Our more aggressive limitations are at least partially a result of the experience of supporting "looser" API restrictions in the other products.

Best regards,
Bryan Turner
Atlassian Bitbucket

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 18, 2018

Thanks Brian,

That's also a good guide on how to be careful about the nuances for other applications!  Very much appreciated!

0 votes
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2018

Hi Joel, are you running a production instance of Bitbucket with the embedded database? That configuration is not supported and we won't be able to help you with that. The internal Bitbucket database is meant for testing single user instances, and it's proven to not work with much more than 10 users, or even less if you have a lot of CI tool activity or if the use is more than what 10 users would normally generate.

We recommend using external databases such as Postgres or MySql. You can read Connecting Bitbucket Server to an external database for instructions.

 

Can you try that with one of the supported databases and let us know how it goes?

 

Best regards!

Ana

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events