I'm working on Drools on eclipse, the code was working properly and suddenly I get these errors. I tried reinstalling the drools plugins, and uninstall Eclipse, I updated JRE, and the JDK, and nothing works
DRL file
import com.binod.DroolsDemo.AssessmentLevel
rule "Level A1"
when
studentObject: AssessmentLevel(assessment=="Null")
then
studentObject.setLevel("A1");
System.out.println("Student Level is A1");
end
rule "Level A2"
when
studentObject: AssessmentLevel(assessment=="[1-10]")
then
studentObject.setLevel("A2");
System.out.println("Student Level is A2");
end
rule "Level B1"
when
studentObject: AssessmentLevel(assessment=="[1-10] AND [11-15]")
then
studentObject.setLevel("B1");
System.out.println("Student Level is B1");
end
AssemsentLevel.java
package com.binod.DroolsDemo;
public class AssessmentLevel {
private String assessment;
private String level;
private String personalizedexercises;
public String getAssessment() {
return assessment;
}
public void setAssessment(String assessment) {
this.assessment = assessment;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getPersonalizedexercises() {
return personalizedexercises;
}
public void setPersonalizedexercises(String personalizedexercises) {
this.personalizedexercises = personalizedexercises;
}
}
Test.java
package com.binod.DroolsDemo;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import org.drools.compiler.compiler.DroolsParserException;
import org.drools.compiler.compiler.PackageBuilder;
import org.drools.core.RuleBase;
import org.drools.core.RuleBaseFactory;
import org.drools.core.WorkingMemory;
public class DemoTest {
public static void main(String[] args) throws DroolsParserException, IOException {
DemoTest client = new DemoTest();
client.execteRule();
}
public void execteRule() throws DroolsParserException, IOException{
PackageBuilder builder = new PackageBuilder();
String ruleFile = "/rules.drl";
InputStream resourceAsStream = getClass().getResourceAsStream(ruleFile);
Reader ruleReader = new InputStreamReader(resourceAsStream);
builder.addPackageFromDrl(ruleReader);
org.drools.core.rule.Package rulePackage = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(rulePackage);
WorkingMemory workingMemory = ruleBase.newStatefulSession();
AssessmentLevel assessemntLevel = new AssessmentLevel();
assessemntLevel.setAssessment("[1-10] AND [11-15] AND [16-20] AND [21-25] AND [26-30] AND [31-35]");
workingMemory.insert(assessemntLevel);
workingMemory.fireAllRules();
System.out.println("\n Assessment Score is "+assessemntLevel.getAssessment());
/*+" \n Student is in Level "
+assessemntLevel.getLevel()+" \n And the excercises include "
+assessemntLevel.getPersonalizedexercises()*/
}
}
Error report
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.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.drools.core.rule.builder.dialect.asm.ClassGenerator (file:/C:/Users/bojaj/.m2/repository/org/drools/drools-core/6.0.1.Final/drools-core-6.0.1.Final.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of org.drools.core.rule.builder.dialect.asm.ClassGenerator
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
Exception in thread "main" java.lang.RuntimeException: wrong class format
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:279)
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:219)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:113)
at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getType(LookupEnvironment.java:1160)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getResolvedType(LookupEnvironment.java:1091)
at org.eclipse.jdt.internal.compiler.lookup.Scope.getJavaLangString(Scope.java:2288)
at org.eclipse.jdt.internal.compiler.ast.StringLiteral.literalType(StringLiteral.java:72)
at org.eclipse.jdt.internal.compiler.ast.Literal.resolveType(Literal.java:45)
at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:374)
at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:947)
at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:456)
at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:252)
at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:415)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1148)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1258)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:539)
at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:763)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:468)
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:405)
at org.drools.compiler.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:49)
at org.drools.compiler.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:405)
at org.drools.compiler.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:46)
at org.drools.compiler.compiler.PackageRegistry.compileAll(PackageRegistry.java:110)
at org.drools.compiler.compiler.PackageBuilder.compileAll(PackageBuilder.java:1334)
at org.drools.compiler.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:975)
at org.drools.compiler.compiler.PackageBuilder.addPackage(PackageBuilder.java:964)
at org.drools.compiler.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:455)
at org.drools.compiler.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:431)
at com.binod.DroolsDemo.DemoTest.execteRule(DemoTest.java:29)
at com.binod.DroolsDemo.DemoTest.main(DemoTest.java:20)
Caused by: org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:372)
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler$2.createNameEnvironmentAnswer(EclipseJavaCompiler.java:303)
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:274)
... 31 more
Please help
You are using an older release of Drools. Maybe you are compiling your Java model classes with a more recent JVM version than release 6 of Drools can handle. I use Java 11 and Drools 7.39.0.Final and it works as expected.
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>7.39.0.Final</version>
</dependency>
Related
I think I may be the only one experiencing this issue.
I, today, updated my eclipse install to version 2020-03 (4.15.0). I am also attempting to write a very simple JUnit 5 test for a new method I'm working on.
When I run my test, right now just a basic stub, I get the following error:
java.lang.SecurityException: class "org.junit.platform.commons.PreconditionViolationException"'s signer information does not match signer information of other classes in the same package
at java.base/java.lang.ClassLoader.checkCerts(ClassLoader.java:1150)
at java.base/java.lang.ClassLoader.preDefineClass(ClassLoader.java:905)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1014)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.createUnfilteredTest(JUnit5TestLoader.java:75)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.createTest(JUnit5TestLoader.java:66)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.loadTests(JUnit5TestLoader.java:53)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
I also see the following dialog
My run Configuration is:
I've tried all major junit-jupiter (aggregator) releases back to 5.5.0 all resulting in the same issue.
I've tried this solution. However, that question deals with a class not found issue. I also tried that same solution using using junit-platform-commons version 1.6.1. no change.
However, I can run maven configuration with -Dtest=DeaFileListTest test the the tests run.
My test case is simple, I instantiate an object that has the method I want to test and then my test.
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.not;
import java.io.IOException;
import java.util.List;
import javax.ws.rs.core.Response;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.mfgweb.FileRepo;
class DeaFileListTest {
private static FileRepo filerepo;
private static Response response;
#BeforeAll
static void setUpBeforeClass() throws Exception {
filerepo = new FileRepo();
response = filerepo.getDeaFiles();
}
#AfterAll
static void tearDownAfterClass() throws Exception {
response = null;
filerepo = null;
}
#Test
public void deaFileListIsNotEmptyTest() throws IOException {
#SuppressWarnings ( "unchecked" )
List< String > files = ( List< String > )response.getEntity();
assertThat( files, not( empty() ) );
}
}
So I am curious why I'm receiving the Security Exception when I run the test in eclipse, yet Maven seems to execute them fine.
I did set up the hadoop Ubuntu OS, followed all the necessary steps, 1.created the hdfs file system 2.Moved the text files to input directory 3.having privilege to access all the directories. but when run the simple word count example, i got:
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
public class wordcount {
public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
context.write(word, one);
}
}
}
public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
public void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
context.write(key, new IntWritable(sum));
}
}
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
conf.addResource(new Path("/HADOOP_HOME/conf/core-site.xml"));
conf.addResource(new Path("/HADOOP_HOME/conf/hdfs-site.xml"));
Job job = new Job(conf, "wordcount");
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
job.setJarByClass(wordcount.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
// FileInputFormat.addInputPath(job, new Path(args[0]));
// FileOutputFormat.setOutputPath(job, new Path(args[1]));
FileInputFormat.setInputPaths(job, new Path("/user/gabriele/input"));
FileOutputFormat.setOutputPath(job, new Path("/user/gabriele/output"));
job.waitForCompletion(true);
}
}
but, input path is valid (checked also from command line) and even can able view the files in that path from eclipse itself, so plz assist were i am wrong.
There was a solution that say to add the following 2 lines:
config.addResource(new Path("/HADOOP_HOME/conf/core-site.xml"));
config.addResource(new Path("/HADOOP_HOME/conf/hdfs-site.xml"));
But still does not work.
Here the errors: Run as -> run on hadoop
13/11/08 08:39:11 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
13/11/08 08:39:12 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
13/11/08 08:39:12 WARN mapred.JobClient: No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
13/11/08 08:39:12 INFO mapred.JobClient: Cleaning up the staging area file:/tmp/hadoop-gabriele/mapred/staging/gabriele481581440/.staging/job_local481581440_0001
13/11/08 08:39:12 ERROR security.UserGroupInformation: PriviledgedActionException as:gabriele cause:org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: file:/user/gabriele/input
Exception in thread "main" org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: file:/user/gabriele/input
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(FileInputFormat.java:235)
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:252)
at org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:1054)
at org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:1071)
at org.apache.hadoop.mapred.JobClient.access$700(JobClient.java:179)
at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:983)
at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:936)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)
at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:936)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:550)
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:580)
at wordcount.main(wordcount.java:74)
THanks
Unless your Hadoop installation really is rooted at /HADOOP_HOME, i suggest you change the following lines such that HADOOP_HOME is replaced to where your Hadoop is actually installed (/usr/lib/hadoop, /opt/hadoop or wherever you installed it):
conf.addResource(new Path("/usr/lib/hadoop/conf/core-site.xml"));
conf.addResource(new Path("/usr/lib/hadoop/conf/hdfs-site.xml"));
Or in Eclipse, add the /usr/lib/hadoop/conf folder (or wherever you have installed hadoop) to the Build classpath).
I have an issue with Spring not loading beans correctly when run from a script in a BIRT Scripted Data Source, but running OK on its own.
Here's a minimal test case:
The spring bean:
package test;
import org.springframework.stereotype.Component;
#Component
public class TestComponent { }
The context provider:
package test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringContextHolder {
private static ApplicationContext ac;
public static ApplicationContext getApplicationContext() {
if( ac == null ) {
ac = new ClassPathXmlApplicationContext("classpath:beans.xml");
}
return ac;
}
}
beans.xml:
<beans .......>
<context:component-scan base-package="test"></context:component-scan>
<context:annotation-config />
</beans>
And finally the test program which is a simple Eclipse java project having all spring and related jars and the test.jar from above in its build path:
public class cltest {
public static void main(String[] args ) throws BeansException {
System.out.println(test.SpringContextHolder.getApplicationContext().getBean("testComponent"));
}
}
This program runs fine and delivers the bean. But when I run the same jars in BIRT designer (4.3.0) by setting them in the Report classpath preferences, I get an exception:
A BIRT exception occurred. See next exception for more information.
Wrapped org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/xxx/.m2/repository/test/test/0.0.1-SNAPSHOT/test-0.0.1-SNAPSHOT.jar!/test/SpringContextHolder.class]; nested exception is java.lang.ArrayIndexOutOfBoundsException: 6
The script source is simply:
importPackage(Packages.test);
ts = SpringContextHolder.getApplicationContext().getBean("testComponent");
The exception results from org.springframework.asm.ClassReader where a readShort violates some array boundaries.
Spring version is 3.2.3 RELEASE, Oracle Java 7u25, BIRT Designer 4.3.0.
Can anyone explain what the difference between the two running scenarios is? Probably some class loader issues when the jars are loaded by the eclipse runtime?
I have a simple application. Just one EJB with #startup and #singleton annotation. It programmitcally creates a timer and has a #timeout method. The code is mostly from the java ee 6 tutorial on the oracle website. Here is the code:
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerService;
#Singleton
#Startup
public class TimerSessionBean {
#Resource
TimerService timerService;
long duration = 6000;
private Logger logger = Logger.getLogger(
"simpletimer.service.TimerSessionBean");
#PostConstruct
public void setTimer() {
logger.info("Setting a programmatic timeout for "
+ duration + " milliseconds from now.");
Timer timer = timerService.createTimer(duration,
"Created new programmatic timer");
}
#Timeout
public void programmaticTimeout(Timer timer) {
logger.info("Programmatic timeout occurred.");
}
}
Here is the error in the serverlog file:
SEVERE: Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
I restarted the server a couple of times and the error doesn't occur anymore. Still not sure what was wrong. I have a follow up question. I changes #Resource to #inject and it fails with javax.ejb.CreateException: Initialization failed for Singleton TimerSessionBean. What is the difference? I thought #inject should be used where possible? Thank you all.
I'm using GlassFish Tools Bundle for Eclipse.
I need to create a bean and a client that tests it. The bean (and its interface) are the following.
package mykPK;
import java.math.BigDecimal;
import javax.ejb.*;
#Stateless
public class ConverterBean implements Converter {
private BigDecimal yenRate = new BigDecimal("115.3100");
private BigDecimal euroRate = new BigDecimal("0.0071");
public BigDecimal dollarToYen(BigDecimal dollars) {
BigDecimal result = dollars.multiply(yenRate);
return result.setScale(2, BigDecimal.ROUND_UP);
}
public BigDecimal yenToEuro(BigDecimal yen) {
BigDecimal result = yen.multiply(euroRate);
return result.setScale(2, BigDecimal.ROUND_UP);
}
}
The interface:
package mykPK;
import java.math.BigDecimal;
import javax.ejb.Remote;
#Remote
public interface Converter {
public BigDecimal dollarToYen(BigDecimal dollars);
public BigDecimal yenToEuro(BigDecimal yen);
}
I create them correctly in an EJB project and run them "as a server". All seems to start correctly.
Now I want to create a client.
I tried to put the client inside the same project, creating a different project ("Application Client Project") or even creating a more general "E application project" with two subproject. The result is the same.
Now, the client code is the following
import java.math.BigDecimal;
import javax.ejb.EJB;
import mykPK.Converter; /*of course to to that, i reference in the client project the
EJB project*/
public class ConverterClient {
#EJB private static Converter converter;
public ConverterClient(String[] args) {
}
public static void main(String[] args) {
ConverterClient client = new ConverterClient(args);
client.doConversion();
}
public void doConversion() {
try {
BigDecimal param = new BigDecimal("100.00");
BigDecimal yenAmount = converter.dollarToYen(param);
System.out.println("$" + param + " is " + yenAmount
+ " Yen.");
BigDecimal euroAmount = converter.yenToEuro(yenAmount);
System.out.println(yenAmount + " Yen is " + euroAmount
+ " Euro.");
System.exit(0);
} catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}
When I run this file, i always get the same:
Caught an unexpected exception!
java.lang.NullPointerException
at ConverterClient.doConversion(ConverterClient.java:17)
at ConverterClient.main(ConverterClient.java:12)
I suppose this is beacause my client is not in the same container of the bean, and it is not "deployed" (I simply run the file). But when I tried the more general "Enterprise Application Project" the results were the same)
So, where to put the client and give him the access (with #EJB) to the Bean??
You're trying to inject into a non-managed object. You need to grab the initial context and look it up.
Pretty much the same thing as here:
cannot find my bean using the InitialContext.lookup() method
The stack trace suggests that you've directly launched the main method. In order to use injection in the main class, you must use the application client container.
A good example of this working can be found here Packaging your client for use with glassfish's application client container (via the "appclient" command) is shown, as is packaging it as a standalone Java app.