How do you specify external configuration in JBoss AS 7? - deployment

We're in the process of upgrading from JBoss Application Server 5.1 to AS 7. In AS 5.1 we defined a Properties object in a '-service.xml' file so that we could externalize all of our configuration. We then read this properties object in via JNDI.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<mbean code="org.jboss.naming.JNDIBindingServiceMgr" name="jboss.apps:name=myProperties">
<attribute name="BindingsConfig" serialDataType="jbxb">
<jndi:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jndi="urn:jboss:jndi-binding-service:1.0"
xs:schemaLocation="urn:jboss:jndi-binding-service resource:jndi-binding-service_1_0.xsd">
<jndi:binding name="myConfig">
<java:properties xmlns:java="urn:jboss:java-properties"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="urn:jboss:java-properties resource:java-properties_1_0.xsd">
<java:property>
...
What's the appropriate way to do this in AS 7?

It is explained here: https://community.jboss.org/message/641742#641742
Seems it is possible from AS 7.1, not in 7.0. Didn't try it yet, though.

Related

Class name is wrong or classpath is not set ERROR in Netbeans with Glassfish 5 server and JPAs

I have a Web Application in Netbeans 11 (with JDK 8 installed), I have added the dependencies for mysql-connector-java-8.0.15.jar and I have generated the JPAs from my DB.
No error while building it.
But when I try to run it, the Glassfish server give me these errors (pastebin link).
This is my persistence.xml, that I set accordingly, is:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="InvoicesPU" transaction-type="JTA">
<jta-data-source>java:app/Invoices</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>
And in my java class I call it by:
#Stateless
public class InvoiceEJB implements InvoiceEJBLocal {
#PersistenceContext(unitName = "InvoicesPU")
EntityManager em;
...
em.someMethod();
For completeness, I have no error during the compilation phase!
Anyone know how to solve it?
After some research I solved it in this way:
taking inspiration from a similar problem, I created the Connection Pool and the Resource in the Glassfish Admin Console as suggested by devmind following this.
I removed as dependency the mysql-connector-java-8.x.x.jar and I added the mysql-connector-java-5.x.x.jar
In the persistence.xml I set the JNDI name for the tag jta-data-source
And everything goes as expected!
I don't know how to make everything work with the latest version of the MySQL Connector but, at least, in this way my Web Application works.
EDIT: for latests versions of mysql-connector, as devmind has suggest you should set MysqlDataSource: from com.mysql.jdbc.jdbc2.optional.MysqlDataSource to com.mysql.cj.jdbc.MysqlDataSource as reported here.
I hope it's useful to someone else.
Try to put your JDBC driver jar to Glassfish domain's lib folder. I usually store them in lib/ext.
I do not remember if I got this info from some other post or from the Glassfish user manual but it solves the issue mentioned for me, i.e.: Class name is wrong or classpath is not set ERROR with Glassfish 5 or Payara server. I'm using Payara Server 5.2022.3 currently.
Add the latest connector j to your server/your_domain; in my case it is domain1 and this is the script after I cd to /bin:
C:\Program Files\payara-web-5.2022.3\payara5\bin>asadmin add-library --type app "C:\Program Files (x86)\MySQL\Connector J 8.0\mysql-connector-j-8.0.31.jar"
Where quoted string is the path where I keep my connector j.

No show anymore message of publisher Java Web Start

I have developed an application via Java Web Start more or less according to this: How do I fix "missing Codebase, Permissions, and Application-Name manifest attribute" in my JNLP app? I have packed the jar with manifest.txt, etc..but in this way I have resolved missing attributes problem, and now I have other problem this message is always showed!! I checked "No show again" and each time I press button to execute and always is showed!! I
Adicionally this is my manifest file:
Manifest-Version: 1.0
Class-Path: .
Main-Class: com.zkteco.biometric.AccesoBiometrioAS2
Permissions: all-permissions
Codebase: http://192.168.111.25:8180/pos-web/
Application-Name: Biometrico
And my Jnlp File this:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://192.168.111.25:8180/pos-web/">
<information> <title>CajaPos</title> <vendor>xxx</vendor>
</information>
<security><all-permissions/>
</security>
<resources>
<j2se version="1.2+"/>
<jar href="xx.jar"
main="true" />
</resources
<application-desc main-class="ec.com.xx.pos" type="JavaFX">
<argument>XY</argument>
</application-desc>
</jnlp>
In this page after check the dialog is not showed again and works fine.
https://docs.oracle.com/javase/tutorial/deployment/webstart/deploying.html
Where XY change for each request because I generate jnlp-xml in a dynamically way with a servlet.
This is due to your Java settings. It is a security prompt. There’s nothing you can change in your application to prevent this dialog, it is up to the end-user to change their security settings to show/hide these dialog windows.
Edit: I also recommend migrating your app to a different delivery platform because Java Web Start is being violently turned off by Oracle.

Persistence unit missing dependencies migrating from JBoss EAP 6.4 to 7.0

I have an application that must run on both JBoss EAP 6.4 and 7.0. The application uses EJB entity beans which are no longer supported on JBoss EAP 7 so the entity beans are being migrated to use JPA entities as described in the JBoss migration guide. The application deploys and works fine on 6.4 but fails to deploy with "missing dependencies" error on 7.0. I've seen alot of issues where the missing dependency was the datasource but that doesn't seem to be the case here. The datasource isn't mentioned at all in the missing dependencies error. I can see in the logs the persistence.xml file is being parsed and the jndi bindings added for the session beans before the deployment fails.
I have an EAR file that contains multiple war and ejb jar files. The application I'm having an issue with consists of an ejbModule.jar which contains the persistence.xml file and entity classes, and a webModule.war file with taglib classes that reference the entity classes contained in ejbModule.jar.
The structure of the EAR file is outlined below:
MyEAR.ear
- ejbJar.jar
- webApp1.war
- webApp2.war
- ejbModule.jar (contains persistence.xml and entity classes)
-- META-INF/persistence.xml
- webModule.jar (taglib classes have dependency on entity classes from ejbModule.jar)
- META-INF
persistence.xml: (replaced class names, datasource name, persistence-unit name)
<persistence version="2.0" xmlns:per="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="myPU">
<class>org.MyEntity1</class>
<class>org.MyEntity2</class>
<jta-data-source>java:/MyDataSource</jta-data-source>
<properties>
<property name="jboss.entity.manager.jndi.name" value="java:/myPU"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/myPU"/>
</properties>
</persistence-unit>
It's difficult to post the error message as it's got hundreds of lines of "missing dependencies" for class names and application names that I can't share and by the time I replace them all I don't feel it would be of much use. But there are entries like:
"jboss.naming.context.java.comp.MyEAR.ejbModule.MyEntity1.InAppClientContainer is missing [jboss.naming.context.java.comp.MyEAR.ejbModule.MyEntity1]",
However there also entries like:
"jboss.deployment.subunit.\"MyEAR.ear\".\"webApp1.war\".component.\"org.taglib.MyTagLibClass\".START is missing [jboss.persistenceunit.\"MyEAT.ear/ejbModule.jar#myPU\"]"
I can see from the DEBUG logging for org.jboss.as.jpa that JBoss looks to be adding dependencies on the persistence unit for all taglib classes in all war files in the ear. Only the webModule.war needs to use the persistence unit.
2017-12-07 15:37:13,808 DEBUG [org.jboss.as.jpa] (MSC service thread 1-2) Adding dependency on PU service service jboss.persistenceunit."MyEAR.ear#myPU" for component org.taglib.MyTagLibClass
When I move the persistence.xml file to the META-INF directory of the EAR the application deploys and works fine on JBoss EAP 7.0. However, this isn't an ideal solution as the EAR file is built dynamically and could contain custom applications that I have no control over.
I've tried various other structures to try and get this working but haven't found anything else that works.
Any ideas how to get this working on JBoss EAP 7.0?
There are unnecessary entries in your persistence.xml
You just need this
<persistence version="2.0" xmlns:per="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="myPU">
<jta-data-source>java:/MyDataSource</jta-data-source>
</persistence-unit>
Because the entities will be found automatically relative to persistence.xml
Please try this and if doesn't help please post as much of the server.log as you can.
Another idea could be to ask the RedHat support as you use EAP I assume that you have subscriptions containing support.

Websphere v8.0.0.6 WASX7017E, ADMA0209E Application exception while Deployment of EJB 2.0 EAR

I have the following problem with WebSphere 8.0.0.6 and no solution is found on the web. I hope anyone can help with this and this will help someone else with this problem.
Error Description:
Error #1 (while installing application):
WASX7017E: Exception received while running file /tmp/wsant3816346180883063201jacl;
exception information:com.ibm.websphere.management.application.client.AppDeploymentException:
com.ibm.websphere.management.application.client.AppDeploymentException
Following Error:
ADMA0209E: Enterprise JavaBeans (EJB) module ServerEJB.jar contains the following
container-managed persistence (CMP) or bean-managed persistence (BMP) :
... (list of all entities)
Explanation:
I generate an EAR with an EJB 2.0 component/project. Up to now I have deployed this EAR within WAS 6.1 successfully, but with WAS 8 it doesn't deploy anymore.
I have the necessary bind-ejbjar.xmi, even in the new format - converted with the script from IBM.
Questions:
WAS 8 still seems to know that there exists a EJB 3 component in the EAR - the question is WHY?
What is the minimum requirement for a EAR/EJB-Module to deploy in WAS 8 - there must be big changes?
Are there more bind-files to be included?
Thanks for help
UPDATE:
So obviously there are prerequisites to declare a package as EJB2.x.
See IBM-HelpCenter:
IBM WebSphere info for developers DE
But I fullfill all of this two prerequisites.
How do I have to package the jar for Websphere 8 to make it acceptable as an EJB2.x?
http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/index.jsp?topic=%2Fcom.ibm.websphere.zseries.doc%2Fae%2Frejb_consid.html&lang%3Dde
The solution was achieved by upgrading to version 2.1 ejb, because there the "version" attribute is allowed and this is required by WebSphere to recognize a non-EJB 3.0 version.
This means that an EJB 2.0 version can not work, since the above tag is not allowed in the ejb-jar_2_0.dtd. Maybe a
<cmp-version>2.x</cmp-version>
could help here, but I didn't tested it.
The conversion of the header of ejbjar.xml brought success:
from 2.0 (ejb-jar_2_0.dtd):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<!-- EJB-jar file declaration -->
<ejb-jar id="EJBJar" version="2.0">
<display-name>Overall Bean Definition</display-name>
<enterprise-beans>
<entity id="Dcnotetext">
...
to 2.1 (ejb-jar_2_1.xsd - you need namespaces! ):
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="EJBJar"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.1"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<!-- EJB-jar file declaration -->
<display-name>Overall Bean Definition</display-name>
<enterprise-beans>
<entity id="Dcnotetext">
...
No further changes to XMI or XML files were necessary!
Thanks for help!

failed to run wicket examples on tomcat7

I downloaded wicket examples 1.6.0 and built successfully in netbeans7.2. but got errors when I tried to deploy on tomcat 7:
Cannot deploy the module. The context.xml file seems to be broken. Check whether it is well-formed and valid.
The module has not been deployed.
See the server log for details.
at
org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:178)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:130)
at
org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:212)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
heres the contents in context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
I prefer to run wicket in eclipse as it negates the requirement to mess around with an external tomcat instance.
If you are comfortable with eclipse and maven i would download wicket 1.6 example archetype via maven, import into eclipse and then in the test directory you can run the run.java class to get an internal jetty server host wicket for you.
this should get you started quickly without having to wrestle with tomcat configurations too.
Not really an answer but an alternative route to the same end point
Add parameter path to context tag, same path that app will be served:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/application-path-name/">
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
Answer obtained from this question.