Resolve Jboss data source configuration issue - jdbc

After configuring the datasources in the jboss 5.0 AS, I deployed the jbpm web application.
Im getting the the exception.
java.lang.RuntimeException: mapped-name is required for simpleds of deployment webapple.war
at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXmlResourceEnvRefs(WebResourceHand
at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXml(WebResourceHandler.java:325)
The web.xml configuration is
<resource-env-ref>
<resource-env-ref-name>simpleds</resource-env-ref-name>
<resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
</resource-env-ref>
The mysql-ds.xml configuration is
<datasources><xa-datasource>
<jndi-name>simpleds</jndi-name>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:mysql://localhost:3306/testdb</xa-datasource-property>
<user-name>abc</user-name>
<password>abc</password></xa-datasource></datasources>

While deploying a web application in JBoss 5AS, We have to define the datasource in jboss-web.xml in web-inf.
<?xml version="1.0" encoding="UTF-8"?><jboss-web><resource-ref>
<res-ref-name>java:simpleds</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:simpleds</jndi-name>
</resource-ref>

Related

Deploying a RAP .war file in jetty

I created an hello-world RAP application following the eclipse tutorial. I have no problems starting it in eclipse.
Now i want to package it as a .war file with maven and deploy it inside a jetty server. That's the point where i'm already unsure if it is the right approach.
My .war file includes all RAP, equinox and maven plugins, a web.xml and a config.ini. I'm building it with Tycho but i'm open to other solutions.
config.ini:
#Product Runtime Configuration File
osgi.bundles=RapHello/BasicEntryPoint#start,\
org.eclipse.core.commands#start,\
org.eclipse.core.jobs#start,\
org.eclipse.equinox.common#start,\
org.eclipse.equinox.console#start,\
org.eclipse.equinox.ds#start,\
org.eclipse.equinox.http.registry#start,\
org.eclipse.equinox.servletbridge.extensionbundle,\
org.eclipse.equinox.http.servlet#start,\
org.eclipse.equinox.http.servletbridge#start,\
org.eclipse.equinox.registry#start,\
org.eclipse.equinox.servletbridge#start,\
org.eclipse.equinox.util#start,\
org.eclipse.osgi.services#start,\
org.eclipse.rap.jface#start,\
org.eclipse.rap.rwt#start,\
org.eclipse.rap.rwt.osgi#start,\
raphello.BasicEntryPoint#start
osgi.bundles.defaultStartLevel=4
web.xml (copied from another sample .war):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app id="WebApp">
<servlet id="bridge">
<servlet-name>equinoxbridgeservlet</servlet-name>
<display-name>Equinox Bridge Servlet</display-name>
<description>Equinox Bridge Servlet</description>
<servlet-class>org.eclipse.equinox.servletbridge.BridgeServlet</servlet-class>
<!-- Framework Controls could be useful for testing purpose, but
we disable it per default -->
<init-param>
<param-name>enableFrameworkControls</param-name>
<param-value>false</param-value>
</init-param>
<!-- Enable multi-language support for the extension registry -->
<!-- the OSGi console is useful for trouble shooting but will fill up your
appserver log quickly, so deactivate on production use. Uncomment
the -console parameter to enabled OSGi console access. -->
<init-param>
<param-name>commandline</param-name>
<param-value>-registryMultiLanguage <!-- -console --></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>equinoxbridgeservlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
When i deploy the file in my jetty server, i get no errors and it seems like the file gets picked up, but all i get are
HTTP ERROR 404
Problem accessing /hellorap. Reason:
ProxyServlet: /hellorap
i think i tried all possible paths. What i read so far is, that the path should be the file name of my .war but that doesn't work.
jetty start log:
INFO::main: Logging initialized #276ms to org.eclipse.jetty.util.log.StdErrLog
INFO:oejs.Server:main: jetty-9.4.10.v20180503; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_181-b13
INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
INFO:oejs.session:main: No SessionScavenger set, using defaults
INFO:oejs.session:main: node0 Scavenging every 600000ms
INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext#561b6512{/,file:///C:/Users/USR/AppData/Local/Temp/jetty-0.0.0.0-8081-raphello.war-_-any-511053963228532950.dir/webapp/,AVAILABLE}{webapps/raphello.war}
INFO:oejs.AbstractConnector:main: Started ServerConnector#2898ac89{HTTP/1.1,[http/1.1]}{0.0.0.0:8081}
INFO:oejs.Server:main: Started #4477ms
So the question is: What am i doing wrong? Is it even the right approach?
This answer doesn't seem to work so my error is propably at an earlier stage.

Failed to look up JNDI DataSource In Spring Boot Application

I have done the bellow mentioned configuration for JNDI DataSource connection for Spring Boot Application that uses an external tomcat.
Tomcat's server.xml configuration like
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="jdbc/MyPostgresDB"
global="jdbc/MyPostgresDB"
auth="Container"
type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/postgres"
username="postgres"
password="postgres"
maxActive="100"
maxIdle="20"
minIdle="5"
maxWait="10000"/>
Context.xml like
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<ResourceLink name="jdbc/MyPostgresDB"
global="jdbc/MyPostgresDB”
auth="Container"
type="javax.sql.DataSource" />
Defined the application.properties for spring boot in right way like
spring.datasource.jndi-name=java:comp/env/jdbc/MyPostgres
Updated the web.xml like
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<resource-ref>
<description>JNDI LookUp</description>
<res-ref-name>jdbc/MyPostgresDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<!-- <res-sharing-scope>Shareable</res-sharing-scope> -->
</resource-ref>
</web-app>
Still getting the exception like
org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException:
Failed to look up JNDI DataSource with name
'java:comp/env/jdbc/MyPostgres'
(Full Stacktrace not given as every where it is given)
So what is the solution or why I am getting this exception.
Don't come with the idea of embedded tomcat server for spring boot.
Please help me.
Should be
spring.datasource.jndi-name=java:comp/env/jdbc/MyPostgresDB
from what you wrote above in your definitions.
we should add factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" in Resource tag of server.xml and make sure to set JndiDatasource in the class where you extends SpringBootServletInitializer class
For elaborate answer please refer here

NameNotFoundException when starting JBoss with an EAR using HornetQ ConnectionFactory via JNDI using Spring JMS

I'm trying to deploy an application (EAR) which has Spring JMS listeners, BlazeDS flex and HornetQ in Jboss EAP 6.2.4. When I deploy the application and try to start the server, I'm getting the below exception.
Caused by: javax.naming.NameNotFoundException: JmsXA -- service jboss.naming.context.java.JmsXA
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:103)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)
at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:241)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:183)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_80]
at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_80]
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154) [spring-context-3.0.7.RELEASE.jar:3.0.7.RELEASE]
I saw this thread with similar problem (https://stackoverflow.com/a/12278834/1326592) but this wouldn't work in my case as I dont have a SAR file in my application.
I'm looking up to the Queues and ConnectionFactory via jee
<jee:jndi-lookup id="connectionFactory" jndi-name="java:/JmsXA"/>
<jee:jndi-lookup id="RequestsQueue" jndi-name="java:/jms/queue/requestQueue"/>
Please suggest a solution of how to start the HornetQ in Jboss before deploying my application.
I found a solution for the above issue.
This got resolved after referring to the JNDI's via resource-ref in web.xml
<resource-ref id="ItftRequestsQueue">
<res-ref-name>requestQueue</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<lookup-name>java:/jms/queue/requestQueue</lookup-name>
</resource-ref>
and
referring to the resource-ref in my spring.xml as
<jee:jndi-lookup id="connectionFactory" jndi-name="connectionFactory"/>
<jee:jndi-lookup id="requestsQueue" jndi-name="requestQueue"/>

Deploying a camel project having no main method,web.xml

My project consists of a spring xml(having the camel context, weblogic configuration parameters, jms related configurations) a pojo having the route for camel (whose reference we provide in spring) and an xsl.
My project has to listen on a queue, transform the message and publish it onto another queue. Everything works fine until i try to deploy it. How do i go about deploying it...i do not have a main java class...i tested my code by invoking Main of org.apache.camel.spring.Main.
I have to deploy it onto weblogic since my route consumes from weblogic queue seamlessly. How do i do it?.jar or .war or .ear? And how do i go about creating my .jar or .war or .ear? Remember i have only 3 files in my project structure and a few dependent jars
You will deploy it as a war file. I have not done this with Weblogic but the steps for Tomcat are listed below:
First make sure that all the needed jars are packaged in your war file.
Bootsrap Spring to your WAR file by adding the following to your web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
Add location of your Spring XML file by using the following:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/camel-context.xml</param-value>
</context-param>
Package the war with Maven i.e. run the command mvn package
Deploy the war file to the server.

Spring 3.1 - Servlet 3 code-based configuration using the Jetty Maven Plugin

I try to integrate the new features of spring 3.1 using annotations to specify the configuration information for the web application.
I set up the maven-jetty-plugin version 8.0.4.v20111024 to run my app.
While starting jetty using the mvn jetty:run command, everything seems to be ok and set up correctly.
But when accessing the app through the browser, there is just the output of the default servlet.
It seems to be a simular issue, that tomcat had in previous versions (<=7.0.14)
https://issues.apache.org/bugzilla/show_bug.cgi?id=51278
Currently, I can not use jetty and I had to switch to the tomcat-plugin to deploy my application to tomcat.
Has anyone any suggestions, how to overwrite the jetty default servlet, when no web.xml is available?
You do it by overriding the default jetty config, put this in your plugin:
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<webAppConfig>
<defaultsDescriptor>src/main/resources/webdefault.xml</defaultsDescriptor>
</webAppConfig>
</configuration>
Copy the webdefault file from Jetty, and comment out this part:
<!-- <servlet-mapping> -->
<!-- <servlet-name>default</servlet-name> -->
<!-- <url-pattern>/</url-pattern> -->
<!-- </servlet-mapping> -->

Resources