Unable to create Model Class from Adempiere Class - java

I have this table C_InvoiceTaxDetail and I am trying to create a model class with the name of MInvoiceTaxDetail.
Now i have created the class , placed it in org.compiere.model and extended X_C_InvoiceTaxDetail class also.
But Still aftersave method works only if i place it in X_C_InvoiceTaxDetail and if i place it in MInvoiceTaxDetail gives the following error:
===========> GridTable.dataSave: Persistency Issue - C_INVOICETAX_DETAIL: org/compiere/model/MINVOICETAXDETAIL (wrong name: org/compiere/model/MInvoiceTaxDetail) [20]
java.lang.NoClassDefFoundError: org/compiere/model/MINVOICETAXDETAIL (wrong name: org/compiere/model/MInvoiceTaxDetail)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at org.compiere.model.MTable.getPOclass(MTable.java:360)
at org.compiere.model.MTable.getClass(MTable.java:300)
at org.compiere.model.MTable.getPO(MTable.java:537)
at org.compiere.model.GridTable.dataSavePO(GridTable.java:2049)
at org.compiere.model.GridTable.dataSave(GridTable.java:1467)
at org.compiere.model.GridTab.dataSave(GridTab.java:983)
at org.compiere.apps.APanel.cmd_save(APanel.java:2045)
at org.compiere.apps.APanel.actionPerformed(APanel.java:1708)
at org.compiere.apps.AppsAction.actionPerformed(AppsAction.java:286)

Make sure you run the Generate Model utility after adding the new Class. You can find full details in the link to the Adempiere wiki.

Related

Type [unknown] not present Caused by: java.lang.NoClassDefFoundError: org/junit/internal/runners/TestClassRunner

We are upgrading from junit-4.2 to junit-4.10. But with that, I am getting initializationError when launching firefox with below error stack. There is absolutely no reference to TestClassRunner (a class from junit-4.2) but not sure why we get it?
Type [unknown] not present
java.lang.TypeNotPresentException: Type [unknown] not present
at com.sun.proxy.$Proxy2.value(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
Caused by: java.lang.NoClassDefFoundError: org/junit/internal/runners/TestClassRunner
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3281)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3288)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3288)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3288)
at java.lang.Class.getAnnotation(Class.java:3229)
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
Right click your project in Package Explorer > click Properties.
Go to Java Build Path > Libraries tab.
Click on 'Add Library' button.
Select JUnit.
Click Next.
OR
Run mvn clean compile test-compile
Tell me if it doesnt work, but it worked for me.
Well the issue was little difference. There were two classes of same name WebDriverRunner. The one that was getting loaded first (based on classpath entries) was incorrect (rather deprecated) one which had some reference of TestClassRunner class. After putting the other jar (with right WebDriverRunner) before the previous one resolved the issue. Thanks all for your suggestions.
I also faced this issue but not due to any code changes. In my case I was running a simple Robolectric test on the Android SDK 29 (as it was set in the TestConfiguration). I tried restarting Android Studio, cleaning the build and Invalidating cache but in the end this issue was resolved by changing the SDK to 28 in the Edit Configuration. I also don't have any solid reason to why this worked.

Exception in java.lang.securityexception

I am getting this exception when i am trying to run a simple class from intellijIdea using spark
Exception in thread "Thread-0" java.lang.SecurityException: class "javax.servlet.SessionTrackingMode"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:952)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:666)
at java.lang.ClassLoader.defineClass(ClassLoader.java:794)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at spark.webserver.SparkServerFactory.create(SparkServerFactory.java:33)
at spark.Spark$1.run(Spark.java:303)
at java.lang.Thread.run(Thread.java:744)

Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute

