Whille deploying RESTful webservice, Shows error JdbcDataSource. not found - rest

I have been trying to create my first RESTful execrcise using. But I am unable to deploy module due to error "com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : jdbc/playerDB__pm"
I checked and I have JNDI, daata source created.
Unlike specified in link. I am using:
-Netbeans 8.0.3, Java EE 7, GlassFish Server 4.
Also I have checked GlassFish is running fine.
Edit 1:
I have re-checked my 'Services' tab, and I could not find jdbc/__playedDB ,even though I have created it.

Its a bug, the JDBC resource file is not being created (atleast with versions I am using: GlassFish 4.1, Netbeans 8.0.2). Using GlassFish manually create.
There could still be different error untill you set following connectins:
database(data source) <- connection pool <- JNDI.

Related

Netbeans Entity classes from database wizard fails

My setup:
Netbeans 16 on windows 11
Mysql server 8
mysql-connector-java-8.0.30.jar
OpenJDK 64-Bit Server VM Microsoft-40354 (build 17.0.4.1+1-LTS, mixed mode, sharing)
Payara server 5.2 configured in Netbeans.
I have a legacy web application which uses Jdbc resources and connection pools defined in domain.xml inside Payara.
When I deploy the application it works correctly and can access the data in Mysql.
I need to add some new entities and I launch Entity classes from database wizard but it fails.
I had weird problems with that wizard in the past months but since then I changed computer reinstalling everything from scratch and the wizard doesn't work any more.
At step 2 I select a datasource which comes from Payara's domain.xml and an error is immediately reported:
Unable to find driver com.mysql.cj.jdbc.MysqlDataSource. Register this driver in databases tab
I think it refers to Tab Services, Databases tree node, drivers. Unfortunately I cannot add class MysqlDataSource there because it only accepts driver classes.
What can I do ?
I found two possible workarounds.
Temporarily remove the Payara server from Netbeans.
Now the Datasource select box is not populated from domain.xml
so you can finally choose a database connection already defined inside Netbeans or create a new one with "New datasource..."
Open domain.xml, search for the Jdbc connection pool you are going to use and add valid URL and driverClass properties

IBM Worklight 6.1 - Project fails to initialize because the project database schema is from version N/A

I got the following error message when I try to deploy my .war file to the application server:
Error 500: javax.servlet.ServletException: Worklight Console
initialization failed.Logged Exception: java.lang.RuntimeException:
FWLSE0206E: The project /rmbp failed to initialize, because the
project database schema for data source
jdbc:db2://192.168.1.80:50001/APPCNTR is from version N/A, which is
not supported by the server from version 6.1.0.00.20131126-0630. Use
the Worklight ant tasks to upgrade the project database schema.
[project rmbp]
I already doing some research and ask IBM's about our issue as wellas reviewed the following similar question: IBM Worklight 6.1 - Unable to initialize the project due to DB2 error
It looks like you try to install a Worklight runtime to the APPCNTR database. This database is used for Application Center and is not related to the Worklight runtime database that is called WRKLGHT.
How do you install your Worklight war file : with the server configuration tool, the deployment ant scripts (that can be found in the configuration-samples directory of the Worklight installation) or manually ?
See http://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/index.jsp?topic=/com.ibm.worklight.deploy.doc/devref/r_ant_tasks_configure_dbs.html that explains how to configure the Worklight runtime database and deploy a Worklight runtime war file.
Have you create a jdbc connection in your Websphere Application Server?
It will be needed by the application inside the WAR file to connect to the database.
If you have done it, you can check inside your WAR file and look for web.xml file in WEB-INF/ folder. In my case I found a jdbc hardcoded inside the file, for example:
<resource-ref>
<description>Worklight Server Database</description>
<res-ref-name>jdbc/WorklightDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Reports Database</description>
<res-ref-name>jdbc/WorklightReportsDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
You can rename those hardcoded file into the same name of the jdbc that you created in you WAS.
For the database issue, you can follow this link to use ant for DB creation.
http://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/index.jsp?topic=/com.ibm.worklight.deploy.doc/devref/r_ant_tasks_configure_dbs.html
If you follow the 1st ant script for DB2 creation which will have two different databases, you need to create the new user for this line if you haven't done so.
Because as you can see, in the xml script, user and password will be needed to create the WRKLGHT database. For example:
<db2 database="WRKLGHT" server="proddb.example.com"
user="wl6admin" password="wl6pass">
If you use non-default port for your DB2 connection, you can add on your port number parameter after the server parameter.
For example:
port="50001"
For user creation, u can follow this link:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=%2Fcom.ibm.db2.luw.qb.server.doc%2Fdoc%2Ft0006742.html
The error message looks pretty clear to me. You seem to have upgraded your Worklight installation, but did not upgrade the database scheme used for Application Center.
You need to consult with the IBM Worklight Information Center.
Upgrading to Worklight Server V6.1.0 in a production environment
You do not mention how did you upgrade your installation to v6.1.0, nor what did you do. So take a look at the following topic as well regarding database upgrade, since as mentioned it looks like your DB2 database scheme for the APPCNTR database did not take place:
Manually upgrading the Worklight Server V6.1.0 databases

