Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Exception thrown when calling eClass
Exception thrown when calling eClass [message #419612] Wed, 28 May 2008 18:02 Go to next message
Oliver Wong is currently offline Oliver WongFriend
Messages: 47
Registered: July 2009
Member
I'm trying to invoke the "eClass()" method on an EObject, but every time I
do so, I get a ClassNotFoundException. Here's my code:

<code>
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;

import com.castortech.iris.astm.AstmFactory;
import com.castortech.iris.astm.CompilationUnit;

public class TestClassLoadingError implements IApplication {

@Override
public Object start(IApplicationContext context) throws Exception {
try {

CompilationUnit cu = AstmFactory.eINSTANCE.createCompilationUnit();
System.out.println(cu.eClass());
}
catch (Throwable t) {
t.printStackTrace();
if (t instanceof Exception) {
throw (Exception)t;
}
if (t instanceof Error) {
throw (Error)t;
}
}
return IApplication.EXIT_OK;
}

@Override
public void stop() {
// Does nothing.
}

}
</code>

And here's the exception:

<exception>
java.lang.NoClassDefFoundError: com/castortech/iris/astm/astmPackage
(wrong name: com/castortech/iris/astm/AstmPackage)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.def ineClass(DefaultClassLoader.java:161)
at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineC lass(ClasspathManager.java:501)
at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findCla ssImpl(ClasspathManager.java:471)
at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClassImpl(ClasspathManager.java:430)
at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:413)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:189)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:340)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl assInternal(BundleLoader.java:408)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:369)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:357)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:289)
at
org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:227)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1269)
at
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescript or.getEPackage(RegistryReader.java:208)
at
org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage( EPackageRegistryImpl.java:114)
at
com.castortech.iris.astm.impl.AstmPackageImpl.init(AstmPacka geImpl.java:2636)
at com.castortech.iris.astm.AstmPackage.<clinit>(AstmPackage.java:63)
at
com.castortech.iris.astm.AstmPackage$Literals.<clinit>(AstmPackage.java:40440)
at
com.castortech.iris.astm.impl.CompilationUnitImpl.eStaticCla ss(CompilationUnitImpl.java:90)
at org.eclipse.emf.ecore.impl.EObjectImpl.eClass(EObjectImpl.ja va:224)
at
com.castortech.vbinterpreter.TestClassLoadingError.start(Tes tClassLoadingError.java:22)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:169)
at
org.eclipse.equinox.internal.app.AnyThreadAppLauncher.run(An yThreadAppLauncher.java:26)
at java.lang.Thread.run(Thread.java:619)

</exception>

The .ecore file, and the javacode generated via EMF, is in a separate
project, but I've specified that this project (the one where the above
code appears) does have dependencies on the project containing the EMF
generated files. The code compiles correctly, which indicates that the
"CompilationUnit" and "AstmFactory" classes do indeed exist. The message
associated with the exception seems to imply that somewhere along the way,
the name of the class is getting changed (from upper case "AstmPackage" to
lowercase "astmPackage"), but browsing through the lines mentioned in the
stack trace, I couldn't find an exact point of where this happens.

The version of EMF I'm using is 2.3.0.v200706262000
Re: Exception thrown when calling eClass [message #419613 is a reply to message #419612] Wed, 28 May 2008 18:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Oliver,

Comments below.


Oliver Wong wrote:
> I'm trying to invoke the "eClass()" method on an EObject, but every
> time I do so, I get a ClassNotFoundException. Here's my code:
>
> <code>
> import org.eclipse.equinox.app.IApplication;
> import org.eclipse.equinox.app.IApplicationContext;
>
> import com.castortech.iris.astm.AstmFactory;
> import com.castortech.iris.astm.CompilationUnit;
>
> public class TestClassLoadingError implements IApplication {
>
> @Override
> public Object start(IApplicationContext context) throws Exception {
> try {
>
> CompilationUnit cu =
> AstmFactory.eINSTANCE.createCompilationUnit();
> System.out.println(cu.eClass());
> }
> catch (Throwable t) {
> t.printStackTrace();
> if (t instanceof Exception) {
> throw (Exception)t;
> }
> if (t instanceof Error) {
> throw (Error)t;
> }
> }
> return IApplication.EXIT_OK;
> }
>
> @Override
> public void stop() {
> // Does nothing.
> }
>
> }
> </code>
>
> And here's the exception:
>
> <exception>
> java.lang.NoClassDefFoundError: com/castortech/iris/astm/astmPackage
> (wrong name: com/castortech/iris/astm/AstmPackage)
Sounds like you have a file case sensitivity issue.
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.def ineClass(DefaultClassLoader.java:161)
>
> at
> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineC lass(ClasspathManager.java:501)
>
> at
> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findCla ssImpl(ClasspathManager.java:471)
>
> at
> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClassImpl(ClasspathManager.java:430)
>
> at
> org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:413)
>
> at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:189)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:340)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl assInternal(BundleLoader.java:408)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:369)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:357)
>
> at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:83)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:289)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:227)
>
> at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1269)
>
> at
> org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescript or.getEPackage(RegistryReader.java:208)
>
> at
> org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage( EPackageRegistryImpl.java:114)
>
> at
> com.castortech.iris.astm.impl.AstmPackageImpl.init(AstmPacka geImpl.java:2636)
>
> at com.castortech.iris.astm.AstmPackage.<clinit>(AstmPackage.java:63)
> at
> com.castortech.iris.astm.AstmPackage$Literals.<clinit>(AstmPackage.java:40440)
>
> at
> com.castortech.iris.astm.impl.CompilationUnitImpl.eStaticCla ss(CompilationUnitImpl.java:90)
>
> at
> org.eclipse.emf.ecore.impl.EObjectImpl.eClass(EObjectImpl.ja va:224)
> at
> com.castortech.vbinterpreter.TestClassLoadingError.start(Tes tClassLoadingError.java:22)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:169)
>
> at
> org.eclipse.equinox.internal.app.AnyThreadAppLauncher.run(An yThreadAppLauncher.java:26)
>
> at java.lang.Thread.run(Thread.java:619)
>
> </exception>
>
> The .ecore file, and the javacode generated via EMF, is in a separate
> project, but I've specified that this project (the one where the above
> code appears) does have dependencies on the project containing the EMF
> generated files. The code compiles correctly, which indicates that the
> "CompilationUnit" and "AstmFactory" classes do indeed exist. The
> message associated with the exception seems to imply that somewhere
> along the way, the name of the class is getting changed (from upper
> case "AstmPackage" to lowercase "astmPackage"), but browsing through
> the lines mentioned in the stack trace, I couldn't find an exact point
> of where this happens.
Did you maybe generate a plugin.xml with a bad value before fixing it?
The plugin.xml doesn't regenerate so you'd need to delete it and
regenerate it or correct it manually.
>
> The version of EMF I'm using is 2.3.0.v200706262000
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Exception thrown when calling eClass [message #419628 is a reply to message #419613] Thu, 29 May 2008 14:36 Go to previous messageGo to next message
Oliver Wong is currently offline Oliver WongFriend
Messages: 47
Registered: July 2009
Member
Ed Merks wrote:

> Did you maybe generate a plugin.xml with a bad value before fixing it?
> The plugin.xml doesn't regenerate so you'd need to delete it and
> regenerate it or correct it manually.

That fixed it. Thanks again, Ed, you've always been extremely helpful.
Re: Exception thrown when calling eClass [message #422476 is a reply to message #419613] Sun, 07 September 2008 09:17 Go to previous message
Eclipse UserFriend
Originally posted by: eyalm_nm.netvision.net.il

Hi,
Where can I find this ASTM lib for java?
I can not find the castortech.com on the web.
Thanks,
Eyal.
Previous Topic:[CDO] intermittent exception ...TransactionException
Next Topic:CreateChildCommand and the EStructuralFeature
Goto Forum:
  


Current Time: Sat Apr 27 00:28:15 GMT 2024

Powered by FUDForum. Page generated in 0.03412 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top