scala Ide Not identifying my class as main method - macos

I have researched some answers in Stackoverflow but my error seems to be different. Having said that i am a newbie in scala hence please consider that as well.
I am trying to create multi class project in scala. Project Format is like this
Test Project
|
COM Package
|
|-->App.class
|
COM.Test Package
|
|-->App1.class
Code Snippet
App.scala
object App {
def main(args : Array[String]): Unit = {
var logger = Logger.getLogger(this.getClass())
if (args.length < 3) {
logger.error("=> wrong parameters number")
System.err.println("Usage: MainExample <path-to-files> <srcCode> <tableName>")
System.exit(1)
}
println("In Main Class")
}
App1.scala
object App1 {
def main(args : Array[String]): Unit = {
println("In Sub Class")
}
Pom.xml
<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</groupId>
<artifactId>test</artifactId>
<version>1.0.0</version>
<name>${project.artifactId}</name>
<description>My wonderfull scala app</description>
<inceptionYear>2015</inceptionYear>
<licenses>
<license>
<name>My License</name>
<url>http://....</url>
<distribution>repo</distribution>
</license>
</licenses>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.10.4</scala.version>
<scala.compat.version>2.10.4</scala.compat.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<!-- >testSourceDirectory>src/test/scala</testSourceDirectory -->
<!-- plugins>
<plugin>
<see http://davidb.github.com/scala-maven-plugin >
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<args>
<arg>-make:transitive</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
</plugins -->
</build>
</project>
I am using SCALA IDE along with Scala Maven Plugin. I have commented out the build plugin but it doen=s not make a difference if that is turned on as well.
Two Issues i am facing
Issue 1) I am unable to Run App1.scala in Sub Package COM.Test. App.scala is run without issue from Run As -->Scala Application. But when ever i try to run App1.scala the scala side is not able to find Main Class
Issue 2) I am unable to debug my code for App.scala in scala ide. Whenever i run Debug Command (Bug Operator) the breakpoints are skipped and code executes entirely. I use Scala JVM Launcher and checked The option Stop in Main. Please help
Using Eclipse Luna with Scala IDE and MAC OS

Package structure must correspond to directory structure in the IDE. (This is unlike scalac.)
It's hard to tell from the info you present, but I can confirm that Scala IDE (on Eclipse Luna) will not offer "Run As > Scala application" if I remove the package declaration.
For example, if the class App in directory src/p/ (source file src/p/App.scala) is not in package p, then it won't offer to run it.
Uncommenting the correct package declaration gets the run as menu back.
I can also verify that a debug config with stop in main and Scala JVM launcher works as expected for App in the default package as well as in a named package. So I don't know how that could have broken for you.