Ant build in Eclipse with Weblogic 9.2 - deployment exception - Unable to connect to 't3://localhost:7001': invalid type code: 31

It gives me the following exception message as I am trying to deploy an application.
BUILD FAILED
C:\eclipse\workspace\SLGIADMIN\build.xml:14: The following error occurred while executing this line:
C:\eclipse\buildcommon.xml:243: weblogic.Deployer$DeployerException: weblogic.deploy.api.tools.deployer.DeployerException: Unable to connect to 't3://localhost:7001': invalid type code: 31. Ensure the url represents a running admin server and that the credentials are correct. If using http protocol, tunneling must be enabled on the admin server.
I am using ant build in Eclipse and deploying to Weblogic 9.2.
I have been trying to find solution online. I have tried enable the tunneling in the Weblogic console. Doesn't work.
I have seen people mention we can use JDK 1.5 which will turn on tunneling on deploying. I have verified mine version is 1.5 too. I have ensured that too but did not fix the issue.
Invalid type code 31 is always because you're connecting with a different version of Java than what the server is running. Weblogic 9.2 only supports Java 1.5. Make sure that's what your ant task is using. You can also connect with later versions of Java if you set the following property in your client:
-Dsun.lang.ClassLoader.allowArraySyntax=true

glassfish 4.0 jpa resource

I try to deploy my application but I still get deployment errors. I created connection pool succesfully (I can even create entities from tables using JPA Tools in Eclipse).
As you can see I've also created a JDBC Resource in Glassfish admin panel called sellyourthingres. When I use "sellyourthingres" instead of "sellyourthing" in persitance.xml nothing changes and i got exactly the same errors (with different name of course). Choosing JTA/JTA(default) doesn't change anything.
What should I do?

java.lang.NoSuchMethodError: javax.persistence.EntityManager.getMetamodel()

How to fix this error using OpenXava 4.6 with Glassfish 2.2:
javax.servlet.ServletException: java.lang.NoSuchMethodError: javax.persistence.EntityManager.getMetamodel()Ljavax/persistence/metamodel/Metamodel
I got this error when trying to access my test module from the browser.
http://localhost:8080/testmod/xava/module.jsp?application=testmod&module=test
In my case, using openxava 4.6 with glassfishESBv22 gave me the error java.lang.NoSuchMethodError: javax.persistence.EntityManager.getMetamodel... so when i changed the server to default tomcat bundle with OX4.6, it worked fine. that means it was the glassfish server problem...finally i used the latest glassfish server v3.1.2 and it also worked fine. so problem solved...only changing the server to the latest one was the solution.
OpenXava 4.6 uses JPA2, while the application server you're using uses JPA1. If you need to work with an old application server you can configure the classloaders in order that use JPA engine included your OpenXava application.