Bug 448496 - IllegalArgumentException when creating a new entity with the diagram
Summary: IllegalArgumentException when creating a new entity with the diagram
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: Diagram Editor (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows 7
: P1 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Petya Sabeva CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-23 09:28 EDT by Mauro Molinari CLA
Modified: 2015-01-14 10:17 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mauro Molinari CLA 2014-10-23 09:28:14 EDT
I installed Dali 3.4 - JPA Support on my Eclipse Luna 4.4.1 installation (build id: M20140925-0400).
Whenever I try to add an entity to my project using the Diagram Editor, I get the following exception and nothing happens (the entity is not added to the diagram editor):

eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_25
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=it_IT
Command-line arguments:  -os win32 -ws win32 -arch x86_64

org.eclipse.graphiti.ui
Error
Thu Oct 23 15:11:03 CEST 2014
GFCommandStack.execute(Command) java.lang.IllegalArgumentException: Path must include project and resource name: /fatturapa-api

java.lang.IllegalArgumentException: Path must include project and resource name: /fatturapa-api
	at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
	at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2137)
	at org.eclipse.core.internal.resources.Container.getFile(Container.java:208)
	at org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil.getFile(JPAEditorUtil.java:1348)
	at org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil.isPersistenceProviderLibraryInClasspath(JPAEditorUtil.java:1363)
	at org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil.checkIsSetPersistenceProviderLibrary(JPAEditorUtil.java:1391)
	at org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateJPAEntityFeature.create(CreateJPAEntityFeature.java:125)
	at org.eclipse.graphiti.features.impl.AbstractCreateFeature.execute(AbstractCreateFeature.java:100)
	at org.eclipse.graphiti.internal.command.GenericFeatureCommandWithContext.execute(GenericFeatureCommandWithContext.java:64)
	at org.eclipse.graphiti.internal.command.GFPreparableCommand.doExecute(GFPreparableCommand.java:37)
	at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
	at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:115)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
	at org.eclipse.graphiti.internal.command.CommandExec.executeCommand(CommandExec.java:85)
	at org.eclipse.graphiti.ui.internal.command.CreateModelObjectCommand.execute(CreateModelObjectCommand.java:55)
	at org.eclipse.graphiti.ui.internal.editor.EmfOnGefCommand.execute(EmfOnGefCommand.java:54)
	at org.eclipse.graphiti.internal.command.GFPreparableCommand2.doExecute(GFPreparableCommand2.java:43)
	at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
	at org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFCommandOperation.java:119)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
	at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
	at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:84)
	at org.eclipse.graphiti.ui.internal.editor.GFCommandStack.execute(GFCommandStack.java:138)
	at org.eclipse.graphiti.ui.internal.dnd.GFTemplateTransferDropTargetListener.handleDrop(GFTemplateTransferDropTargetListener.java:55)
	at org.eclipse.gef.dnd.AbstractTransferDropTargetListener.drop(AbstractTransferDropTargetListener.java:183)
	at org.eclipse.jface.util.DelegatingDropAdapter$3.run(DelegatingDropAdapter.java:219)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
	at org.eclipse.jface.util.DelegatingDropAdapter.drop(DelegatingDropAdapter.java:216)
	at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:91)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:782)
	at org.eclipse.swt.dnd.DropTarget.Drop(DropTarget.java:456)
	at org.eclipse.swt.dnd.DropTarget.Drop_64(DropTarget.java:392)
	at org.eclipse.swt.dnd.DropTarget$3.method6(DropTarget.java:260)
	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:119)
	at org.eclipse.swt.internal.ole.win32.COM.DoDragDrop(Native Method)
	at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:363)
	at org.eclipse.swt.dnd.DragSource.access$0(DragSource.java:289)
	at org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:172)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)

Project setup: it's a JPA project (facets: Java 7, JPA 2.1), with the following configuration:
- platform = Generic 2.1
- library configuration disabled
- connection: a defined connection to a MySQL database
- discover annotated classes automatically
- no source defined for canonical metamodel

