Deploying Apache Isis on WildFly - deployment

I'm trying to deploy an Apache Isis project on a WildFly server.
The project is just the simpleapp-archetype-1.10.0 and it starts and works well with mvn antrun:run -P self-host and mvn jetty:run-war.
For the jetty part, I added configuration to the org.eclipse.jetty plugin of the parent pom.xml
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.2.v20150730</version>
<configuration>
<war>${project.basedir}/webapp/target/simpleapp.war</war>
</configuration>
</plugin>
Now I wanted to deploy this on a WildFly server, but I get the following error:
Cannot upload deployment: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"simpleapp.war\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"simpleapp.war\".WeldStartService: Failed to start service Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type IsisJdoSupport with qualifiers #Default at injection point [BackedAnnotatedField] #Inject org.apache.isis.objectstore.jdo.datanucleus.service.support.TimestampService.isisJdoSupport at org.apache.isis.objectstore.jdo.datanucleus.service.support.TimestampService.isisJdoSupport(TimestampService.java:0) "}}
How can I fix this error, and why does jetty bypass this error?

I got an answer via the Apache Isis Mailing List.
The error says that WildFly tries to do CDI work. Jetty is just a web server and doesn't support Java EE stuff like CDI. Try to disable CDI support for this application (I have no idea how exactly).
http://isis.markmail.org/message/d3coq6qus3rca7kx
To fix this error:
Add the file jboss-all.xml to Simple App Webapp/Web Pages/WEB-INF with the following code:
<jboss xmlns="urn:jboss:1.0">
<weld xmlns="urn:jboss:weld:1.0" require-bean-descriptor="true"/>
</jboss>
https://docs.jboss.org/author/display/WFLY8/CDI+Reference
Credits to Martin Grigorov though.

Related

War deployment failing on Jboss 7.4

I am migrating from Jboss 6.4 to Jboss 7.4, First I have not made any changes in war file and tried to deploy it on Jboss 7.4, but I was getting below error. This error is coming for all filter and servlet classes which are configured in web.xml file.
Caused by: java.lang.IllegalArgumentException: UT010011: Filter log4jServletFilter of type class org.apache.logging.log4j.web.Log4jServletFilter does not implement javax.servlet.Filter
at io.undertow.servlet.api.FilterInfo.<init>(FilterInfo.java:74)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.createServletConfig(UndertowDeploymentInfoService.java:801)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.start(UndertowDeploymentInfoService.java:276)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
... 6 more
Then I tried with excluding undertow subsystem in jboss-deployment-structure.xml file as below. This time I was able to deploy war file without error, but application is not accessible with root context or any different way. On jboss admin console War is showing in active state but still accessible.
<exclude-subsystems>
<subsystem name="undertow" />
</exclude-subsystems>
Could anyone advise me to resolve filter or servlet class error?

Ojdbc8 jars upgrade to 21.1.0.0 throws Nosuchmethod exception UCPservletContextListener init

Ojdbc8, ons, ucp jars are upgraded to 21.1.0.0 version. When trying to start the app on tomcat server, it's throwing Nosuchmethod exception. Logged in the Tomcat's localhost.log file. Application tries to establish DB connection during startup itself.
01-Jun-2021 15:59:56.641 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 3 Spring WebApplication Initializers detected on classpath
01-Jun-2021 16:00:05.365 INFO localhost-startStop-1 org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext
01-Jun-2021 16:00:19.397 SEVERE localhost-startStop-1 org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [oracle.ucp.jdbc.UCPServletContextListener]
java.lang.NoSuchMethodException: oracle.ucp.jdbc.UCPServletContextListener.init
at java.lang.class.getConstructor(Unknown Source)
This is a known issue with ucp.jar in 21.1. It will be fixed in 21.3 when it's released. In the meantime, you can remove this class from the ucp.jar:
oracle/ucp/jdbc/UCPServletContextListener.class
From my experience, if you put jdbc/ucp jars to Tomcat's lib (which is recommended for productive system) and set provided scope for them in Maven, the problem will disappear.
Another option could be setting metadata-complete="true" in web.xml (read more here and here)
if you are using spring boot then you can use
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
this dependency or update your maven project.

Wrong war file name in deployment directory