I am attempting to scan my entity class for JPA #Column annotation using the code below;
for (Method m : User.class.getMethods())
{
if (m.isAnnotationPresent(javax.persistence.Column.class))
{
javax.persistence.Column column = m.getAnnotation(javax.persistence.Column.class);
System.out.println(column.name());
}
}
But I am getting below exception. I can confirm that I have javax-api jar loaded as part of my dependencies. Do anyone know what I am doing wrong?
Exception in thread "main" java.lang.ClassFormatError: Absent Code
attribute in method that is not native or abstract in class file
javax/persistence/CascadeType at
java.lang.ClassLoader.defineClass1(Native Method) at
java.lang.ClassLoader.defineClass(ClassLoader.java:791) at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at
java.net.URLClassLoader.access$100(URLClassLoader.java:71) at
java.net.URLClassLoader$1.run(URLClassLoader.java:361) at
java.net.URLClassLoader$1.run(URLClassLoader.java:355) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:354) at
java.lang.ClassLoader.loadClass(ClassLoader.java:423) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at
java.lang.ClassLoader.loadClass(ClassLoader.java:356) at
java.lang.Class.getDeclaredMethods0(Native Method) at
java.lang.Class.privateGetDeclaredMethods(Class.java:2442) at
java.lang.Class.getDeclaredMethods(Class.java:1808) at
sun.reflect.annotation.AnnotationType$1.run(AnnotationType.java:104)
at
sun.reflect.annotation.AnnotationType$1.run(AnnotationType.java:101)
at java.security.AccessController.doPrivileged(Native Method) at
sun.reflect.annotation.AnnotationType.(AnnotationType.java:100)
at
sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:84)
at
sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:221)
at
sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88)
at
sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
at java.lang.reflect.Method.declaredAnnotations(Method.java:699) at
java.lang.reflect.Method.getAnnotation(Method.java:685) at
java.lang.reflect.AccessibleObject.isAnnotationPresent(AccessibleObject.java:189)
You jar does not contain any method bodies, but only the APIs specification. This is not suitable to use for running or deploying along with your application. Extract the jar open the class in a decompiler you will get to know why it is not running. I am not sure from where you get javax-api jar but you surely need original full version of this jar.

Strange error when trying to send email

The following strange error is returned. I cannot understand where it's coming from as the Netbeans debugger is quite lacking.
Exception in thread "AWT-EventQueue-0" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/Address
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at modules.impl.EmailModule.process(EmailModule.java:41)
at agent.AgentDriver.callModules(AgentDriver.java:66)
at agent.AgentDriver.process(AgentDriver.java:33)
at agent.AgentUI.agentTextFieldActionPerformed(AgentUI.java:71)
Turns out this actually has to do with Java EE. This solution comes from here and here.
Java EE can screw up your classpath, so often it just needs to be removed and added again (or just removed). If your classpath has issues, you can occasionally get a java.lang.ClassFormatError, which is what happened here.

Active MQ - HelloWorld example exception

I'm trying to run the hello world example found here
I added activemq-all-5.5.1.jar to the libraries already
It builds successfully with the following warning
warning: [options] bootstrap class path not set in conjunction with -source 1.6
But it doesn't run, I get this exception
Exception in thread "Thread-0" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/jms/JMSException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at hw_testing.HW_testing$HelloWorldProducer.run(HW_testing.java:69)
at java.lang.Thread.run(Thread.java:722)
Exception in thread "Thread-1" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/jms/JMSException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at hw_testing.HW_testing$HelloWorldProducer.run(HW_testing.java:69)
at java.lang.Thread.run(Thread.java:722)
...
And the same exception for thread 3 and 4
Can anybody help me with that please?
This is a problem with dependencies (javax/jms/JMSException is in multiple jars), which occurs e.g. with javaee-api (5 or 6) - this jar lacks some method bodies for several classes. activemq-all-5.5.1.jar also contains javax.jms.JMSException but these classes are not identical. If javaee-api comes first in classpath, you will get the java.lang.ClassFormatError.
If you use maven, put javaee-api after activemq-all (or remove it). In general, remove unecessary dependencies.

Categories