I can't make it work to get connection from DataSource obtained from JNDI in tomcat 7.0, resulting in error like this:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of cla
ss '' for connect URL 'null'
I have done in many ways following the doc and other people suggestions, but still not able to fix it. Here are my settings:
In web.xml:
<resource-ref>
<description>MyDataSource</description>
<res-ref-name>jdbc/MyDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
In context.xml:
<Context>
<Resource name="jdbc/MyDataSource" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="abc" password="abc" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#123.123.123.123:1521:xe"/>
<!-- // tried both driver class names but all not work driverClassName="oracle.jdbc.driver.OracleDriver" -->
</Context>
Also, I tried to put that in server.xml, also not work
<Resource name="jdbc/MyDataSource" auth="Container" type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:#123.123.123.123:1521:xe"
servicename="MyDataSource" username="abc" password="abc"
maxActive="20" maxIdle="10" maxWait="20000"/>
<ResourceParams name="jdbc/MyDataSource">
<parameter>
<name>user</name>
<value>abc</value>
</parameter>
<parameter>
<name>password</name>
<value>abc</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
</ResourceParams>
Put classes12.jar as well as ojdbc14.jar in Tomcat 7.0\lib
Can anyone point me the right way?
I wasted so much time on that configuration but still cannot make it work. Thanks in advance!
John
Stack Trace as below:
DS: org.apache.tomcat.dbcp.dbcp.BasicDataSource#497062
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at DBTest.doGet(DBTest.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(Unknown Source)
at java.sql.DriverManager.getDriver(Unknown Source)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
... 21 more
And here is the code, exception at ds.getConnection. (It is not typical way to get DS, bcoz need to match WebSphere way...)
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
initCtx = new InitialContext(env);
DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/MyDataSource");
System.err.println("DS: " + ds.toString());
Connection conn = ds.getConnection();
I realized that I defined the resource twice, once in my TOMCAT_HOME/conf/context.xml and in my applicationPath/META-INF/context.xml. Once I removed the resource from TOMCAT_HOME/conf/context.xml everything worked great.
Related
trying to add content to infinispan cache and I get null pointer exception when i use the put method. Mine is a JSF web application. We are trying to achieve session replication using wildfly 13.
import org.infinispan.Cache;
public class index extends AbstractPageBean implements java.io.Serializable {
#Resource(lookup = "java:jboss/infinispan/cache/web/web_repl")
Cache<String, String> ilsCache;
public Cache<String, String> getCache() {
return ilsCache;
}
public void prerender() {
ilsCache.put("Message", "Hello");
logger.info("CACHE " + getCache());
}
Log file
2018-08-21 14:21:57,134 ERROR [biz.autoscan.ils.index] (default task-1) index.java::Exception occured : java.lang.NullPointerException
at biz.autoscan.ils.index.btnLogin_action(index.java:930)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:181)
at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.lang.Thread.run(Thread.java:745)
Any idea why I still get null pointer exception fro cache.put()?
Edit: We are using WildFly 13 in domain mode and Infinispan in replication mode. My aim is to store the session object in the infinispan cache and share it between all the nodes.
Infinispan subsystem in domain.xml: This is how I have configured infinispan. We are using only two servers at the moment hence we have gone with replication mode.
<subsystem xmlns="urn:jboss:domain:infinispan:6.0">
<cache-container name="web" aliases="ilsee" default-cache="web_repl" module="org.wildfly.clustering.web.infinispan">
<transport channel="ee" lock-timeout="60000"/>
<local-cache name="Username"/>
<replicated-cache name="web_repl">
<transaction mode="BATCH"/>
</replicated-cache>
<distributed-cache name="dist">
<transaction mode="NON_XA"/>
<file-store/>
</distributed-cache>
</cache-container>
</subsystem>
The answer depends on how you configure your server.
I will provide a generic example.
First, you need to configure your standalone.xml file
<subsystem xmlns="urn:infinispan:server:core:9.2">
<cache-container module="org.infinispan.extension:ispn-9.2" name="infinispan_container" default-cache="default">
<transport/>
<global-state/>
<distributed-cache name="default"/>
<distributed-cache name="myCache"/>
</cache-container>
</subsystem>
Then in your Java application, you need to inject the resource using
#Resource(lookup = "java:jboss/datagrid-infinispan/container/infinispan_container/cache/myCache")
Cache cache;
As you can see infinispan_container and myCache are values that you provided in the XML configuration file.
There are two possible ways for your application to utilize Infinispan within Wildfly: embedded mode and server mode.
You can find more information http://infinispan.org/docs/stable/user_guide/user_guide.html#usage_3
I'm having difficulty getting a JDBC DataSource using Tomcat 7
javax.naming.NameNotFoundException: Name [jdbc/weblogin01b] is not bound in this Context. Unable to find [jdbc].
at org.apache.naming.NamingContext.lookup(NamingContext.java:818)
at org.apache.naming.NamingContext.lookup(NamingContext.java:166)
at org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(ResourceLinkFactory.java:92)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:841)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.NamingContext.lookup(NamingContext.java:829)
at org.apache.naming.NamingContext.lookup(NamingContext.java:166)
In CATALINA_BASE/conf/server.xml
I have included a variety of slightly different resources
all aiming to be the same connection hopefully one of them will be right:
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="jdbc/weblogin01"
username="weblogin01"
password="xxxxx"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.pool.OracleDataSource"
description="Global Address Database"
url="jdbc:oracle:thin:#10.15.120.29:1522:DGSPC"
maxActive="15"
maxIdle="3" />
<Resource name="jdbc/weblogin01b"
user="weblogin01"
password="xxxxx"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
url="jdbc:oracle:thin:#10.15.120.29:1522:DGSPC"
maxActive="20"
maxIdle="3"
maxWait="-1" />
<Resource name="jdbc/weblogin01c"
user="weblogin01"
password="xxxxx"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#10.15.120.29:1522:DGSPC"
maxActive="20"
maxIdle="3"
maxWait="-1" />
</GlobalNamingResources>
In META-INF/context.xml
I have a ResourceLink to each resource
<Context antiJARLocking="true" path="/testDbAccess">
<ResourceLink name="jdbc/weblogin01"
global="jdbc/weblogin01"
type="javax.sql.DataSource"/>
<ResourceLink name="jdbc/weblogin01b"
global="jdbc/weblogin01b"
type="javax.sql.DataSource"/>
<ResourceLink name="jdbc/weblogin01c"
global="jdbc/weblogin01c"
type="javax.sql.DataSource"/>
</Context>
In web.xml I made no changes related to JDBC on the understanding that
the ResourceLink elements will be sufficient.
In Java code I try to get a DataSource as follows:
String dbUser = "weblogin01b";
try {
// Obtain our environment naming context
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
// Look up our data source
ds = (DataSource) envCtx.lookup("jdbc/" + dbUser);
if (ds == null) {
logger.log(Level.WARNING,"Null datasource for " + dbUser);
}
}
Given the exception above, it never gets a DataSource, this is the same for:
jdbc/weblogin01
jdbc/weblogin01b
jdbc/weblogin01c
I'm finding Tomcat an uphill struggle, any help would be much appreciated.
Part 1 of the puzzle is solved:
I was editing the wrong copy of server.xml
I am running Tomcat under NetBeans which makes a separate copy of CATALINA_HOME which it configures as CATALINA_BASE, I had not noticed the separate copy.
I wish Tomcat's CATALINA_HOME and CATALINA_BASE were always separate and distinctly different, i.e. no duplication of files.
Part 2 is a different story:
java.sql.SQLException: ORA-01017: invalid username/password; logon denied
I know that I've specified the correct username and password but I'm not seeing these values logged anywhere, I'm guessing that I've specified the correct values in the wrong properties.
Part 2 of the puzzle is solved:
That should be:
username="weblogin01"
NOT
user="weblogin01"
I get the following error consistently when opening STS. To reproduce, I have a bean configuration file open in the editor and I exit STS. Then I re-open STS and this exception is thrown and the editor I had open does not start correctly.
If I close the editor throwing the error and then re-open it (without restarting STS), the editor is able to open fine. But then when restarting STS it will still throw this error.
The content of my bean configuration is mostly Spring Integration elements. Here are the schemas I am using:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc-2.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
The only non-Spring Integration elements are 2 inner-bean definitions for a custom router and a custom transformer:
<int:router id="myrouter" input-channel="routerInput">
<bean class="my.example.Router">
<property name="prop" ref="otherBean"/>
</bean>
</int:router>
<int:transformer input-channel="transformerInput" output-channel="OutboundMail" >
<bean class="my.example.Transformer">
<property name="prop" ref="otherBean"/>
</bean>
</int:transformer>
Stacktrace:
eclipse.buildId=3.6.0.201407101106-RELEASE-e44
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.springsource.sts.ide
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.springsource.sts.ide
This is a continuation of log file U:\Users\fgreg\Documents\Workspace\.metadata\.bak_0.log
Created Time: 2014-08-20 07:57:08.801
org.springframework.ide.eclipse.beans.core.metadata
Error
Wed Aug 20 08:00:16 EDT 2014
Problems occurred when invoking code from plug-in: "org.springframework.ide.eclipse.beans.core.metadata".
java.lang.IllegalArgumentException: 'beanName' must not be empty
at org.springframework.util.Assert.hasText(Assert.java:162)
at org.springframework.beans.factory.config.RuntimeBeanReference.<init>(RuntimeBeanReference.java:58)
at org.springframework.beans.factory.config.RuntimeBeanReference.<init>(RuntimeBeanReference.java:46)
at org.springframework.ide.eclipse.beans.core.internal.model.AbstractBeanMethodOverride.<init>(AbstractBeanMethodOverride.java:37)
at org.springframework.ide.eclipse.beans.core.internal.model.BeanLookupMethodOverride.<init>(BeanLookupMethodOverride.java:24)
at org.springframework.ide.eclipse.beans.core.internal.model.Bean.initBean(Bean.java:373)
at org.springframework.ide.eclipse.beans.core.internal.model.Bean.getProperty(Bean.java:192)
at org.springframework.ide.eclipse.data.SpringDataUtils.isRepositoryBean(SpringDataUtils.java:108)
at org.springframework.ide.eclipse.data.metadata.ui.RepositoriesBeanMetadataProvider.provideBeanMetadata(RepositoriesBeanMetadataProvider.java:52)
at org.springframework.ide.eclipse.beans.core.metadata.internal.model.BeanMetadataBuilderJob$1.run(BeanMetadataBuilderJob.java:198)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.springframework.ide.eclipse.beans.core.metadata.internal.model.BeanMetadataBuilderJob.attachMetadataToBean(BeanMetadataBuilderJob.java:191)
at org.springframework.ide.eclipse.beans.core.metadata.internal.model.BeanMetadataBuilderJob.attachMetadata(BeanMetadataBuilderJob.java:170)
at org.springframework.ide.eclipse.beans.core.metadata.internal.model.BeanMetadataBuilderJob.run(BeanMetadataBuilderJob.java:141)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Has anyone seen this before or know how to fix it?
Larger stacktrace from the log file:
!ENTRY org.eclipse.e4.ui.workbench 4 0 2014-08-20 07:57:05.848
!MESSAGE
!STACK 0
java.lang.IllegalArgumentException: 'beanName' must not be empty
at org.springframework.util.Assert.hasText(Assert.java:162)
at org.springframework.beans.factory.config.RuntimeBeanReference.<init>(RuntimeBeanReference.java:58)
at org.springframework.beans.factory.config.RuntimeBeanReference.<init>(RuntimeBeanReference.java:46)
at org.springframework.ide.eclipse.beans.core.internal.model.AbstractBeanMethodOverride.<init>(AbstractBeanMethodOverride.java:37)
at org.springframework.ide.eclipse.beans.core.internal.model.BeanLookupMethodOverride.<init>(BeanLookupMethodOverride.java:24)
at org.springframework.ide.eclipse.beans.core.internal.model.Bean.initBean(Bean.java:373)
at org.springframework.ide.eclipse.beans.core.internal.model.Bean.getProperty(Bean.java:192)
at org.springframework.ide.eclipse.data.SpringDataUtils.isRepositoryBean(SpringDataUtils.java:108)
at org.springframework.ide.eclipse.data.SpringDataUtils.getRepositoryBeansFor(SpringDataUtils.java:130)
at org.springframework.ide.eclipse.data.SpringDataUtils.getRepositoryBeanIds(SpringDataUtils.java:67)
at org.springframework.ide.eclipse.data.beans.ui.editor.RepositoriesReferenceableElementLocator.getReferenceableElements(RepositoriesReferenceableElementLocator.java:55)
at org.springframework.ide.eclipse.beans.ui.editor.util.BeansEditorUtils.getReferenceableNodes(BeansEditorUtils.java:918)
at org.springframework.ide.eclipse.config.graph.model.AbstractConfigGraphDiagram.updateRefNodeRegistry(AbstractConfigGraphDiagram.java:342)
at org.springframework.ide.eclipse.config.graph.model.AbstractConfigGraphDiagram.refreshModelFromXml(AbstractConfigGraphDiagram.java:331)
at org.springframework.ide.eclipse.config.graph.parts.ActivityDiagramPart.refresh(ActivityDiagramPart.java:217)
at org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:253)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:223)
at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:212)
at org.eclipse.gef.editparts.SimpleRootEditPart.setContents(SimpleRootEditPart.java:105)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:617)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:626)
at org.springframework.ide.eclipse.config.graph.AbstractConfigGraphicalEditor.initializeGraphicalViewer(AbstractConfigGraphicalEditor.java:378)
at org.eclipse.gef.ui.parts.GraphicalEditor.createGraphicalViewer(GraphicalEditor.java:158)
at org.eclipse.gef.ui.parts.GraphicalEditorWithPalette.createPartControl(GraphicalEditorWithPalette.java:63)
at org.eclipse.ui.part.MultiPageEditorPart.addPage(MultiPageEditorPart.java:243)
at org.eclipse.ui.forms.editor.FormEditor.addPage(FormEditor.java:325)
at org.eclipse.ui.part.MultiPageEditorPart.addPage(MultiPageEditorPart.java:213)
at org.eclipse.ui.forms.editor.FormEditor.addPage(FormEditor.java:308)
at org.springframework.ide.eclipse.config.ui.editors.AbstractConfigEditor.addConfigEditorPage(AbstractConfigEditor.java:237)
at org.springframework.ide.eclipse.config.ui.editors.AbstractConfigEditor.updateNamespacePages(AbstractConfigEditor.java:936)
at org.springframework.ide.eclipse.config.ui.editors.SpringConfigEditor.updateNamespacePages(SpringConfigEditor.java:189)
at org.springframework.ide.eclipse.config.ui.editors.AbstractConfigEditor.createNamespacePages(AbstractConfigEditor.java:284)
at org.springframework.ide.eclipse.config.ui.editors.AbstractConfigEditor.addPages(AbstractConfigEditor.java:253)
at org.eclipse.ui.forms.editor.FormEditor.createPages(FormEditor.java:138)
at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:362)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:140)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:99)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:321)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:888)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:869)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:120)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:337)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:104)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:73)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:55)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:127)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:983)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:662)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:766)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:737)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:731)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:715)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl$1.handleEvent(PartServiceImpl.java:92)
at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:187)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:156)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4734)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:218)
at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:36)
at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:81)
at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:59)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:171)
at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer$10.widgetSelected(StackRenderer.java:1035)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:782)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3110)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1794)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:283)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Well I sort of took the nuclear approach which seems to have fixed the problem. I did 2 things that seemed to have resulted in the issue to resolving itself, I'm not sure which one had greater effect in fixing the problem:
I added the 'name' attribute to my inner bean elements:
<int:router id="myrouter" input-channel="routerInput">
<bean class="my.example.Router" name="router">
<property name="prop" ref="otherBean"/>
</bean>
</int:router>
<int:transformer input-channel="transformerInput" output-channel="OutboundMail" >
<bean class="my.example.Transformer" name="transformer">
<property name="prop" ref="otherBean"/>
</bean>
</int:transformer>
I wiped out everything in my .settings folder and restarted STS
I thought adding the 'name' to the inner beans is what did it so I removed the attribute and then restarted to see if the error would reappear. It did not reappear. So it was either a combination of doing both of these things or it was wiping out the .settings files that did it.
trying to write ejb3 junit on netbeans8
we use weblogic 12c but i cant get their embedded container so gave up and trying glassfish
it goes further but one thing bizzar is, even though my persistence xml uses oracle settings, it fires derby and says my schema/tables are not there
I am NOT trying to use derby
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="ACP-warPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<shared-cache-mode>ALL</shared-cache-mode>
<properties>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.logging.logger" value="ServerLogger"/>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:#localhost:1521:db11g"/>
<property name="javax.persistence.jdbc.password" value="spa"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
<property name="javax.persistence.jdbc.user" value="spa"/>
</properties>
</persistence-unit>
</persistence>
Map<String, Object> p = new HashMap<String, Object>();
File[] modules = {
new File("target/test-classes"),
new File("target/classes")
};
p.put(EJBContainer.MODULES, modules);
p.put("org.glassfish.ejb.embedded.glassfish.installation.root", "/target/gfv3");
ejbContainer = EJBContainer.createEJBContainer(p);
ctx = ejbContainer.getContext();
ejbFacade = (AllocnGrpFacade) ctx.lookup("java:global/classes/AllocnGrpFacade");
Caused by: ERROR 42Y07: Schema 'SPA' does not exist
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown Source)
at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown Source)
at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown Source)
at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source)
at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
basically you need glassfish domain setup even for embedded container
I wish I can do this with code, and not with generated garbage, but for now this is how I did it
solved see
Caused by: javax.naming.NameNotFoundException: pools
I have some problems deploying a JAX-WS webservice with Spring 3.0.6 on JBoss AS Final 7.1.1.
I have tried two first method from this tutorial: http://www.javacodegeeks.com/2010/11/jaxws-with-spring-and-maven-tutorial.html
When I was using the first method (extending SpringBeanAutowiringSupport and declaring the servlet in web.xml) the application deploys correctly, but the beans that I inject in the webservice are Null.
Using the second method with SimpleJaxWsServiceExporter I am getting an error while deploying:
10:09:33,012 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-2) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0' defined in ServletContext resource [/WEB-INF/generic-applicationContext.xml]: Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_18]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_18]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_18]
Caused by: javax.xml.ws.WebServiceException: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)
at org.jboss.wsf.stack.cxf.client.ProviderImpl$DelegateEndpointImpl.publish(ProviderImpl.java:300)
at org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter.publishEndpoint(SimpleJaxWsServiceExporter.java:68) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.remoting.jaxws.AbstractJaxWsServiceExporter.publishEndpoints(AbstractJaxWsServiceExporter.java:154) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.remoting.jaxws.AbstractJaxWsServiceExporter.afterPropertiesSet(AbstractJaxWsServiceExporter.java:125) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
... 20 more
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" 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">
<display-name>subscription-barring-service</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/generic-applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
application context:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<context:component-scan
base-package="org.bluewin.bwsso.services.barring" />
<bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter"/>
</beans>
webservice:
#Service("terminateSessionsEndpoint")
#WebService(serviceName = "TerminateSessionsEndpoint", portName = "TerminateSessionsEndpoint")
public class TerminateSessionsEndpoint extends SpringBeanAutowiringSupport {
private Logger logger = Logger.getLogger(TerminateSessionsEndpoint.class);
#Autowired
Service serviceImpl;
#WebMethod(operationName = "TerminateAllSessionsForAccountId")
#WebResult(name = "TerminateAllSessionsResponse")
public TerminateAllSessionsResponseVO terminateAllSessionsForAccountId(
#WebParam(name = "TerminateAllSessionsRequest")
TerminateAllSessionsRequestVO requestWS) {
//do some logic..
}
}
Any clue how can I get it work?
I am also having problems deploying JAX-WS with similiar configuration. Indeed using the SpringBeanAutowiringSupport as described in Spring doc chapter "19.5.5 Exposing servlet-based web services using JAX-WS" doesn't work as expected.
See doc http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html#remoting-web-services
But you are wrong here trying to use SimpleJaxWsServiceExporter. Chapter "19.5.6 Exporting standalone web services using JAX-WS" of spring doc.
This is making a conflict with web service that was was already registered by jboss.
For prove try following configuration with updated port number
application context:
<bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
<property name="baseAddress" value="http://localhost:8081/"/>
</bean>
In final you will run with two services exposed
http://localhost:8080/war-root/MyService?wsdl
http://localhost:8081/MyService?wsdl
As for now I found two workarounds proposed by other people:
use org.springframework.beans.factory.config.AutowireCapableBeanFactory: Jax-ws, spring and SpringBeanAutowiringSupport
move dependency injection to #PostConstruct method: JBoss 6 + Spring 3.0.5 + JAX-WS/CXF
Both workarounds are working fine.
It's definitely a port issue. The exception is pretty clear on that.
Caused by: javax.xml.ws.WebServiceException: java.lang.RuntimeException: java.net.BindException: Address already in use: bind
From your comment you indicate there is something listening on port 9999, <property name="baseAddress" value="http://localhost:9999/ws/" />. The management-native default port is port 9999. If you look in your standalone.xml under the <socket-binding-group/> You'll likely see something like the following.
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/>
<socket-binding name="ajp" port="8009"/>
<socket-binding name="http" port="8080"/>
<socket-binding name="https" port="8443"/>
<socket-binding name="osgi-http" interface="management" port="8090"/>
<socket-binding name="remoting" port="4447"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>
For a test start standalone with the following command.
$JBOSS_HOME/bin/standalone.sh -Djboss.management.native.port=19999