嵌入式Glassfish v3:以编程方式部署sun-resources.xml失败 [英] Embedded Glassfish v3: deploying sun-resources.xml programmatically fails

查看:160
本文介绍了嵌入式Glassfish v3:以编程方式部署sun-resources.xml失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用Glassfish嵌入式API将我的jpa-ejb-web项目打包为独立应用程序。

I would like to be able to package my jpa-ejb-web project as a standalone application, by using Glassfish embedded API.

要使用JPA图层,我需要部署sun-resource.xml配置,这应该可以通过 asadmin命令 add-resources path \ to\sun-resources.xml 。我有这样的代码来做到这一点:

To use the JPA layer, I need to deploy the sun-resource.xml configuration, which should be possible with the asadmin command add-resources path\to\sun-resources.xml. I've this code to do it:

    String command = "add-resources";
    ParameterMap params = new ParameterMap();
    params.add("", "...\sun-resources.xml" );
    CommandRunner runner = server.getHabitat().getComponent(CommandRunner.class);
    ActionReport report = server.getHabitat().getComponent(ActionReport.class);
    runner.getCommandInvocation(command, report).parameters(params).execute();

但Glassfish拒绝:

but Glassfish refuses it with:

15-Jul-2010 16:34:12 org.glassfish.admin.cli.resources.AddResources execute

SEVERE:添加资源出错了

SEVERE: Something went wrong in add-resources

java.lang.Exception: ...\gfembed6930201441546233570tmp\lib\dtds\sun-resources_1_4.dtd (The system cannot find the path specified)
        at org.glassfish.admin.cli.resources.ResourcesXMLParser.initProperties(ResourcesXMLParser.java:163)
        at org.glassfish.admin.cli.resources.ResourcesXMLParser.<init>(ResourcesXMLParser.java:109)
        at org.glassfish.admin.cli.resources.ResourcesManager.createResources(ResourcesManager.java:67)
        at org.glassfish.admin.cli.resources.AddResources.execute(AddResources.java:106)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at javaapplication4.Main.main(Main.java:55)

实际上,在指定路径上没有 lib 目录...

and indeed, there is no lib directory on the indicated path ...

在我的代码中是否有错? (我使用 glassfish-embedded- all-3.0.1.jar

is there something wrong in my code? (I use glassfish-embedded-all-3.0.1.jar)

谢谢

Thanks

推荐答案

我通过为嵌入式Glassfish指定一个嵌入式文件系统来解决这个问题,并将 / path / to / my / glassfish / lib / dtds
$ b

I solved it by specifying an Embedded File System for the embedded Glassfish, and prepopulated the /path/to/my/glassfish/lib/dtds folder with the files which were missing.

        EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
        efsb.autoDelete(false);
        efsb.installRoot(new File("/path/to/my/glassfish"), true);

        EmbeddedFileSystem efs = efsb.build();
        Server.Builder builder = new Server.Builder("test");
        builder.embeddedFileSystem(efs);

        builder.logger(true);
        Server server = builder.build();
        server.addContainer(ContainerBuilder.Type.all);
        server.start();

并要求Glassfish在执行结束时不要删除该文件夹。

and asking Glassfish not to delete the folder at the end of the execution.

这篇关于嵌入式Glassfish v3:以编程方式部署sun-resources.xml失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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