Eclipse doesn't initialize JPA persistence - java

when I try to run a JPA project, I get the following error message :
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.<clinit>(EntityManagerFactoryProvider.java:55)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:92)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:188)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at dao.LayerDAO.<init>(LayerDAO.java:10)
at exec.Run.main(Run.java:9)
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.platform.server.NoServerPlatformDetector.checkPlatform(NoServerPlatformDetector.java:28)
at org.eclipse.persistence.platform.server.ServerPlatformUtils.detectServerPlatform(ServerPlatformUtils.java:58)
at org.eclipse.persistence.internal.jpa.IsolatedHashMap.<clinit>(IsolatedHashMap.java:48)
... 7 more
This project was running before, but I needed to reinstall Glassfish because of problems and now it's broken.
I tried to create a new project but I got the same error messages.
Do you have an idea of what could explain such a behavior ?
Thanx

Thanx to #Gimby who made me verified my EclipseLink version, I had to go into the project properties.
After a look in the BuildPath parameters, I tried to look at the "targeted runtime" I've chosen and found that none was selected.
Since I've checked it, everything goes better.
++

Related

ExtendedLogService does not appear to start

I am attempting to run an Eclipse 3.x application using Equinox in Neon as initiated in this question.
It appears that my remaining issue is that the LogReaderService appears to not be available, as the second line below in org.eclipse.core.internal.runtime.InternalPlatform.getLog() appears to throw a NullPointerException:
ExtendedLogReaderService logReader = logReaderTracker.getService();
logReader.addLogListener(result, result);
An implementation of this class can be found in org.eclipse.osgi, which I am launching the application with. For whatever reason, though, the service is null, which causes a number of plug-ins to throw exceptions when logging since many of the plug-ins rely on getting the Logging service from the Activator.
Since org.eclipse.osgi contains the implementation in its internals, I assumed that it would also register the service. That does not appear to be the case. I have also tried including log4j and org.apache.felix.log and neither appear to resolve this problem.
There must be something simple that is missing here to get the LogService to start? Here's the stack trace:
Caused by: java.lang.ClassNotFoundException: An error occurred while automatically activating bundle org.eclipse.core.resources (44).
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:116)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:529)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:325)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:36)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:419)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 20 more
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources.
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:795)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:724)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:932)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:309)
at org.eclipse.osgi.container.Module.doStart(Module.java:581)
at org.eclipse.osgi.container.Module.start(Module.java:449)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:470)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)
... 29 more
Caused by: java.lang.NullPointerException
at org.eclipse.core.internal.runtime.InternalPlatform.getLog(InternalPlatform.java:353)
at org.eclipse.core.runtime.Platform.getLog(Platform.java:976)
at org.eclipse.core.internal.utils.Policy.log(Policy.java:159)
at org.eclipse.core.internal.resources.Workspace.setCrashed(Workspace.java:2302)
at org.eclipse.core.internal.resources.SaveManager.restoreSnapshots(SaveManager.java:963)
at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:720)
at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1587)
at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2399)
at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2156)
at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:464)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:774)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:767)
... 36 more
I also added
Require-Capability: osgi.service;filter:="(objectClass=org.osgi.service.log.LogService)";effective:=active
To one of the dependent bnd files. This did not appear to solve the problem.
Edit: Because the OSGI Framework is set to org.eclipse.osgi in the bndrun file, is that preventing the logging from getting initialized? I have also tried adding org.apache.commons.logging as well as osgi.enroute.equinox.log.adapter and I am still getting NPEs when anything attempts to log. The org.eclipse.osgi bundle is already considered running by the time the RCP plugins get activated... yet there is no ExtendedLogReaderService. Do I need to find a way to install Felix as the Core Runtime in order to make org.eclipse.osgi able to get started by the framework in order for the ExtendedLogReaderServiceImpl to get registered?
I have found numerous examples of how to listen for the LogService... I'm not seeing how to start the ExtendedLogService.
Edit 2: I am able to suppress the LogService nulls issue by registering dummy ExtendedLogService implementations.
The problem has been resolved (finally), revisiting this now that our build system is in place the solution was likely that osgi.enterprise was not a Required-Bundle which also caused caused our OSGI-JDBC services to not work properly when testing the deployed target platforms.
Additionally, our primary RCP plug-in (containing the Application class, etc.) did not have a Bundle-ActivationPolicy: lazy clause in the *.bnd files used to generate the MANIFEST.MF file which lead to some other problems.
Just in case anyone else runs into such problems.

ClasscastException on update application

