NetBeans Restfull testing error - rest

Hi
I am trying to test a RESTful Application, but keep getting the following error.
I am using "NetBeans 6.9.1" and "GlassFish Server 3" and I have added all the JAR files.
restlib_gfv3ee6, EclipseLink-GlassFish-v3,EclipseLink(JPA2.0), mysql-connector-java :
GET RequestFailed RequestFailed --> Status: ()
Response: {
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: null
Error Code: 0
root cause
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: null
Error Code: 0
root cause
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: null
Error Code: 0
root cause
java.sql.SQLException: Error in allocating a connection. Cause: null
please let me know what is the problem ???

Check whether the connection to mysql is defined in the services window or not. It usually looks like 'jdbc:mysql://localhost:3306/mydb[root on Default schema]"

Related

Error creating rule engine Drools

Exception in thread "main" org.swrlapi.exceptions.SWRLRuleEngineException: Error creating rule engine Drools. Exception: java.lang.NoSuchMethodError. Message: org.semanticweb.owlapi.model.OWLOntologyManager.getIRIMappers()Lorg/semanticweb/owlapi/util/PriorityCollection;
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSWRLRuleEngine(DefaultSWRLRuleAndQueryEngineFactory.java:71)
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSWRLRuleEngine(DefaultSWRLRuleAndQueryEngineFactory.java:41)
at org.swrlapi.factory.SWRLAPIFactory.createSWRLRuleEngine(SWRLAPIFactory.java:38)
at swrlagaintest.plzwork.runWithOWLAPI(plzwork.java:30)
at swrlagaintest.plzwork.main(plzwork.java:21)
Caused by: java.lang.NoSuchMethodError: org.semanticweb.owlapi.model.OWLOntologyManager.getIRIMappers()Lorg/semanticweb/owlapi/util/PriorityCollection;
at org.swrlapi.factory.DefaultSWRLAPIOWLOntology.addSWRLAPIOntologies(DefaultSWRLAPIOWLOntology.java:1469)
at org.swrlapi.factory.DefaultSWRLAPIOWLOntology.<init>(DefaultSWRLAPIOWLOntology.java:161)
at org.swrlapi.factory.SWRLAPIInternalFactory.createSWRLAPIOntology(SWRLAPIInternalFactory.java:266)
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSWRLRuleEngine(DefaultSWRLRuleAndQueryEngineFactory.java:53)
... 4 more
am trying to create a SWRL rule engine using the SWRLAPI just for testing but i got this error.

Weaving with EclipseLink fails with NPE

Performing weaving (static or dynamic) results in the following error:
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.1.v20171221-bd47e8f): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [MyUnit] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:231)
... 20 more
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.sessions.Project.hasSQLResultSetMapping(Project.java:1040)
at org.eclipse.persistence.internal.jpa.metadata.queries.NamedNativeQueryMetadata.hasResultSetMapping(NamedNativeQueryMetadata.java:141)
at org.eclipse.persistence.internal.jpa.metadata.queries.NamedNativeQueryMetadata.process(NamedNativeQueryMetadata.java:172)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processQueries(MetadataProject.java:1713)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.addNamedQueries(MetadataProcessor.java:153)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2024)
I didn't get this error with EclipseLink 2.6.5 and if I turn Weaving off everything works fine.
Is there a way to work around it? What triggers the error?
The NPE is a bug, as it isn't performing a null check and throwing a more specific error: This error could only occur if you've specified a named native (SQL) query on your entities that references a SqlResultSetMapping, but you haven't defined any result sets mappings. See https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Native#SQL_Result_Set_Mapping for documentation and an example.

jsf+jpa+eclipselink (eclipse juno)

i use jpa (eclipse link) when i test my class main to add data to my table i get this error
[EL Info]: 2014-07-18 22:41:55.274--ServerSession(22745079)--EclipseLink, version: Eclipse Persistence Services - 2.4.2.v20130514-5956486 [EL Info]: connection: 2014-07-18 22:41:55.637--ServerSession(22745079)--
file:/C:/Users/toshiba/workspaceV2/login/build/classes/_login login successful
Exception in thread "main" java.lang.IllegalStateException: Exception Description: No transaction is currently active
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:77)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
at dao.Comptesdao.ajouterComptedao(Comptesdao.java:17)
at test.Main.main(Main.java:15)
do you have any idea

Functional operators causes JPA to crash? (Bug?)

I'm having a very strange problem with JPA and Java 8 functional programming.
I have a Student and Presentation class and their relationship is bidirectional. Everything worked fine in Java 7, but I just switched to Java 8.
This works (visible is private, has no setters):
public static void setAllVisible(boolean visible) {
for (Presentation presentation : new PresentationRepository().findAll()) {
presentation.visible = visible;
}
}
This crashes:
public static void setAllVisible(boolean visible) {
new PresentationRepository().findAll().forEach(x -> x.visible = visible);
//same for new PresentationRepository().findAll().stream().forEach(x -> x.visible = visible);
}
Which gives this exception multiple times:
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader#4554617c
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [BachelorproefPU] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class models.users.Student] uses a non-entity [class models.planning.Presentation] as target entity in the relationship attribute [field presentation].
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at persistence.JPAEntityManager.getEntityManagerFactory(JPAEntityManager.java:45)
at models.repositories.Repository.<init>(Repository.java:23)
at models.repositories.UserRepository.<init>(UserRepository.java:15)
at main.DbInitializer.<init>(DbInitializer.java:27)
at main.DbInitializer.main(DbInitializer.java:23)
I'm pretty sure the persistence.xml is configured correctly (because it works without Java 8) and all classes are included and have #Entity. It's also not the Student class, because if I comment that out, the error just gives another class.
What's causing this? Maybe it's also worth mentioning that I get a compile crash once a while and that they ask me to send the project to Oracle.
Think you'll find that current EclipseLink doesn't support Java 1.8 syntaxis; look at
https://github.com/averri/jpa-lambda-integration-test
I use DataNucleus v4.0 for my projects and works for Java 1.8

Eclispelink PersistenceUnitLoadingException

i encountered PersistenceUnitLoadingException with Eclispelink 2.4.1 below, what do the stack traces tell?
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader#45a877
Internal Exception: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader#45a877
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:118)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at com.mypkg.Main.<clinit>(Main.java:12)
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader#45a877
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:321)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:272)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:150)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:135)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:76)
... 3 more
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:79)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:96)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.<init>(DirectoryArchive.java:74)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.<init>(DirectoryArchive.java:54)
at org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl.createArchive(ArchiveFactoryImpl.java:89)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:297)
... 7 more
Could not find the main class: com.mypkg.Main. Program will exit.
#EDIT
i have the project structure under Eclipse below, which works well with Hibernate as the persistence provider.
bin
|_META-INF
| |_persistence.xml
|_com
|_mypkg
|_Main.class
|_MyEntity.class
Upgrading to eclipselink to the following resolved this issue for me:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.3</version>
</dependency>