Failed to load during JIRA startup. java.lang.NoClassDefFoundError: javax/management/InstanceNotFoundException


#1

Java

D:\>set
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161

How to fix error in my custom Jira plugin?

Second build question without any response… :sleepy::sleepy::sleepy:

Java SDK contains this class, so it is strange.

j2ee 1.2.1 jar fixes startup, but breaks getConnection() call in Java code

Caused by: java.lang.ClassCastException: sun.management.MemoryImpl cannot be cast to javax.management.NotificationEmitter

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>com.x.jira.plugin</groupId>
	    <artifactId>com.x.jira.plugin-y</artifactId>
	    <version>1.0.0</version>
	    <organization>
	        <name>x</name>
	        <url>https://www.x.co/</url>
	    </organization>
	    <name>com.x.jira.plugin-y</name>
	    <description>This is the com.x.jira.plugin:com.x.jira.plugin-y plugin
		    for Atlassian JIRA.</description>
	    <packaging>atlassian-plugin</packaging>
		<repositories>
			<repository>
				<id>ora</id>
				<url>https://maven.oracle.com</url>
			</repository>
		</repositories>
	    <dependencies>
	        <dependency>
	            <groupId>com.atlassian.jira</groupId>
	            <artifactId>jira-api</artifactId>
	            <version>${jira.version}</version>
	            <scope>provided</scope>
	        </dependency>
			 <dependency>
	            <groupId>com.oracle</groupId>
	            <artifactId>ojdbc6</artifactId>
	            <version>12.1.0.1-atlassian-hosted</version>
	        </dependency>
		             <dependency>
	            <groupId>com.oracle.ons</groupId>
	            <artifactId>com.springsource.oracle.ons</artifactId>
	            <version>10.2.0.2</version>
	        </dependency>
		             <dependency>
	            <groupId>com.oracle</groupId>
	            <artifactId>oraclepki</artifactId>
	            <version>1.0</version>
	        </dependency>
		             <dependency>
	            <groupId>com.oracle</groupId>
	            <artifactId>orai18n</artifactId>
	            <version>11.2.0.3</version>
	        </dependency>
		    <dependency>
	    <groupId>postgresql</groupId>
	    <artifactId>postgresql</artifactId>
	    <version>9.1-901-1.jdbc4</version>
	</dependency>
		    <dependency>
	    <groupId>mysql</groupId>
	    <artifactId>mysql-connector-java</artifactId>
	    <version>5.1.47</version>
	</dependency>
		    <dependency>
	    <groupId>com.microsoft.sqlserver</groupId>
	    <artifactId>mssql-jdbc</artifactId>
	    <version>7.0.0.jre8</version>
	</dependency>
		    <dependency>
	    <groupId>com.microsoft.aad</groupId>
	    <artifactId>adal4j</artifactId>
	    <version>0.0.2</version>
	</dependency>
			   
		    <dependency>
	    <groupId>c3p0</groupId>
	    <artifactId>c3p0</artifactId>
	    <version>0.9.1.2</version>
	</dependency>
			   
		    <dependency>
	    <groupId>com.sun.jna</groupId>
	    <artifactId>jna</artifactId>
	    <version>3.0.9</version>
	</dependency>
		    <dependency>
	    <groupId>net.java.dev.jna</groupId>
	    <artifactId>jna-platform</artifactId>
	    <version>5.2.0</version>
	</dependency>
		    <dependency>
	    <groupId>org.jy.jyas</groupId>
	    <artifactId>jy-as-connector</artifactId>
	    <version>6.1.0.Final</version>
			    <exclusions>
				    <exclusion><groupId>xml-apis</groupId>
				    <artifactId>xml-apis</artifactId></exclusion>
			    </exclusions>
	</dependency>
		 
			<dependency>
				<groupId>org.projectlombok</groupId>
				<artifactId>lombok</artifactId>
				<version>1.16.20</version>
				<scope>provided</scope>
			</dependency>
			<dependency>
				<groupId>com.atlassian.jira</groupId>
				<artifactId>jira-core</artifactId>
				<version>${jira.version}</version>
				<scope>provided</scope>
				 <exclusions>
	 <exclusion>
	 <groupId>xml-apis</groupId>
	 <artifactId>xml-apis</artifactId>
	 </exclusion>
	 </exclusions>
			</dependency>
		    <dependency>
	            <groupId>junit</groupId>
	            <artifactId>junit</artifactId>
	            <version>4.10</version>
	            <scope>test</scope>
	        </dependency>
	        <dependency>
	            <groupId>com.atlassian.plugin</groupId>
	            <artifactId>atlassian-spring-scanner-annotation</artifactId>
	            <version>${atlassian.spring.scanner.version}</version>
	            <scope>compile</scope>
	        </dependency>
	        <dependency>
	            <groupId>com.atlassian.plugin</groupId>
	            <artifactId>atlassian-spring-scanner-runtime</artifactId>
	            <version>${atlassian.spring.scanner.version}</version>
	            <scope>runtime</scope>
	        </dependency>
	        <dependency>
	            <groupId>javax.inject</groupId>
	            <artifactId>javax.inject</artifactId>
	            <version>1</version>
	            <scope>provided</scope>
	        </dependency>
		    <dependency>
	            <groupId>com.atlassian.plugins</groupId>
	            <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
	            <version>${plugin.testrunner.version}</version>
	            <scope>test</scope>
	        </dependency>
	        <dependency>
	            <groupId>javax.ws.rs</groupId>
	            <artifactId>jsr311-api</artifactId>
	            <version>1.1.1</version>
	            <scope>provided</scope>
	        </dependency>
	        <dependency>
	            <groupId>com.google.code.gson</groupId>
	            <artifactId>gson</artifactId>
	            <version>2.2.2-atlassian-1</version>
	        </dependency>
		    <dependency>
	            <groupId>javax.servlet</groupId>
	            <artifactId>servlet-api</artifactId>
	            <version>2.4</version>
	            <scope>provided</scope>
	        </dependency>
	        <dependency>
	            <groupId>javax.xml.bind</groupId>
	            <artifactId>jaxb-api</artifactId>
	            <version>2.1</version>
	            <scope>provided</scope>
	        </dependency>
	        <dependency>
	            <groupId>com.atlassian.plugins.rest</groupId>
	            <artifactId>atlassian-rest-common</artifactId>
	            <version>1.0.2</version>
	            <scope>provided</scope>
	        </dependency>
	        <dependency>
	            <groupId>com.atlassian.sal</groupId>
	            <artifactId>sal-api</artifactId>
	            <version>2.6.0</version>
	            <scope>provided</scope>
	        </dependency>
	        <dependency>
	            <groupId>org.apache.wink</groupId>
	            <artifactId>wink-client</artifactId>
	            <version>1.1.3-incubating</version>
	            <scope>test</scope>
	        </dependency>
	        <dependency>
	            <groupId>org.mockito</groupId>
	            <artifactId>mockito-all</artifactId>
	            <version>1.8.5</version>
	            <scope>test</scope>
	        </dependency>
	    </dependencies>
		
		<dependencyManagement>
			<dependencies>
				<dependency>
	<groupId>org.jy.jyas</groupId>
	<artifactId>jy-as-connector</artifactId><version>6.1.0.Final</version>
					<exclusions>
						<exclusion>
							<groupId>xml-apis</groupId>
							<artifactId>xml-apis</artifactId></exclusion>
					</exclusions>
	</dependency>
					<dependency>
				<groupId>com.atlassian.jira</groupId>
				<artifactId>jira-core</artifactId>
				<version>${jira.version}</version>
				<scope>provided</scope>
				 <exclusions>
	 <exclusion>
	 <groupId>xml-apis</groupId>
	 <artifactId>xml-apis</artifactId>
	 </exclusion>
	 </exclusions>
			</dependency>
			</dependencies>
		</dependencyManagement>
		
		<pluginRepositories>
			<pluginRepository>
	    <id>atlassian</id>
	    <url>https://maven.atlassian.com/repository/public</url>
	     <releases>
	        <enabled>true</enabled>
	        <checksumPolicy>warn</checksumPolicy>
	      </releases>
	      <snapshots>
	         <enabled>true</enabled>
	      </snapshots>
	 </pluginRepository>
		</pluginRepositories>
	    <build>
	        <plugins>
	            <plugin>
	                <groupId>com.atlassian.maven.plugins</groupId>
	                <artifactId>maven-jira-plugin</artifactId>
	                <version>${amps.version}</version>
	                <extensions>true</extensions>
	                <configuration>
		                <compressResources>false</compressResources>
	                    <productVersion>${jira.version}</productVersion>
	                    <productDataVersion>${jira.version}</productDataVersion>
		                <enableQuickReload>true</enableQuickReload>
	                    <enableFastdev>false</enableFastdev>
		                <instructions>
	                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
			                <Export-Package>com.x.jira.plugin.y.api,</Export-Package>
			                <Import-Package>org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", *</Import-Package>
			                <Spring-Context>*</Spring-Context>
	                    </instructions>
	<excludes>
	<exclude>**/CertificateTest.class</exclude>
		<exclude>**/GetoptDemo.class</exclude>
		<exclude>**/KeyStoreTest.class</exclude>
		<exclude>CertificateTest.class</exclude>
		<exclude>GetoptDemo.class</exclude>
		<exclude>KeyStoreTest.class</exclude>
	</excludes>
	                </configuration>
	            </plugin>
	            <plugin>
	                <groupId>com.atlassian.plugin</groupId>
	                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
	                <version>${atlassian.spring.scanner.version}</version>
	                <executions>
	                    <execution>
	                        <goals>
	                            <goal>atlassian-spring-scanner</goal>
	                        </goals>
	                        <phase>process-classes</phase>
	                    </execution>
	                </executions>
	                <configuration>
	                    <scannedDependencies>
	                        <dependency>
	                            <groupId>com.atlassian.plugin</groupId>
	                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
	                        </dependency>
	                    </scannedDependencies>
	                    <verbose>false</verbose>
	                </configuration>
	            </plugin>
	        </plugins>
	    </build>
	    <properties>
	        <jira.version>7.12.0</jira.version>
	        <amps.version>8.0.0-edfff1b</amps.version>
	        <plugin.testrunner.version>1.2.3</plugin.testrunner.version>
	        <atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
		    <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
		    <testkit.version>6.3.11</testkit.version>
	        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	        <maven.compiler.source>1.8</maven.compiler.source>
	        <maven.compiler.target>1.8</maven.compiler.target>
	    </properties>
	</project>

#2

Don’t bundle the drivers in the Pom - it will cause a huge plugin jar and potentially cause you to have licensing issues (there’s a reason why Atlassian doesn’t do this). At least makes the provided scope.

The error with the sun.* class comes becomes sun is an internal java package - you shouldn’t reference it (and if you’re not - I’m guess one of your dependencies is).


#3

Thx! I removed drivers, but how to connect external oracle db
without jndi? If url was added in runtime, I need to have drivers for this before it.


#4

Can you not have the drivers added by the installation admin? Just like they do for Jira etc?


#5

What do u mean? I just created plugin with atlas command and tried to add drivers.
Same result is, when I am trying to start Tomcat with these drivers in lib folder.