You need to add extends App to your main objects.
object App extends App {
def main(args : Array[String]): Unit = {
var logger = Logger.getLogger(this.getClass())
if (args.length < 3) {
logger.error("=> wrong parameters number")
System.err.println("Usage: MainExample <path-to-files> <srcCode> <tableName>")
System.exit(1)
}
println("In Main Class")
}

Related

Building SOA composite application using maven

Using SOA suite 11, trying building source code (composite.xml with configuration file) in SOA composite application into a jar file using maven.
Can anyone help to guide me making POM.xml for the same. i am using "Apache-ANT-Plugin" in my pom file.
http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
This POM relates to this SOA Composite, i.e. the one in this same directory.
There is another POM in the SOA Application directory which handles
the whole SOA Application, which may contain additional projects.
-->
4.0.0
test1
HelloWrold
1.0-SNAPSHOT
sar
<!--
The parent points to the common SOA parent POM. That is a special POM that is
shipped by Oracle as a point of customization (only). You can add default values
for properties like serverUrl, etc. to the SOA common parent POM, so that you
do not have to specify them over and over in every project POM.
-->
<parent>
<groupId>com.oracle.soa</groupId>
<artifactId>sar-common</artifactId>
<version>12.1.3-0-0</version>
</parent>
<properties>
<!-- These parameters are used by the compile goal -->
<scac.input.dir>${project.basedir}\SOA/</scac.input.dir>
<scac.output.dir>${project.basedir}/target</scac.output.dir>
<scac.input>${scac.input.dir}/composite.xml</scac.input>
<scac.output>${scac.output.dir}/out.xml</scac.output>
<scac.error>${scac.output.dir}/error.txt</scac.error>
<scac.displayLevel>1</scac.displayLevel>
<!-- if you are using a config plan, uncomment the following line and update to point
to your config plan -->
<!--<configplan>${scac.input.dir}/configplan.xml</configplan>-->
<!-- These parameters are used by the deploy and undeploy goals -->
<composite.name>${project.artifactId}</composite.name>
<composite.revision>1.0</composite.revision>
<composite.partition>default</composite.partition>
<serverUrl>${oracleServerUrl}</serverUrl>
<user>${oracleUsername}</user>
<password>${oraclePassword}</password>
<overwrite>true</overwrite>
<forceDefault>true</forceDefault>
<regenerateRulebase>false</regenerateRulebase>
<keepInstancesOnRedeploy>false</keepInstancesOnRedeploy>
<!-- These parameters are used by the test goal
if you are using the sca-test (test) goal, you need to uncomment the following
line and point it to your jndi.properties file. -->
<!--<jndi.properties.input>UNDEFINED</jndi.properties.input>-->
<scatest.result>${scac.output.dir}/testResult</scatest.result>
<!-- input is the name of the composite to run test suties against -->
<input>${project.artifactId}</input>
<!--<scac.ant.buildfile>${env.MW_HOME}/soa/bin/ant-sca-compile.xml</scac.ant.buildfile>
<sca.ant.testfile>${env.MW_HOME}/soa/bin/ant-sca-test.xml</sca.ant.testfile>
-->
</properties>
<build>
<plugins>
<plugin>
<groupId>com.oracle.soa.plugin</groupId>
<artifactId>oracle-soa-plugin</artifactId>
<version>12.1.3-0-0</version>
<configuration>
<compositeName>${project.artifactId}</compositeName>
<composite>${scac.input}</composite>
<sarLocation>${scac.output.dir}/sca_${project.artifactId}_rev${composite.revision}.jar</sarLocation>
<serverUrl>${serverUrl}</serverUrl>
<user>${user}</user>
<password>${password}</password>
<!-- Note: compositeRevision is needed to package, revision is needed to undeploy -->
<compositeRevision>${composite.revision}</compositeRevision>
<revision>${composite.revision}</revision>
<scacInputDir>${scac.input.dir}</scacInputDir>
<input>${input}</input>
</configuration>
<!-- extensions=true is needed to use the custom sar packaging type -->
<extensions>true</extensions>
</plugin>
</plugins>
</build>

display application version in title using thymeleaf and springboot

I want to display in my htm page the version of my webapp, using something like this (thymeleaf inside) :
<h4 th:text="${version}">Version</h4>
The data is well set in the pom.xml :
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.test.navig</groupId>
<artifactId>navigo</artifactId>
<version>2.0.3-SNAPSHOT</version>
...
<!-- Package as an executable jar -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>Application</mainClass>
<addDefaultImplementationEntries>
true
</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
and I can see it in the MANIFEST.MF (which is in the generated jar under META-INF) :
Implementation-Version: 2.0.3-SNAPSHOT
I've tried to get the appplication version in the controller and set it in a ModuleAttribute :
#ModelAttribute("version")
public String getVersion() {
logger.info("ModelAttribute to get application version");
return getClass().getPackage().getImplementationVersion();
}
But getClass().getPackage().getImplementationVersion() value is null. Indeed the package implementationVersion is not the implementation Version of the application by default.
I know I'm late but Patrick's answer and Spring docs greatly helps in this matter.
1. If your pom.xml use spring-boot-starter-parent as parent, you can use #project.version# to get version (and any other Maven properties) in your application.properties file. According to Spring docs:
You can automatically expand properties from the Maven project using
resource filtering. If you use the spring-boot-starter-parent you
can
then refer to your Maven ‘project properties’ via #..# placeholders
Maven pom.xml:
<groupId>com.foo</groupId>
<artifactId>bar</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Foo</name>
<description>Bar</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
Spring application.properties:
foo.app.version=#project.version#
2. Then a class annotated with #ControllerAdvice can be used to inject version as model attribute.
#ControllerAdvice
public class ControllerAdvice {
#Value("${foo.app.version}")
private String applicationVersion;
#ModelAttribute("applicationVersion")
public String getApplicationVersion() {
return applicationVersion;
}
}
3. Finally this model attribute can be accessed by Thymeleaf as any other.
<th:block th:text="${applicationVersion}"></th:block>
Hope this helps!
Here is the simplest way I've found :
In my controller :
#ModelAttribute("version")
public String getVersion() throws IOException {
logger.info("ModelAttribute to get application version");
Manifest manif = new Manifest(
Application.class.getResourceAsStream("/META-INF/MANIFEST.MF"));
String version = (String) manif.getMainAttributes().get(
Attributes.Name.IMPLEMENTATION_VERSION);
return version;
}
In my htm page :
<h4 th:text="${version}">Version</h4>
You need to configure resource plugin to activate filtering on the file that need to be enriched with properties coming from your POM file.
In the generated war, the version (in fact ${project.version}) will be hardcoded to your POM version.

Can I weave aspect into same maven module it was defined in and into a 3rd party dependency?

I have a multimodule maven project with the following setup of relevant modules:
root
commons-app
backend
frontend
Module frontend is built into war and deployed on Tomcat. Module backend is a standard Java application packaged as jar. All I am trying to accomplish is to make the following aspect work (in both frontend and backend):
#Aspect
public class VirtuosoSequenceSanitizerAspect {
#Around("execution(* cz.cuni.mff.xrg.odcs.commons.app.facade.*Facade.save(..))")
public Object sanitizeSequenceOnSave(ProceedingJoinPoint pjp) throws Throwable {
// ... some code
}
#Before("execution(* org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(java.lang.Object, org.eclipse.persistence.internal.sessions.AbstractSession))")
public void rememberAssignSequence(JoinPoint jp) {
// .. some code
}
}
This aspect is setup as a Spring bean in commons-app-context.xml like so:
<!-- enable aspects -->
<aop:aspectj-autoproxy />
<!-- Aspect for fixing corrupted database sequences. -->
<bean id="sequenceAspect" class="cz.cuni.mff.xrg.odcs.commons.app.dao.VirtuosoSequenceSanitizerAspect" />
With this setup the around advice is working properly, however the before advice is not triggered. From what I found I concluded I need to use aspectj-maven-plugin to weave to 3rd party libs. So I added the plugin into the pom.xml for commons-app module like so:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<complianceLevel>1.7</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<!-- Weave EclipseLink dependency -->
<weaveDependencies>
<weaveDependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
</weaveDependency>
</weaveDependencies>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
</dependencies>
</plugin>
With this plugin before advice works, but around advice stops working. I have been struggling to set this up correctly so both advices work as expected, but to no avail. When building commons-app module log says both advices are woven:
--- aspectj-maven-plugin:1.5:compile (default) # commons-app ---
Join point 'method-execution(void cz.cuni.mff.xrg.odcs.commons.app.facade.ScheduleFacade.save(cz.cuni.mff.xrg.odcs.commons.app.scheduling.Schedule))' in Type 'cz.cuni.mff.xrg.odcs.commons.app.facade.ScheduleFacade' (ScheduleFacade.java:127) advised by around advice from 'cz.cuni.mff.xrg.odcs.commons.app.dao.VirtuosoSequenceSanitizerAspect' (VirtuosoSequenceSanitizerAspect.java:90)
Join point 'method-execution(void cz.cuni.mff.xrg.odcs.commons.app.facade.DPUFacade.save(cz.cuni.mff.xrg.odcs.commons.app.dpu.DPUTemplateRecord))' in Type 'cz.cuni.mff.xrg.odcs.commons.app.facade.DPUFacade' (DPUFacade.java:123) advised by around advice from 'cz.cuni.mff.xrg.odcs.commons.app.dao.VirtuosoSequenceSanitizerAspect' (VirtuosoSequenceSanitizerAspect.java:90)
Join point 'method-execution(void cz.cuni.mff.xrg.odcs.commons.app.facade.DPUFacade.save(cz.cuni.mff.xrg.odcs.commons.app.dpu.DPUInstanceRecord))' in Type 'cz.cuni.mff.xrg.odcs.commons.app.facade.DPUFacade' (DPUFacade.java:185) advised by around advice from 'cz.cuni.mff.xrg.odcs.commons.app.dao.VirtuosoSequenceSanitizerAspect' (VirtuosoSequenceSanitizerAspect.java:90)
Join point 'method-execution(void cz.cuni.mff.xrg.odcs.commons.app.facade.PipelineFacade.save(cz.cuni.mff.xrg.odcs.commons.app.pipeline.Pipeline))' in Type 'cz.cuni.mff.xrg.odcs.commons.app.facade.PipelineFacade' (PipelineFacade.java:134) advised by around advice from 'cz.cuni.mff.xrg.odcs.commons.app.dao.VirtuosoSequenceSanitizerAspect' (VirtuosoSequenceSanitizerAspect.java:90)
...
However, when I deploy frontend to Tomcat, only the before advice is triggered. How can I configure maven to always weave both advices?
My mistake, I actually found out, that the around advice is being triggered. I did not see this because the code did not do what I expected. Also, I thought it is not triggered because a debugger breakpoint was not hit. From a brief googling I found the reason...
If around advice is inlined, the debugger can't figure out what to do
(we still have some JSR 45 related work to do in this area, and
possibly so does the Eclipse debugger). To debug around advice, you
also need to go to the project properties and turn off the "inline
around advice" AspectJ compiler option. Debugging should then
hopefully work as expected...

NullPointerExpection on basic EJB application in NetBeans 7.3.1

I'm doing a course on Enterprise computing using Beginning Java EE 6 Platform with GlassFish 3: From Novice to Professional
Last chapter was about EJB and I've actually found it very hard to understand.
I've been trying to run one of the book's sample codes in order to try to better understand EJB but I'm getting a NullPointerException whenever I call for the EJB.
I'm using NetBeans 7.3.1 and the Maven and Glassfish versions provided with NetBeans (Maven seems to be 3.0.5, and Glassfish is 4.0)
This is the code for the main class:
package org.beginningee6.book.chapter06;
import javax.ejb.EJB;
/**
* #author Antonio Goncalves
* APress Book - Beginning Java EE 6 with Glassfish
* --
*/
public class Main {
// ======================================
// = Attributes =
// ======================================
#EJB
private static BookEJBRemote bookEJB;
// ======================================
// = Public Methods =
// ======================================
public static void main(String[] args) {
// Creates an instance of book
Book book = new Book();
book.setTitle("The Hitchhiker's Guide to the Galaxy");
book.setPrice(12.5F);
book.setDescription("Science fiction comedy series created by Douglas Adams.");
book.setIsbn("1-84023-742-2");
book.setNbOfPage(354);
book.setIllustrations(false);
book = bookEJB.createBook(book);
System.out.println("### Book created : " + book);
book.setTitle("H2G2");
book = bookEJB.updateBook(book);
System.out.println("### Book updated : " + book);
System.out.println("Execution succeeded");
}
}
Here is the persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="chapter06PU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<!--<jta-data-source>jdbc/__default</jta-data-source>-->
<jta-data-source>jdbc/chapter06DS</jta-data-source>
<class>org.beginningee6.book.chapter06.Book</class>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
</persistence>
And this is the pom.xml:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.beginningee6.book</groupId>
<artifactId>chapter06</artifactId>
<packaging>jar</packaging>
<version>2.0</version>
<name>Week5</name>
<parent>
<groupId>org.beginningee6.book</groupId>
<artifactId>chapters</artifactId>
<version>2.0</version>
</parent>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>${javax.persistence-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>${eclipselink-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>${glassfish-version}</version>
</dependency>
</dependencies>
<!--To avoid multiple modules with Maven, here is what you need to manually do (it's not nice, but it works)
1) Comment the following section (maven-jar-plugin), package the jar, and deploy to GlassFish
2) Uncomment the following section, package the jar and run the Main class with app client -->
<build>
<!-- <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${plugin-jar-version}</version>
<configuration>
<archive>
<manifest>
<mainClass>org.beginningee6.book.chapter06.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>-->
</build>
</project>
I'm getting this error:
Exception in thread "main" java.lang.NullPointerException
at this line:
book = bookEJB.updateBook(book);
Apparently Maven is giving this error:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project chapter06: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project chapter06: Command execution failed.
And after activating Maven's debugging option the last command line before the error is:
Executing command line: C:\Program Files (x86)\Java\jdk1.7.0_21\bin\java.exe -classpath C:\Users\Manuel_Laptop\Desktop\Week5\COIT20227LabSolWeek5\Week5\target\classes;C:\Users\Manuel_Laptop\.m2\repository\org\eclipse\persistence\javax.persistence\2.0.0\javax.persistence-2.0.0.jar;C:\Users\Manuel_Laptop\.m2\repository\org\eclipse\persistence\eclipselink\2.0.1\eclipselink-2.0.1.jar;C:\Users\Manuel_Laptop\.m2\repository\org\glassfish\extras\glassfish-embedded-all\3.0.1-b19\glassfish-embedded-all-3.0.1-b19.jar org.beginningee6.book.chapter06.Main
After going through some course tips and some forums I went and set my JAVA_HOME and M2_HOME to their respective directories but nothing worked. I even found a link to someone having an issue on the same chapter of the textbook (https://getsatisfaction.com/javaee6/topics/yet_another_chapter_6_ejb_problem) after seeing it referenced here in StackOverflow, but couldn't find anything there (didn't understand it to be honest)
It's not maven issue, you should set up ejb container in java SE enviroment to use EJB.
Try someithing like this
EJBContainer.createEJBContainer()
you can get complete example at http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/embeddedContainerDemo/EmbeddedContainerDemo.html

How to access the internal sun.security class from an OSGI bundle?

What options do I need to add to the maven build or the java runtime to access the internal sun.security classes? There is Java code from Akamai in an OSGI bundle needs access to internal sun.security classes. The Apache Felix console gives errors for the OSGI bundle:
sun.awt.image.codec -- Cannot be resolved
sun.io -- Cannot be resolved
sun.misc -- Cannot be resolved
sun.rmi.rmic -- Cannot be resolved
sun.security.action -- Cannot be resolved
sun.security.ec -- Cannot be resolved
sun.security.internal.interfaces -- Cannot be resolved
...
I looked at this article about using internal sun classes but it only refers to javac. My maven build starts like:
<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>
<artifactId>cdncache</artifactId>
<packaging>bundle</packaging>
<name>NCDN Cache</name>
<description>Classes and interfaces to expire resource from the Akamai CDN cache [build:${build.number}]\
</description>
<version>1.0-${build.number}</version>
<properties>
<!-- Skip tests, so maven execution is faster. -->
<maven.test.skip>true</maven.test.skip>
<file.encoding>utf-8</file.encoding>
</properties>
<build>
<plugins>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
com.nymag.akamai,
com.akamai.*,
...
</Export-Package>
<Private-Package>
org.apache.axis.*,
...
sun.security,
sun.security.ec,
</Private-Package>
<Bundle-Version>1.0</Bundle-Version>
<Bundle-Activator>com.nymag.akamai.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
...
I agree with stjohnroe that using VM-specific classes is usually bad, but sometimes you have to (for instance, as you are currently in a transition phase). If you want to do so, you can add
org.osgi.framework.system.packages.extra=sun.your.package.of.choice
to the framework properties. If you use the standard Felix launcher, you can edit conf/config.properties for that.
All of these are non public API classes and cannot be relied upon to be present in all jre distributions. I believe that they are all present sun distributions, but not in IBM distributions etc. Try running against a Sun distribution, but this looks like a case of building against undocumented features, a big no no.

Resources