I am having a "404 Not found" error message when visiting at:
http://localhost:8080/bword in Eclipse.
This application is served in Wildfly. In POM.xml, it defines:
<artifactId>bword</artifactId>
<packaging>war</packaging>
<name>bword</name>
However, strange enough, when I run the application in Eclipse with Wildfly 9.0 configured as the server, what's deployed into wildfly/standone/deployments/ is bbword.war, as below:
[abigail#localhost wildfly-9.0.2.Final]$ ls standalone/deployments/
bbword.war/ bbword.war.deployed
Which is wrong, it should be "bword.war/" and "bword.war.deployed".
Outside of Eclipse, if I "mvn clean package" under the project "bword", I can get the "bword.war" under the target/ directory.
Please see the attachment screenshot for reference. I suspect somewhere in my pom, or eclipse, or whatever place, there is a misconfiguration of "bbword", instead of "bword", but I can't really find it. I can't find any trace of "bbword". What dictates the name of the deployed war file under deployments?
See attached.
Edited (Part of the POM.xml):
<build>
<!-- Set the name of the war, used as the context root when the app
is deployed -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<!-- WildFly plugin to deploy war -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
</plugin>
<!-- Compiler plugin enforces Java 1.6 compatibility and activates
annotation processors -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
</build>
One more addition:
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
17:32:35,508 INFO [org.jboss.modules] (main) JBoss Modules version 1.4.3.Final
17:32:35,702 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
17:32:35,761 INFO [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) starting
17:32:36,573 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 22) WFLYCTL0028: Attribute 'job-repository-type' in the resource at address '/subsystem=batch' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
17:32:36,594 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found bbword.war in deployment directory. To trigger deployment create a file called bbword.war.dodeploy
17:32:36,625 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
17:32:36,647 INFO [org.xnio] (MSC service thread 1-5) XNIO version 3.3.1.Final
......
This is the very initial section of the console message after I click "Run as Server" on Wildfly. It seems that it shows "Found bbword.war in deployment directory." Before I run it, I delete all in standalone/deployments/*. It start with an empty directory. It seems the "bbword.war" is copied to this directory whenever I run the server. I can't figure out. I use "find / -name bbword.war" on my computer but can't find this file. Really puzzled.
Update on this:
Eventually found out the problem: under the project 'bword', there is a ".setting" directory, which contains this file:
bword/.settings/org.eclipse.wst.common.component
And there is a line in it: , where "bbword" was the previous deploy name I used. Remove this directory and in Maven, run "update" seems fixing this problem. In particular, I need to do both, first delete this dirctory, .setting, then update maven.
Several days wasted on this, but it's good to know about this.
Had the same issue and fixed it by having corrected those 2 files :
.settings/org.eclipse.wst.common.component
=>deploy-name, etc
.project
=>name
First, try deploying the maven-built artifact (bword.war) on your server(Do not forget to completely clean-up any Eclipse deployed artifacts first).
You can do this by simply moving the bword.war from your /target folder to your path_to_wildfly/standalone/deployments folder.
Check the server log file for message: Registered web context: <web_context_name> that should appear once your war is deployed.
If it says /bbword - which is not what you expect, check whether you have a jboss-web.xml file in src/main/webapp/WEB-INF that specifies this as a web-context value.
If the maven artifact results in correct webcontext - /bword, then it must be an Eclipse configuration issue. Have you tried updating the Eclipse project from Maven? :
right click on your project
select Maven
select Update Project
remove your project from Wildfly server, and add it again. If that does not help, try adding a new server runtime and add your project there. Last resort would be to create a new Eclipse workspace.
Good luck.
The listed solutions didnt work for me.
I had to create a completely new project in eclipse:
File->New->Project
named it correctly, and then copy-pasted the necessary code from the old project.
Now the server name is correct.
If you'e running from intellij idea config then checkout artifact name in project structure. I had to rename it manually after fixing finalname tag in pom.xml. Better avoid any timestamp in artifact name.

Unable to see log output of Spring when starting Jetty from Maven plugin

I am developing a webapp in Eclipse Juno as a Maven multi-module project using Spring MVC and the Jetty Maven plugin version 8.1.7.v20120910 with HSQL as in-memory DB during development. I want to start Jetty from within the IDE using the jetty:run goal. The problem is that I cannot see any log outputs from Spring, but I suspect the context is indeed being loaded since console log outputs stop briefly - just as long as it would take to load my yet so small Spring context - before throwing an NPE on an Autowired bean. So my suspicion is that something went wrong while starting up the Spring context.
This is the log output just before it "stops" briefly:
[INFO] web.xml file = file:/F:/projects/matching/template/template-app/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = F:\projects\matching\template\template-app\src\main\webapp
2013-01-26 11:09:18.130:INFO:oejs.Server:jetty-8.1.7.v20120910
2013-01-26 11:09:20.704:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
Which after the pause is followed by:
2013-01-26 11:09:35.884:INFO:/:No Spring WebApplicationInitializer types detected on classpath
2013-01-26 11:09:36.742:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/F:/projects/matching/template/template-app/src/main/webapp/},file:/F:/projects/matching/template/template-app/src/main/webapp/
2013-01-26 11:09:36.742:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/F:/projects/matching/template/template-app/src/main/webapp/},file:/F:/projects/matching/template/template-app/src/main/webapp/
2013-01-26 11:09:36.742:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/F:/projects/matching/template/template-app/src/main/webapp/},file:/F:/projects/matching/template/template-app/src/main/webapp/
2013-01-26 11:09:36.743:WARN:oejw.WebAppContext:Failed startup of context o.m.j.p.JettyWebAppContext{/,file:/F:/projects/matching/template/template-app/src/main/webapp/},file:/F:/projects/matching/template/template-app/src/main/webapp/
java.lang.NullPointerException
Now I am confident that I will be able to fix whatever is causing the NPE, but for that I need to see what is happening to my Spring context. I used to work on the same constellation of tools last year, when a colleague had set it up with what I believe was the same configuration as I am using now.
I have searched the web all morning and couldn't find anything useful about it, only the vague suggestion to run Jetty externally and assemble the war and deploy the app, which is exactly not what I want.
This is my pom's build configuration:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
<warName>template</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
<webApp>
<jettyEnvXml>${jettyEnvXml-file}</jettyEnvXml>
</webApp>
<contextPath>template</contextPath>
<systemProperties>
<systemProperty>
<name>log4j.configuration</name>
<value>file:jetty/log4j-jetty.properties</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
And this is my log4j configuration for Jetty:
log4j.debug=true
log4j.threshold=ALL
log4j.rootLogger=DEBUG, consoleLogger
log4j.appender.consoleLogger=org.apache.log4j.ConsoleAppender
log4j.appender.consoleLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleLogger.layout.ConversionPattern=%-5p [%t]: %m%n
log4j.appender.consoleLogger.Threshold=TRACE
Could it have to do with this line at the beginning of my log?
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
But as far as I know it's just an m2e bug that can be ignored. I have slf4j in my classpath though.
When I run my unit tests with HSQL in the SpringJPA module, it works nicely, so I suspect it's a Jetty issue or something with my log4j configuration is just bogus.
Any ideas, hints, helps are greatly appreciated.
You have slf4j in your classpath, then Jetty will use slf4j.
Make sure you setup/configure for slf4j.
You can even setup slf4j to have its log events route to log4j for actual writing to disk or presenting to your console.

Run WAR file in /target directory of Maven project by Tomcat

I'm developing a web application with Java and Maven build system and the web server is Tomcat 7.0.12. After packaging whole project to a WAR file to \target directory by Maven build command, I have to copy it to the webapps folder of Tomcat home to run it. It's very inconvenient, especially when I modified some source files because I have to do all those things (build, copy to Tomcat, run it) again. I've research some articles about Maven, Tomcat, Eclipse on this problem, but there's no result.
Could you please help me:
1. How to make Tomcat run the WAR file on target directory of project which is built by Maven command directly? No need to copy/paste the WAR file and restart Tomcat?
2. How can I configure the Tomcat to debug the web application on Eclipse?
Thank you so much!
BTW, I've read and tried to configure Tomcat, Maven and pom file many times. But I don't know what is the exact configuration, because there are so many advices! Could you provide a particular example of configuration for me?
Here is my configuration files:
Tomcat tomcat-users.xml
<role rolename="manager-gui"/>
<user username="admin" password="" roles="manager-gui"/>
**<role rolename="manager"/>
<user username="admin" password="" roles="manager"/>**
<role rolename="admin-gui"/>
<user username="admin" password="" roles="admin-gui"/>
Maven settings.xml
tomcat
admin
And the pom.xml file of project:
<build>
<finalName>my-project</finalName>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<server>tomcat</server>
<warFile> ${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
</plugins>
// Other plugins
</build>
More details:
If I run mvn tomcat:deploy before starting a Tomcat instance, the returned error is "Cannot invoke Tomcat manager: Connection refused: connect."
Otherwise, if a Tomcat instance has been started before calling mvn tomcat:deploy, the error is "Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fmy-project&war=..."
There are a couple of ways to do this.
The tomcat maven plugin http://mojo.codehaus.org/tomcat-maven-plugin/ provides you a way to deploy directly to tomcat from maven. You must have configured your tomcat users first. See http://tomcat.apache.org/tomcat-7.0-doc/config/realm.html for instructions on how to configure your users.
For debugging you can start tomcat with the arguments specified at http://wiki.apache.org/tomcat/FAQ/Developing
The other way would be to configure tomcat to point to your war. See http://tomcat.apache.org/tomcat-7.0-doc/config/context.html particularly the docbase parameter.
EDIT 1
Based on the revised question http 403 is a forbidden this means you didn't authenticate correctly.
Change your tomcat-users.xml to look as follows:
You need to add a refrence to the username/password in your pom.xml.
You settings.xml must contain (based on your configuration)
<server>
<id>tomcat</id>
<username>admin</username>
<password></password>
</server>
Theres a good page http://www.avajava.com/tutorials/lessons/how-do-i-deploy-a-maven-web-application-to-tomcat.html that explains it more fully. However the information may be out of date.
I ran into exactly the same issue.
I suppose it is eclipse-tomcat plugin that is doing this. And I have no idea why it works differently in tomcat 7 opposed to tomcat 6 which I didn't have problem with.
Anyways, what I did was to have maven build into the /web-app/WEB-INF directory
<build>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
...
</build>
After this config, eclipse:eclipse should yield a proper eclipse project/classpath files
resources:resources shoudl work accordingly as well.