我正在尝试使用Netbeans 从Java 7/8 EE教程*部署第一个示例(hello1),我遇到了问题.项目编译没有问题,但在部署时会出错:
Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.2:redeploy (deploy) on project hello1: Execution deploy of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.2:redeploy failed: Failed to create deployer with implementation class org.codehaus.cargo.container.glassfish.GlassFish4xInstalledLocalDeployer for the parameters (container [id = [glassfish4x]], deployer type [installed]). InvocationTargetException: The container configuration directory "/home/DeltaLima/glassfish4/glassfish/domains" does not exist. Please configure the container before attempting to perform any local deployment. Read more on: http://cargo.codehaus.org/Local+Configuration -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
与教程相反,我在/ opt/glassfish-v4中安装了GlassFish服务器,而不是/ home/DeltaLima/glassfish4.在Netbeans中我以这种方式进行配置,因此我可以毫无问题地启动,停止和检查服务器的状态.服务器配置中的域文件夹已正确设置.
似乎与Netbeans捆绑的Maven安装期望服务器安装在用户的主目录中.
我是Java EE,Netbeans和Maven的新手,因此我没有配置Netbeans/Maven的经验,错误消息中提供的教程或链接都没有多大帮助.
如何在Netbeans中设置项目,使其部署在正确的目录中?
Netbeans版本7.3.1
Glassfish版本4.0
操作系统:Ubuntu
*答案已更新,以便考虑Java 8 EE
这个问题之所以出现是因为我阅读了Arjan Tijms 关于 JSF 2.3 的博客文章。在那里,他列出了可以通过 CDI 注入的所有 JSF 工件。虽然HttpServletRequest
提到了,HttpServletResponse
但并没有出现在我一开始并不相信的上述清单上。
为了进行尝试,我设置了一个简单的服务器(JavaEE8、Wildfy22):
@Inject private HttpServletRequest req;
工作得很好@Inject private HttpServletResponse res;
投掷DeploymentException: WELD-001408: Unsatisfied dependencies for type HttpServletResponse
我不明白为什么HttpServletResponse
不应该注射。毕竟,我们的目标是通过简洁的注入来取代复杂的方法链。如果是HttpServletRequest
,FacesContext.getCurrentInstance().getExternalContext().getRequest();
现在可以缩短为上述注入。
好吧,在 的情况下HttpServletResponse
,没有可替换的候选注入FacesContext.getCurrentInstance().getExternalContext().getResponse();
,如上所示。
总结:为什么可以HttpServletRequest
通过 CDI 注射但HttpServletResponse
不能?
我正在尝试将EAR文件部署到Glassfish 5服务器。确切的版本是GlassFish Server Open Source Edition 5.0 (build 25)
。部署是通过管理GUI完成的,并列出了已放置在域的applib文件夹中的另一个库。尝试部署时,它立即失败,并显示以下形式的消息Error occurred during deployment: java.io.IOException: invalid zip file: file:/C:/glassfish5/glassfish/tmp/(ear_file_name).ear. Please see server.log for more details.
文件名将是EAR文件的名称,后跟某种形式的时间戳或随机数。我检查了temp目录,可以看到在那里创建了一个0字节大小的EAR文件。最初,这是Windows temp文件夹,我怀疑有访问问题,因此我将JVM设置为对临时文件使用其他文件夹,如上所示。这也失败了。我尝试与具有管理员权限的用户一起运行Glassfish,但仍然无济于事。
如何解决这个问题?
附加信息:
asadmin
提示符下使用deploy命令(或直接通过asadmin deploy --libraries=[jar in applibs] [ear file]
)通过命令行进行部署可以正常工作。部署时来自服务器的日志文件如下:
[2019-07-17T17:16:48.174+0200] [glassfish 5.0] [INFO] [] [org.glassfish.admingui] [tid: _ThreadID=46 _ThreadName=admin-listener(4)] [timeMillis: 1563376608174] [levelValue: 800] [[
GUI deployment: uploadToTempfile]]
[2019-07-17T17:16:48.175+0200] [glassfish 5.0] [INFO] [] [org.glassfish.admingui] [tid: _ThreadID=46 _ThreadName=admin-listener(4)] [timeMillis: 1563376608175] [levelValue: 800] [[
uploadFileName=Test-app-ear-3.0.0.0-SNAPSHOT.ear]]
[2019-07-17T17:16:48.177+0200] [glassfish 5.0] …
Run Code Online (Sandbox Code Playgroud) 除了这里对 CY2018的引用之外……我发现很难弄清楚何时(或是否)Weblogic Server 版本将支持 Java EE 8?
由于最近在 Log4j 上发现了漏洞,我们的任务是迁移到版本 >= 2.16.0。最初,我的项目使用的是<version>1.2.17</version>
添加必要的依赖项并进行必要的更改后,在启动请求时出现以下错误:
引起原因:java.lang.NoClassDefFoundError:无法初始化类org.apache.logging.log4j.core.LoggerContext
我的 POM 文件
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.12</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.13</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>5.1</version>
<scope>provided</scope> …
Run Code Online (Sandbox Code Playgroud) 我已经尝试了很多方法来解决这个问题,但没有成功。我发现,如果我们使用“abstractBinder”,那么这可以解决,但是一旦我的 Binder 就位,我就开始出现 404 错误。
UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl
Run Code Online (Sandbox Code Playgroud)
请帮忙
我的资源:
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import com.walmart.services.helpers.IUserService;
import com.walmart.services.helpers.ServicesTest;
@Path("/sayHello")
public class ControllerTest {
@Inject
private IUserService service;
@Inject
private ServicesTest service2;
@GET
@Path("/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String method(@PathParam("name") String msg) {
return service.method() + " msg";
}
@GET
@Path("/v2/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String method2(@PathParam("name") String msg) {
return service2.method() + " msg";
}
}
Run Code Online (Sandbox Code Playgroud)
我的资源配置文件:
@ApplicationPath("/rest/*")
public …
Run Code Online (Sandbox Code Playgroud) 即使我从我的代码异常中抛出自定义异常,我也收到了邮递员内部服务器错误。我想查看我抛出的具有有效错误消息和错误代码的异常。如果你们中的任何人能在这一点上帮助我,那将是一个很大的帮助。就像我如何获得更好的错误消息一样。添加以下代码快照。提前致谢。
@Service
public class FetchActionImpl implements FetchAction {
private static Logger log = LoggerFactory.getLogger(FetchActionImpl.class);
@Autowired
FetchActionServiceImpl fetchActionService;// = new FetchActionServiceImpl();
@Override
public FetchResponse fetchActionRequest(String caseId) throws BBWException,Exception{
//String resp ="";
log.info("fetchaction Request: {}",ApplicationConstants.LOG_ENTRY_MESSAGE);
log.info("The caseId received from BRASS:\n {}",caseId);
FetchResponse resp = null;
try{
if(true) {
throw new BBWException("500","Test");
}
resp = fetchActionService.fetchIt(caseId);
log.debug("fetchaction Response: {}",resp.toString());
}
catch (BBWException be) {
throw be;
}
catch (Exception e) {
throw new BBWException("500",e.getMessage());
}
return resp;
}
}
@Api
@Path("/fetch_service")
public interface …
Run Code Online (Sandbox Code Playgroud) 在网上搜索时,我发现应该可以将一些方便的 JSF 对象 @Inject 到 CDI bean 中,这些对象应该由 JSF 生成并通过 javax.faces.annotation.* 中的限定符公开(如 @RequestMap 或 @SessionMap)。
但是,我无法将这些资源 @Inject 到 CDI Bean 中。即使注入ExternalContext
或FacesContext
失败,如 JSF 2.3 规范中所述,也应该可以 @Inject 以及以下内容:
javax.faces.context.Flash
javax.servlet.http.HttpSession <-- 这个正在工作
@RequestScoped
public class SimpleRequestParamReportProvider implements ReportParamsProvider {
@Inject // <-- FAILS
ExternalContext externalContext;
@Inject // <-- FAILS
FacesContext facesContext;
@Inject @RequestMap // <-- FAILS
Map<String, Object> requestMap;
@Inject // <-- WORKS
HttpSession httpSession;
Run Code Online (Sandbox Code Playgroud)
应用程序启动时显示错误:
在注入点 [BackedAnnotatedField] @Inject report.SimpleRequestParamReportProvider.facesContext 处带有限定符 @Default 的 FacesContext 类型的依赖关系不满足
我正在使用JBoss …
我需要在嵌入式解决方案中部署我的应用程序(在树莓派零上运行)。因此,我只能在本地主机上部署东西。我对虚拟主机不太熟悉,所以我对此可能是错误的。
我的问题是我希望 tomcat 自动部署包含在我克隆到树莓派上的 git 存储库中的 war 文件。这样就可以轻松地通过 git 存储库进行更新,而不必与经理打交道。话虽这么说,我也希望保持默认 webapps 目录中包含的管理器和其他管理工具处于活动状态并正常工作。我不想将它们复制到 git 存储库中,因为它们会被放错位置并保留在存储库中,这是不必要的。此外,我希望tomcat“分解”或提取原始webapps目录中的WAR文件,以免将这些文件添加到git存储库中。
基本上,我希望能够自动部署某个目录中的所有 war 文件,而无需实际写入该目录,同时还可以自动部署“标准”webapps 目录中的 war 文件。
这可能吗?
我使用的是tomcat9
我想在 Liberty 应用程序服务器上激活自定义消息侦听器。
这是我的代码:
@MessageDriven(name = "Receiver")
public class Receiver implements InboundListener {
@Override
public void receiveMessage(String message) {
System.out.println("Message Received : " + message);
}
}
Run Code Online (Sandbox Code Playgroud)
这是 server.xml :
<?xml version="1.0" encoding="UTF-8"?>
<server description="Dandelion IOT server">
<featureManager>
<feature>cdi-2.0</feature>
<feature>beanValidation-2.0</feature>
<feature>appSecurity-3.0</feature>
<feature>jpa-2.2</feature>
<feature>jaxrs-2.1</feature>
<feature>jsonb-1.0</feature>
<feature>jsonp-1.1</feature>
<feature>managedBeans-1.0</feature>
<feature>websocket-1.1</feature>
<feature>ejbLite-3.2</feature>
<feature>jca-1.7</feature>
<feature>jndi-1.0</feature>
<feature>mdb-3.2</feature>
<feature>localConnector-1.0</feature>
</featureManager>
<library id="DandelionLibs">
<fileset dir="/etc/dandelion/lib" includes="*.jar"/>
</library>
<jdbcDriver id="database-driver" libraryRef="DandelionLibs"/>
<dataSource jndiName="JTA-DataSource" transactional="true" jdbcDriverRef="database-driver">
<properties databaseName="${database.name}" serverName="${database.hostname}" portNumber="${database.port}"
user="${database.username}" password="${database.password}"/>
</dataSource>
<resourceAdapter id="dra" autoStart="true" location="/etc/dandelion/lib/RA.rar"/>
<connectionFactory jndiName="h5/sampleConnection">
<properties.dra/> …
Run Code Online (Sandbox Code Playgroud) java-ee-8 ×10
java ×5
cdi ×2
jakarta-ee ×2
jsf-2.3 ×2
tomcat9 ×2
deployment ×1
ear ×1
glassfish ×1
hk2 ×1
java-ee ×1
java-ee-7 ×1
jboss ×1
jca ×1
jersey ×1
jersey-2.0 ×1
log4j2 ×1
maven ×1
maven-cargo ×1
open-liberty ×1
raspberry-pi ×1
rest ×1
servlets ×1
spring-boot ×1
web-services ×1
weblogic ×1
weblogic12c ×1
weld ×1