<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
在glassfish 4和wildfly 8 Final上不适用最新的Mojarra 2.2.5
Manfried Riem 说,我已经看到了关于此的多个错误报告,
确定这是一个EL问题,EL实现已经修复以解决这个问题
修复版本说2.2.5,它也在2.2.5的发行说明中说明,我错过了什么?
我曾经遇到过wildfly 8这个问题,但解决了包含$ WILDFLY_HOME/modules/system/layers/base/org/eclipse/persistence/main中的eclipselink.jar并使用资源root更新module.xml
<resource-root path="eclipselink.jar" />
Run Code Online (Sandbox Code Playgroud)
并包括在我的ejb模块的POM.xml上
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.0</version>
<scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这在Wildfly 8中运行良好.*.不幸的是,为Wildfly 9CR1采用相同的技术一直都没有通过以下日志:
08:52:31,028 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.unit."rga-ear-1.0.ear".FIRST_MODULE_USE: org.jboss.msc.service.StartException in service jboss.deployment.unit."rga-ear-1.0.ear".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment "rga-ear-1.0.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:163)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.ServiceConfigurationError: javax.persistence.spi.PersistenceProvider: Provider org.eclipse.persistence.jpa.PersistenceProvider could not be instantiated
at java.util.ServiceLoader.fail(ServiceLoader.java:232)
at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at org.jboss.as.jpa.persistenceprovider.PersistenceProviderLoader.loadProviderModuleByName(PersistenceProviderLoader.java:70)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.lookupProvider(PersistenceUnitServiceHandler.java:998)
at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.nextPhaseDependsOnPersistenceUnit(PersistenceUnitServiceHandler.java:1046) …Run Code Online (Sandbox Code Playgroud) 我正在处理与数据库中的延迟加载对象相关的问题。
假设我们有以下实体。
@Entity(name = "User")
@Table(name = "USERS")
public class User{
@Id
@GeneratedValue
private int id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="NOTES_ID")
private List<Note> notes;
}
Run Code Online (Sandbox Code Playgroud)
而 Dto 将是
@Mapper
public interface UserDtoMapper{
/** the INSTACE HERE **/
User fromDto(UserDto dto);
UserDto toDto(User user);
}
Run Code Online (Sandbox Code Playgroud)
那么哪个可能是获取所有用户而没有 EJBException 的最佳方法,因为我正在获取他们懒惰?
编辑:解决方案
假设您有以下数据模型
@Entity(name = "User")
@Table(name = "USERS")
public class User{
@Id
@GeneratedValue
private int id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="NOTES_ID")
private List<Note> notes;
}
Run Code Online (Sandbox Code Playgroud)
addresses但因为延迟加载(通过休眠或任何其他框架)最终会出现异常。此外,您可以忽略addressesfrom 被映射,如@Mehmet …
我是在Mac OSX上开发Java的新手.我想下载Java 7 EE SDK,以便我可以使用Java进行桌面/移动/企业开发.下载文件.sh(具体java_ee_sdk-7-jdk7-macosx-x64)是我不熟悉的.Java 7 SE SDK是一个.dmg文件,它是我期望的Enterprise Edition而不是.sh文件的格式.
.shvs .dmg).sh
文件?*注意:目前我在Mac上安装的唯一JRE是Apple版本,据我所知已被弃用.
我们有一个Java EE 7应用程序并使用Arquillian来测试东西.现在我们要检查当前登录用户的一些权限.我的问题很基本,如何在测试用例中登录用户?我读过ProgrammaticLogin在arquillian测试和嵌入式Glassfish,安全性和Arquillian问题上都没有用,但是没有明确回答.我目前的做法是这样的:
// Inject services etc.
@Test
public void testLogin(){
UserAccount user = new UserAccount();
user.setUsername("bob");
user.setPassword("bob");
userAccountService.save(user);
ProgrammaticLogin pl = new ProgrammaticLogin();
String realmName = "secureJDBCRealm";
try {
pl.login("bob", "bob".toCharArray(), realmName, true);
} catch (Exception e){
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
现在当我尝试运行它时,得到一个LoginException,声称我没有为"fileRealm"配置LoginModule.但是"fileRealm"不是我正在寻找的领域(我把它放在那里进行第一次测试,但后来我将其改为"secureJDBCRealm",这是我们为GlassFish定制的安全领域).我们arquillian-glassfish-embedded-3.1用于测试.
我在项目中使用JAVA SE 1.7和JAVA EE 7,
哪些是可用的服务器(商业/免费),它们将支持JAVA EE 7 web profile 2.1?(必需组件).我需要使用Servlet 3.1和CDI 1.1 ..etc.
JavaEE的-spec_WebProfile
我尝试使用JBoss EAP 6.1/Jboss 7,但我开始知道它将支持JAVA EE 6 web配置文件.(web-profile1,web-profile2)
我发现JAVA EE 7兼容服务器是GlassFish Server Open Source Edition 4.0,TMAX JEUS 8.
还有其他服务器?
我已将我的应用程序从JSF 1.2迁移到2.2.
它在java.sun.com域 上使用XML命名空间xmlns:f="http://java.sun.com/jsf/core".但是,Oracle的Java EE 7教程正在使用xmlns.jcp.org域名
上的XML命名空间xmlns:f="http://xmlns.jcp.org/jsf/core".
推荐哪一个,为什么会改变?
EclipseLink 2.6.1(final)在GlassFish Server 4.1上部署Java EE应用程序时抛出以下异常.在从2.6.0升级之前没有发生这种情况.
Warning: java.lang.NullPointerException
at org.eclipse.persistence.platform.server.ServerPlatformUtils.createServerPlatform(ServerPlatformUtils.java:101)
at org.eclipse.persistence.sessions.factories.SessionManager.init(SessionManager.java:77)
at org.eclipse.persistence.sessions.factories.SessionManager.<clinit>(SessionManager.java:71)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.addSessionToGlobalSessionManager(EntityManagerSetupImpl.java:907)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.initSession(EntityManagerSetupImpl.java:2676)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:675)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:305)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:337)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:303)
at org.glassfish.persistence.jpa.JPADeployer$2.visitPUD(JPADeployer.java:451)
at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:492)
at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:395)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:487)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at …Run Code Online (Sandbox Code Playgroud) 鉴于新的Java8,我们为异步任务获得了非常好的功能,例如CompletableFuture和.paralellStream().如果你在Java SE中运行它,因为我已经理解它你将使用ForkJoinPool,但是如果我在例如Wildfly或TomcatEE中运行以下示例会发生什么?
//Here I start a comp.Future without giving an Executor
test = CompletableFuture.supplyAsync(() -> timeConsumingMethod());
//Here I start a parallel stream
mList.paralell().filter(...).collect(Collectors.toList())
Run Code Online (Sandbox Code Playgroud)
会发生什么,我将从哪里借用我的资源
我已经使用Java EE 7提供的api实现了一个WebSocket.此外,我已经实现了一个请求我的WebSocket没有任何问题的客户端.为了确保在执行某些代码更改时这仍然有效,我想实现测试,这些测试也可以在构建服务器上运行,例如Jenkins CI,而不仅仅是在本地.我正在使用maven.
这是我的服务器端点:
import javax.enterprise.context.ApplicationScoped;
import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@ApplicationScoped
@ServerEndpoint("/example")
public class WebSocket {
private final Set<Session> sessions = Collections.synchronizedSet(new HashSet<>());
@OnOpen
public void open(Session session) {
sessions.add(session);
}
@OnClose
public void close(Session session) {
sessions.remove(session);
}
@OnError
public void onError(Throwable error) {
//TODO do something
}
@OnMessage
public void handleMessage(String message, Session session) throws IOException {
session.getBasicRemote().sendText("Hello "+message+"!");
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的客户端端点:
import javax.websocket.*;
import java.io.IOException;
import java.net.URI;
@ClientEndpoint …Run Code Online (Sandbox Code Playgroud)