I have an openjpa application running in a weblogic 12.1.2 container.
When i first install the application everything works fine. If i update the ear file (or redeploy) i get the following error:
- Could not log the error: EJB Exception: found this error: EJB Exception: : <openjpa-1.1.1-SNAPSHOT-r422266:1445923 nonfatal general error> org.apache.openj
pa.persistence.PersistenceException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:196)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:199)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:152)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
at weblogic.persistence.TransactionalEntityManagerProxyImpl.newPersistenceContext(TransactionalEntityManagerProxyImpl.java:71)
at weblogic.persistence.BasePersistenceContextProxyImpl.getPersistenceContext(BasePersistenceContextProxyImpl.java:175)
at weblogic.persistence.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:106)
at weblogic.persistence.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:82)
at weblogic.persistence.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:92)
at com.sun.proxy.$Proxy235.createNativeQuery(Unknown Source)
(...)
Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
at org.apache.openjpa.lib.xml.XMLFactory.getDOMParser(XMLFactory.java:107)
at org.apache.openjpa.jdbc.sql.SQLErrorCodeReader.parse(SQLErrorCodeReader.java:108)
at org.apache.openjpa.jdbc.sql.DBDictionary.endConfiguration(DBDictionary.java:4096)
at org.apache.openjpa.jdbc.sql.OracleDictionary.endConfiguration(OracleDictionary.java:170)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:505)
This is only fixed by restarting the cluster nodes. This doesn't happen in Weblogic 10.3.
I've been looking around and i stumbled across several possible solutions to no avail. One of the possible issues can be seen here: Stackoverflow Question
From here I started fiddling with the ear and i now have the xercesImpl lib ( the same that exists on the server) inside my APP-INF/lib this. Without this the application won't even install.
I've tried adding the following line to my weblogic-application.xml:
<wls:package-name>org.apache.xerces.*</wls:package-name>
And this had no effect.
Also looked into the possibility that my EntityManager was being left open upon undeploy, but i have no reason to believe this is the case. All my EntityManager are container managed and injected using the #EJB annotation.
Anyone have any ideas on this?

Unable to start server due following issues: Launch process failed with exit code 1

For 3 days now, I have been trying to install glassfish 4.1 on eclipse Luna version 4.4.1. I first installed the plugin from eclipse marketplace then added it in my runtime using jdk 8. I also made jdk my default since eclipse default uses jre. I have to point out that I have been been using glassfish on netbeans and tomcat on eclipse but I decided to play around with glassfish on eclipse. Every information I got on the internet didn't fix my issue.
Below is the error I got in the console. Right now, this is driving me nuts so I have decided to come to you for direction.
Thanks
Launching GlassFish on Felix platform
ERROR: Unable to create cache directory: C:\Program Files\glassfish-4.1\glassfish\domains\domain1\osgi-cache\felix
ERROR: Error creating bundle cache. (java.lang.RuntimeException: Unable to create cache directory.)
java.lang.RuntimeException: Unable to create cache directory.
at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:131)
at org.apache.felix.framework.Felix.init(Felix.java:640)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:88)
Exception in thread "Thread-1" java.lang.RuntimeException: org.osgi.framework.BundleException: Error creating bundle cache.
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:90)
Caused by: org.osgi.framework.BundleException: Error creating bundle cache.
at org.apache.felix.framework.Felix.init(Felix.java:645)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:88)
Caused by: java.lang.RuntimeException: Unable to create cache directory.
at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:131)
at org.apache.felix.framework.Felix.init(Felix.java:640)
... 1 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
Caused by: org.glassfish.embeddable.GlassFishException: java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.build(OSGiGlassFishRuntimeBuilder.java:170)
at org.glassfish.embeddable.GlassFishRuntime._bootstrap(GlassFishRuntime.java:157)
at org.glassfish.embeddable.GlassFishRuntime.bootstrap(GlassFishRuntime.java:110)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:112)
... 6 more
Caused by: java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.newFramework(OSGiGlassFishRuntimeBuilder.java:241)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.build(OSGiGlassFishRuntimeBuilder.java:135)
... 9 more
Error stopping framework: java.lang.NullPointerException
java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher$1.run(GlassFishMain.java:203)
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=192m; support was removed in 8.0
Run Eclipse or any other IDE you use in Administrator mode.
Works for me.
I think your comment deserves to be posted as the main answer but I have been trying to mark your comment as answer but I wash't able to. So I decided to post post your comment here and then back it up with my own experience.
Answer by unwichtich:
I guess this is a similar problem. The cause may be that you have installed Glassfish in c:\Program Files. You can try to move your Glassfish installation to a directory where your normal user account has full access rights but you then have to change the path to the Glassfish installation in Eclipse.
My own experience:
Turns out that all the problems I had with the glassfish server (including exit code 1 error) was because glassfish could not handle folder names with spaces in it. So I moved the glassfish-4.1 folder from C:\Program File\glassfish-4.1.. path to C:\ glassfish-4.1.. It wiped all my tears away. This is really important in eclipse and netbeans IDEs (if you are installing the netbeans that does not come with a glassfish bundled zip).
I had the same problem and fixed it by installing Glassfish under C:\ instead of C:\Program Files. Try that.
use JDk 7 instead of JDK 8 am also faced the same issue i just changed to jdk7 its working now.

Generic error [50000-175] caused by NullPointerException

