将Scala类添加到DataNucleus增强器CLASSPATH [英] Add scala class to DataNucleus enhancer CLASSPATH

查看:172
本文介绍了将Scala类添加到DataNucleus增强器CLASSPATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在撰写Google App Engine网络应用程序,并希望在服务器端使用Scala。我正在使用Eclipse和Google App Engine插件。但是,只要我将一个空的Scala类源文件添加到我的项目中,DataNucleus增强程序就会警告:


SEVERE:Classcom。 my.package.UserAccount在
CLASSPATH中找不到。请检查您的规范和您的CLASSPATH。


我最终会让这个类持久化,但我想摆脱这个错误首先。

到目前为止,我已经添加了Scala Nature,并且已经尝试清理项目并重新启动Eclipse,但是我总是收到来自增强器的警告。 / p>

关于我能做些什么来让增强器成功运行的想法?

解决方案

在过去的几天里,我一直在努力解决这个问题。在Scala类上的Datanucleus增强器抛出的类未找到错误,因为当增强器运行时,scala-library.jar文件不在类路径中。我找到了两个解决方案:
$ b


  1. 简单但很流畅:将scala-library.jar复制到eclipse / plugins中的文件夹包含增强器。对我来说,这是目前:/opt/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.5.5.r36v201110112027/appengine-java-sdk-1.5.5/lib/tools/orm


  2. 关闭项目属性中的增强器构建器,并创建一个ant文件以手动运行它。然后您可以正确控制类路径。我真的很努力地将scala库加入到classpath中,因此放弃并将它复制到与我的datanucleus jar相同的文件夹中。我的蚂蚁文件如果有人感兴趣的话:






 < project name =DataNucleusEnhancerdefault =enhancebasedir =。> 
< property name =base.dirlocation =/ home / steve / Projects / DNProject/>
< property name =datanucleus.libslocation =/ home / steve / Projects / Jar Libraries / datanucleusjars/>
< property name =sdk.dirlocation =/ opt / eclipse / plugins / com.google.appengine.eclipse.sdkbundle_1.5.5.r36v201110112027 / appengine-java-sdk-1.5.5/> ;
< property name =classes.dirlocation =$ {base.dir} / war / WEB-INF / classes //>
< property name =entities.dirlocation =$ {base.dir} / war / WEB-INF / classes / packagenamehere / entities/>

< fileset dir =$ {sdk.dir} / lib / userincludes =*。jar/>
< / path>

< target name =enhancedescription =DataNucleus enhancement>
< taskdef name =datanucleusenhancerclasspathref =enhancer.classpathclassname =org.datanucleus.enhancer.tools.EnhancerTask/>
< datanucleusenhancer dir =$ {classes.dir}failonerror =trueverbose =true>
< classpath>
< path location =$ {base.dir} / war / WEB-INF / classes //>
< path refid =enhancer.classpath/>
< / classpath>
< / datanucleusenhancer>
< / target>

< / project>

在测试中,我还发现如果我没有命名空间,增强器不愿意增强类。我还担心我现在需要管理scala-library.jar的副本,以确保它与scala eclipse插件中的相同。如果gae插件能够正常工作,它会好得多!


I am writing a Google App Engine web app and wish to use Scala on the server side. I'm using Eclipse and the Google App Engine plugin. However, as soon as I add an empty Scala class source file to my project, the DataNucleus enhancer warns:

SEVERE: Class "com.my.package.UserAccount" was not found in the CLASSPATH. Please check your specification and your CLASSPATH.

I will eventually get round to making the class persistent but I want to get rid of this error first.

So far I've added the Scala Nature, and have tried cleaning the project and also restarting Eclipse but I always get the same warning issued from the enhancer.

Any ideas on what I can do to get the enhancer to run successfully?

解决方案

I've struggled away with this for the last few days. Class not found errors thrown by the datanucleus enhancer on Scala classes occur because the scala-library.jar file isn't in the classpath when the enhancer runs. I've found two solutions:

  1. Simple but cludgy: Copy scala-library.jar to the folder in eclipse/plugins which contains the enhancer. For me this is currently: /opt/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.5.5.r36v201110112027/appengine-java-sdk-1.5.5/lib/tools/orm

  2. Switch off the enhancer builder in your project properties and create an ant file to run it manually. You can then properly control the classpath. I really struggled to get the scala-library into the classpath so gave up and copied it into the same folder as my datanucleus jars. My ant file if anyone's interested is:

<project name="DataNucleusEnhancer" default="enhance" basedir="."> 
    <property name="base.dir" location="/home/steve/Projects/DNProject"/>
    <property name="datanucleus.libs" location="/home/steve/Projects/Jar Libraries/datanucleusjars"/>
    <property name="sdk.dir" location="/opt/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.5.5.r36v201110112027/appengine-java-sdk-1.5.5"/>
    <property name="classes.dir" location="${base.dir}/war/WEB-INF/classes/"/>
    <property name="entities.dir" location="${base.dir}/war/WEB-INF/classes/packagenamehere/entities"/>

    <path id="enhancer.classpath">
        <fileset dir="${datanucleus.libs}" includes="*.jar" excludes="" />
        <fileset dir="${sdk.dir}/lib/user" includes="*.jar" />
    </path>

    <target name="enhance" description="DataNucleus enhancement">
        <taskdef name="datanucleusenhancer" classpathref="enhancer.classpath" classname="org.datanucleus.enhancer.tools.EnhancerTask" />
        <datanucleusenhancer dir="${classes.dir}" failonerror="true" verbose="true">
            <fileset dir="${entities.dir}" includes="**/*.class" />
            <classpath>
            <path location="${base.dir}/war/WEB-INF/classes/"/>
                <path refid="enhancer.classpath"/>
            </classpath>
        </datanucleusenhancer>
    </target>

</project>

In testing I also found the enhancer unwilling to enhance classes if I had no namespaces. I'm also concerned that I now need to manage the copy of scala-library.jar to make sure it's the same as in the scala eclipse plugin. It'd be much better if the gae plugin worked properly!

这篇关于将Scala类添加到DataNucleus增强器CLASSPATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