gwt-plugins / gwt-eclipse-plugin

GWT Eclipse Plugin Documentation
http://gwt-plugins.github.io/documentation/
Eclipse Public License 1.0
115 stars 49 forks source link

AutoEnhancer classpath, or classloader issue. Fails validation. #15

Closed branflake2267 closed 9 years ago

branflake2267 commented 9 years ago

Should the facet gatekeep turning on the auto enhancing when in facet mode.

branflake2267 commented 9 years ago

sdk = GaeSdk.findSdkFor(javaProject); is finding, and this is wrong.

/Users/branflake2267/.m2/repository/com/google/appengine/appengine-api-1.0-sdk/1.9.18/appengine-api-1.0-sdk-1.9.18.jar, /Users/branflake2267/.m2/repository/com/google/appengine/appengine-api-1.0-sdk/1.9.18/appengine-api-1.0-sdk-1.9.18.jar,

branflake2267 commented 9 years ago

It appears the issue exists in GaeSdk.getInstallationPath() when m2e is providing the library, it has the wrong base path for the java sdk .

branflake2267 commented 9 years ago

GaeSdkInstaller is installing zip by unzipping and adding it to the list. "gaeSdk" extension query not pulling it up.

branflake2267 commented 9 years ago

Original error

!MESSAGE GAE SDK /Users/branflake2267/.m2/repository/com/google/appengine/appengine-api-1.0-sdk/1.9.18/appengine-api-1.0-sdk-1.9.18.jar failed validation
!STACK 1
org.eclipse.core.runtime.CoreException: SDK location '/Users/branflake2267/.m2/repository/com/google/appengine/appengine-api-1.0-sdk/1.9.18/appengine-api-1.0-sdk-1.9.18.jar' is not a directory
    at com.google.appengine.eclipse.core.sdk.AppEngineBridgeFactory.getAppEngineBridge(AppEngineBridgeFactory.java:73)
    at com.google.appengine.eclipse.core.sdk.GaeSdk.getAppEngineBridge(GaeSdk.java:326)
    at com.google.appengine.eclipse.core.sdk.GaeSdk.validate(GaeSdk.java:494)
    at com.google.appengine.eclipse.core.orm.enhancement.AutoEnhancer.hasValidSdk(AutoEnhancer.java:209)
    at com.google.appengine.eclipse.core.orm.enhancement.AutoEnhancer.build(AutoEnhancer.java:126)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
branflake2267 commented 9 years ago

Fixed library path, but now, the enhancer isn't getting the tools lib loaded in the classpath. Tracking that down now. Trying to figure out how the bridge is adding the tools api jar to classpath for enhancer.

workaround for maven lib path.

@Override
    public IPath getInstallationPath() {
      try {
        IPath fragmentRootPath = null;
        IPath installPath = null;
        // Check for a type that lives appengine-api-*.jar
        IType gaeMarkerType = javaProject.findType(GAE_MARKER_TYPE);
        if (gaeMarkerType != null) {
          IPackageFragmentRoot packageFragmentRoot =
              (IPackageFragmentRoot) gaeMarkerType.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
          fragmentRootPath = packageFragmentRoot.getPath();

          // Used for maven path, this may not be the best method (might be considered to be a workaround)
          // See: GaeSdkInstaller.mavenRepositorySdkPath(...)
          if (fragmentRootPath.segmentCount() > 3 && MavenUtils.hasMavenNature(javaProject.getProject())) {
            String version = fragmentRootPath.removeLastSegments(1).removeFirstSegments(fragmentRootPath.segments().length - 2).toPortableString();
            String sdkPath = String.format("appengine-java-sdk/%s/appengine-java-sdk/appengine-java-sdk-%s", version, version); // from GaeSdkInstaller
            installPath = fragmentRootPath.removeLastSegments(3).addTrailingSeparator().append(sdkPath);

            System.out.println("~~~~ installPath=" + installPath);
          } else if (fragmentRootPath.segmentCount() > 1
              && (fragmentRootPath.removeLastSegments(1).addTrailingSeparator().toPortableString()
                  .endsWith(SDK_LIB_USER_DIR_PORTABLE_SUBPATH) || fragmentRootPath
                  .removeLastSegments(1).addTrailingSeparator().toPortableString()
                  .endsWith(SDK_LIB_IMPL_DIR_PORTABLE_SUBPATH))) {
            // Should live in SDK_ROOT/lib/user or SDK_ROOT/lib/impl
            installPath = fragmentRootPath.removeLastSegments(3);
          }
        } else {
          // Check for a type that lives in appengine-tools-api.jar
          gaeMarkerType = javaProject.findType(GAE_TOOLS_MARKER_TYPE);
          if (gaeMarkerType != null) {
            IPackageFragmentRoot packageFragmentRoot =
                (IPackageFragmentRoot) gaeMarkerType
                    .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
            fragmentRootPath = packageFragmentRoot.getPath();
            if (fragmentRootPath.segmentCount() > 1
                && fragmentRootPath.removeLastSegments(1).addTrailingSeparator().toPortableString()
                    .endsWith(SDK_LIB_DIR_PORTABLE_SUBPATH)) {
              // Should live in SDK_ROOT/lib
              installPath = fragmentRootPath.removeLastSegments(2);
            }
          }
        }

        if (installPath != null) {
          return installPath;
        }

        return fragmentRootPath;
      } catch (JavaModelException e) {
        AppEngineCorePluginLog.logError(e);
      }

      return null;
    }
branflake2267 commented 9 years ago

Wahoo, fixed in app. Going to pull and test.

EnhancerJob

 @Override
  public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {

    List<String> classpath = buildClasspath(javaProject);

    // Workaround, when using maven project, the tools api jar isn't in rumtime classpath
    if (sdk != null && MavenUtils.hasMavenNature(javaProject.getProject())) {
      IPath toolApiJarPath = sdk.getInstallationPath().append(GaeSdk.APPENGINE_TOOLS_API_JAR_PATH);
      classpath.add(toolApiJarPath.toPortableString());
    }
branflake2267 commented 9 years ago

https://github.com/gwt-eclipse-plugin/gwt-eclipse-plugin/pull/16