When I try to do a JDNI lookup from my plugin, a class not found exception is thrown: java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory
Anyone have an idea? Is this class not included with JIRA 5.2 / tomcat 7? Do I have to include it? The Atlassian maven repositories give some dependencies that fit, but all like "jboss this" and "jboss that", nothing that gives me a comfortable feeling that it is the way to go. (https://maven.atlassian.com/index.html#nexus-search;classname~javaURLContextFactory)
plugin code:
InitialContext initalContext = new InitialContext(); // <---- exception thrown here! Context context = (Context) initalContext.lookup("java:comp/env"); datasource = (DataSource) context.lookup("jbdc/OracleDS");
The POM:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>xxx</groupId> <artifactId>xxx</artifactId> <version>1.0</version> <organization> <name>xxx</name> <url>xxx</url> </organization> <name>xxx</name> <description>xxx</description> <packaging>atlassian-plugin</packaging> <properties> <jira.version>5.2.8</jira.version> <jira.data.version>5.0</jira.data.version> <amps.version>4.2.3</amps.version> <jersey.version>1.8-atlassian-6</jersey.version> <jackson.version>1.9.4</jackson.version> </properties> <build> <plugins> <plugin> <groupId>com.atlassian.maven.plugins</groupId> <artifactId>maven-jira-plugin</artifactId> <version>${amps.version}</version> <extensions>true</extensions> <configuration> <server>localhost</server> <productVersion>${jira.version}</productVersion> <productDataVersion>${jira.data.version}</productDataVersion> <productDataPath>${basedir}/src/test/resources/generated-test-resources.zip</productDataPath> <log4jProperties>src/main/resources/log4j.properties</log4jProperties> <instanceId>jira</instanceId> <products> <product> <id>jira</id> <instanceId>jira</instanceId> <version>${jira.version}</version> <dataSources> <!-- Still need to provide datasource for JIRA --> <dataSource> <jndi>jdbc/JiraDS</jndi> <driver>org.hsqldb.jdbcDriver</driver> <!-- default username, password and url are filled in (see target/container/tomcatxx/cargo-jira-home/conf/context.xml) --> </dataSource> <!-- Additional datasource for connecting to Oracle --> <dataSource> <jndi>jdbc/OracleDS</jndi> <driver>oracle.jdbc.OracleDriver</driver> <username></username> <!-- leave empty, otherwise default values from JiraDS are filled in --> <password></password> <url></url> <libArtifacts> <libArtifact> <groupId>com.oracle</groupId> <artifactId>ojdbc16</artifactId> <version>11.2.0.3</version> </libArtifact> </libArtifacts> </dataSource> </dataSources> </product> </products> </configuration> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <!-- JIRA dependencies --> <dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-api</artifactId> <version>${jira.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-core</artifactId> <version>${jira.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.atlassian.templaterenderer</groupId> <artifactId>atlassian-template-renderer-api</artifactId> <version>1.1.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <!-- REST dependencies --> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>jsr311-api</artifactId> <version>1.1.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-core</artifactId> <version>${jersey.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>${jersey.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-jaxrs</artifactId> <version>${jackson.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>${jersey.version}</version> <scope>provided</scope> </dependency> <!-- data-related dependencies --> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc16</artifactId> <version>11.2.0.3</version> <scope>runtime</scope> </dependency> <!-- test dependencies --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope> </dependency> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito</artifactId> <version>1.4.9</version> <scope>test</scope> </dependency> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-module-junit4</artifactId> <version>1.4.9</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-chrome-driver</artifactId> <version>2.31.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-support</artifactId> <version>2.31.0</version> <scope>test</scope> </dependency> </dependencies> </project>
Community moderators have prevented the ability to post new answers.
i am able to accessing JNDI succussfully using the answer posted here
https://answers.atlassian.com/questions/6374/how-do-i-access-jndi-from-a-version-2-osgi-plugin
In my search I stumbled on that page indeed, but I did not see what made that work in specific. Is it the concept of "bundles" ? I see some bundle-related stuff in the POM file, is this what makes it work? Because I don't see anything that would make the "javax naming" package available for use in my plug-in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sorry! i don't have much knowldege on OSGI bundles but it worked for me!
just try with that code once!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In my search I stumbled on that page indeed, but I did not see what made that work in specific. Is it the concept of "bundles" ?
A simple google yielded this (http://blog.knowhowlab.org/2010/10/osgi-tutorial-4-ways-to-activate-code.html#ba).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you try to do an atlas-clean and repackage it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I did.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.