I am using H2 database in client-server mode. Server is running with version 1.3.175 and client with 1.3.168.
Everything seems working fine, but I get an exception executing some queries:
org.h2.jdbc.JdbcSQLException: General error: "java.lang.NullPointerException" [50000-175]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
at org.h2.message.DbException.get(DbException.java:161)
at org.h2.message.DbException.convert(DbException.java:284)
at org.h2.server.TcpServerThread.sendError(TcpServerThread.java:218)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:158)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.h2.expression.Function.getCost(Function.java:2391)
at org.h2.expression.CompareLike.getCost(CompareLike.java:417)
at org.h2.expression.ConditionAndOr.optimize(ConditionAndOr.java:133)
at org.h2.command.dml.Select.prepare(Select.java:813)
at org.h2.command.Parser.prepareCommand(Parser.java:240)
at org.h2.engine.Session.prepareLocal(Session.java:436)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:260)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:156)
... 1 more
at org.h2.engine.SessionRemote.done(SessionRemote.java:567)
at org.h2.command.CommandRemote.prepare(CommandRemote.java:67)
at org.h2.command.CommandRemote.<init>(CommandRemote.java:46)
at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:439)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1109)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:74)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:264)
Thanks for help.
This is a bug in this version of the database engine, which was fixed in revision 5437 of the trunk.
You can either:
go back to the previous version (1.3.174) which should not have this bug,
use the latest nightly build where it should be fixed,
download the latest source code and built the database yourself, or
wait for the next version of H2.

What would cause java.lang.ClassNotFoundException: [B?

I'm rewriting a client/server application using Akka 2.2.0, Java 1.7.0_25 and Eclipse Juno.
I had a sample client and server working with Akka 2.0.2.
I updated to the old stable release 2.1.4 and got everything working once again.
I've just moved to the latest stable release 2.2.0.
I created a new package to add some new functionality, leaving the existing code untouched.
Something changed and now I can't launch my test cases.
Here is the stacktrace I see when I try to create an ActorSystem:
Exception in thread "main" java.lang.ClassNotFoundException: [B
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at akka.actor.ReflectiveDynamicAccess.getClassFor(DynamicAccess.scala:94)
at akka.serialization.Serialization$$anonfun$4.apply(Serialization.scala:154)
at akka.serialization.Serialization$$anonfun$4.apply(Serialization.scala:153)
at scala.collection.TraversableLike$WithFilter$$anonfun$map$2.apply(TraversableLike.scala:697)
at scala.collection.immutable.HashMap$HashMap1.foreach(HashMap.scala:178)
at scala.collection.immutable.HashMap$HashTrieMap.foreach(HashMap.scala:347)
at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:696)
at akka.serialization.Serialization.<init>(Serialization.scala:153)
at akka.serialization.SerializationExtension$.createExtension(SerializationExtension.scala:15)
at akka.serialization.SerializationExtension$.createExtension(SerializationExtension.scala:12)
at akka.actor.ActorSystemImpl.registerExtension(ActorSystem.scala:644)
at akka.actor.ExtensionId$class.apply(Extension.scala:34)
at akka.serialization.SerializationExtension$.apply(SerializationExtension.scala:12)
at akka.remote.RemoteActorRefProvider.init(RemoteActorRefProvider.scala:77)
at akka.actor.ActorSystemImpl._start(ActorSystem.scala:568)
at akka.actor.ActorSystemImpl.start(ActorSystem.scala:575)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:103)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:98)
at akka.actor.ActorSystem$.create(ActorSystem.scala:64)
at akka.actor.ActorSystem.create(ActorSystem.scala)
Its complaining that it can't class load a byte array via the method descriptor style string "[B".
#som-snytt pointed out two bug reports that exactly describe the error I'm seeing.
#paul-vargas called out -Dsun.lang.ClassLoader.allowArraySyntax=true which re-enables the old loadClass behavior.
The allowArraySyntax flag does make the ClassNotFoundException go away but other errors popped up. The errors lead me to believe that something has gone wrong with my Eclipse/m2e/Scala-ide/Akka setup.
I imported the project into Netbeans 7.3 and did a clean and build and it worked on the first try. I didn't even need to set allowArraySyntax.
May you need add the argument to VM:
-Dsun.lang.ClassLoader.allowArraySyntax=true
This won't be news to everyone:
http://bugs.sun.com/view_bug.do?bug_id=6500212
http://bugs.sun.com/view_bug.do?bug_id=6434149
I only looked that up due to #paul-vargas.
I observe that in trunk, ReflectiveDynamicAccess uses Class.forName as the bug report says is recommended. See the code on master.
Possibly, you'll want to upgrade your Akka together with your Java version.
Or, perhaps your production runtime is stuck on 1.5 but you develop on 1.7.
Old akka and scala jars were on the classpath along with the updated versions. Not sure why it caused the above exception but the problem became obvious once Paul pointed out the allowArraySyntax flag.

Categories