The persistence.xml is almost empty:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
	<persistence-unit name="myPU">
	</persistence-unit>
</persistence>

The JPA libraries are added to the project classpath by using Gradle, which adds the following JAR to the project classpath through a dedicated container:
- org.eclipse.persistence.core-2.5.0.jar
- org.eclipse.persistence.asm-2.5.0.jar
- org.eclipse.persistence.antlr-2.5.0.jar
- org.eclipse.persistence.jpa-2.5.0.jar
- org.eclipse.persistence.jpa.jpql-2.5.0.jar
- javax.persistence-2.1.0.jar

The result is the same if I add the User Libraries by downloading EclipseLink 2.5.2 libraries using the JPA configuration wizard in Eclipse instead of providing the JARs by myself with Gradle.

The project is defined in the workspace but physically resides in a folder outside the workspace folder (it's linked in the workspace, using the "Import Existing Project into Workspace"). Could it be this the problem?
Comment 1 Mauro Molinari CLA 2014-10-24 04:42:52 EDT
Sorry Neil, I took the liberty to originally set the severity to "critical" because this is a complete loss of functionality for me, since the Diagram Editor does not work at all in my environment.
Comment 2 Neil Hauge CLA 2014-10-24 08:20:02 EDT
No worries Mauro.  We usually reserve Critical for issues that crash the whole IDE and or result in data loss.  It is certainly a severe problem.  Thanks for the report.
Comment 3 Petya Sabeva CLA 2014-10-24 17:35:07 EDT
Mauro, what type of resource is /fatturapa-api ? Actually, from the attached log seems that this resource couldn't be found? Can you explain how it is bound to the project's structure, so I can try to reproduce the exact exception.
Comment 4 Mauro Molinari CLA 2014-10-27 04:58:52 EDT
Hi Petya!
fatturapa-api is a project the JPA project depends on. The dependency is a buildpath dependency (it is listed in Java Build Path | Projects of the JPA project).
It's a standard Java project with just the Java 1.7 facet and some additional natures (like Groovy and Spring). It physically resides outside the workspace and it is linked in the workspace, just like the JPA project. Anyway, both the JPA project and fatturapa-api are within the same physical folder in the file system (so, even if paths between projects were resolved against the file system instead of against the Eclipse API, relative paths should match...).
Comment 5 Petya Sabeva CLA 2014-10-28 16:42:12 EDT
Mauro, actually we haven't thought of this scenario. So when we are looking for the persistence provider library, we were expecting the array in which we iterate to contains only resources of type IFile, not IProject. However I made a fix and pushed in R3_4_maintenance branch:

http://git.eclipse.org/c/dali/webtools.dali.git/commit/?h=R3_4_maintenance&id=658de43396dcede4321ffba6820b6b0a0169ffe1

and in HEAD:

http://git.eclipse.org/c/dali/webtools.dali.git/commit/?id=6bff4ac94fa51b77ab97115107579edc5c8e9439

Unfortunately, I couldn't find a proper workaround, except to remove the dependency and add it again, when all necessary entities are added in the diagram.
Comment 6 Petya Sabeva CLA 2014-10-28 18:24:37 EDT
I am reopening the bug, because there is a code freeze, so I needed to revert my change.
Comment 7 Mauro Molinari CLA 2014-10-29 04:43:26 EDT
Hi Petya, thanks for your prompt feedback and fix.
So, if I understand it correctly, the fix will be in 3.5, but not in 3.4.x, won't it? Or we may get it for Luna SR2 in February too?
Comment 8 Petya Sabeva CLA 2014-10-29 05:18:52 EDT
Actually, the fix will be available for Luna SR2 also.
Comment 9 Petya Sabeva CLA 2015-01-14 10:17:48 EST
Fix is pushed to the master branch.