简体   繁体   English

使用Jboss和Wildfly 9.x运行Java EE项目时出错

[英]Error while runing java EE project with Jboss and Wildfly 9.x

I have error while runing my Project it's correctly deployed but i have this error 我在运行Project时出错,但已正确部署,但出现此错误

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) javax.naming.NoInitialContextException:需要在环境或系统属性中或作为applet参数或在应用程序资源文件中指定类名称:javax.naming.spi.NamingManager.getInitialContext(未知源)上的java.naming.factory.initial )

here is my main Code : 这是我的主要代码:

try {
        Context context = new InitialContext();
        UserServicesRemote userservicesremote = (UserServicesRemote) context.lookup("behealthy-ear/behealthy-ejb/UserServices!services.UserServicesRemote");
    } catch (NamingException e) {
        e.printStackTrace();
    }

My canonical adress is true : 我的规范地址是正确的: 在此处输入图片说明

this exception (NamingException) is indicating that the name of service not is correct. 此异常(NamingException)表示服务名称不正确。 When you server is deployed, you can see in the log the names of services deployed. 部署服务器后,您可以在日志中看到已部署服务的名称。 Por example: 例如:

java:global/backend-ear/backend-ejb/UserBOEJB!org.backend.bo.UserBOLocal
java:app/backend-ejb/UserBOEJB!org.backend.bo.UserBOLocal
java:module/UserBOEJB!org.backend.bo.UserBOLocal
java:global/backend-ear/backend-ejb/UserBOEJB
java:app/backend-ejb/UserBOEJB
java:module/UserBOEJB

You can use the first line of your log (global) for the lookup. 您可以使用日志的第一行(全局)进行查找。

Suggestion: Perhaps you should add jboss-client.jar into your client environment. 建议:也许您应该将jboss-client.jar添加到您的客户端环境中。 ../bin/client/ ../bin/client/

The error is not from the actual lookup, but it can't initialise the JNDI-system properly. 该错误不是来自实际的查找,但无法正确初始化JNDI系统。

When you have a standalone-client you need to add a file jndi.properties like this: 当拥有独立客户端时,您需要添加文件jndi.properties,如下所示:

java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

and a file jboss-ejb-client.properties like this: 以及一个文件jboss-ejb-client.properties,如下所示:

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port = 8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

You have to add jboss-client.jar to the classpath and use the correct JNDI-name in the ejb:-namespace, not the one in the java:-namespace from the logfile. 您必须将jboss-client.jar添加到类路径中,并在ejb:-名称空间中使用正确的JNDI名称,而不是日志文件中java:-namespace中的名称。 It looks like this: 看起来像这样:

ejb:backend-ear/backend-ejb/UserBOEJB!org.backend.bo.UserBOLocal

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM