Remote Debugging Eclipse doesn't stop at my break point - war

I usually never post questions on stackoverflow because I always found answers but in this case I spent a full week trying to get eclipse to debug my remote WAR file but impossible. My war project is just an Hello Word with only one file BackTest.java
package alxFinancial.dispatcher;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import javax.servlet.*;
import java.io.*;
/**
* Servlet implementation class BackTest
*/
#WebServlet("/BackTest")
public class BackTest extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* #see HttpServlet#HttpServlet()
*/
public BackTest() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<head><title>Hello World</title></title>");
pw.println("<body>");
pw.println("<h1>Hello World</h1>");
pw.println("</body></html>");
}
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException,IOException
{
doGet(request, response);
}
}
I created an ant build.xml file to compile the war file. I made sure to include the source,vars and lines and debug="true" in the debugger option.
<project name="orderManager" default="war_dispatcher" basedir=".">
<!-- set global properties for this build -->
<property name="build" location="build"/>
<property name="lib" location="build/lib"/>
<property name="jar_path"
location="/home/alex/Documents/Projects/Finance/Framework/Java/jars"/>
<property name="lib_alxFinancial" location="build/lib/alxFinancial"/>
<property name="lib_dispatcher" location="build/lib/dispatcher"/>
<property name="target" location="build/target"/>
<property name="webxml" location="ressources/dispatcher/webContent/WEB-
INF/web.xml"/>
<property name="web_directory" location="ressources/dispatcher/webContent"/>
<property name="src" location="src"/>
<property name="src_dispatcher" location="src/dispatcher"/>
<property name="src_alxFinancial" location="src/alxFinancial"/>
<property name="main-class" value="orderManager.Test" />
<property name="client-main-class" value="orderManager.Client" />
<property name="server-main-class" value="orderManager.OrderServer" />
<property name="quoteUpdate-main-class" value="quoteUpdate.Test" />
<property name="strategyManager-main-class"
value="strategyManager.StrategyManagerServer" />
<property name="ressources" value="ressources" />
<path id="dispatcher.classpath">
<fileset dir="/home/alex/Documents/Projects/Finance/Framework/Java/jars">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="init">
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
<mkdir dir="${lib}"/>
<mkdir dir="${lib_alxFinancial}"/>
<mkdir dir="${lib_dispatcher}"/>
<mkdir dir="${target}"/>
</target>
<target name="build_dispatcher" depends="init" description="Compile
dispatcher source">
<javac srcdir="${src_dispatcher}" destdir="${lib_dispatcher}" debug="true"
includeantruntime="false" debuglevel="lines,vars,source" source="1.8"
target="1.8">
<classpath refid="dispatcher.classpath"/>
</javac>
</target>
<target name="war_dispatcher" depends="build_dispatcher">
<war warfile="${target}/Dispatcher.war" webxml="${webxml}">
<classes dir="${lib_dispatcher}" />
<fileset dir="${web_directory}">
<exclude name="WEB-INF/web.xml" />
</fileset>
</war>
</target>
<target name="copy_dispatcher" depends="war_dispatcher" description="Copy
dispatcher war to tomcat webapp directory">
<copy file="${target}/Dispatcher.war" tofile="${tomcat}/Dispatcher.war"
overwrite="true"/>
</target>
</project>
My ant script compile my class,create the war file and copy it into the tomcat/webapp/ folder.
I also configured my catalina.sh to be able to accept remote debugging as follow.
#
JPDA_OPTS="-
agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y"
#
and finally I set up a remote java application in eclipse with the port 8000 and the host localhost.When I run http://localhost:8080/Dispatcher/BackTest I can see my nice Hello word appearing but eclipse does not stop in the breakpoints I set in doGet.I also tried using jdb as a debugger, thinking it was an eclipse problem but I can't see the code:
alex#XXX:~/alx_git/orderManager$ jdb -attach localhost:8000 -sourcepath
src/dispatcher/
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
> stop in alxFinancial.dispatcher.BackTest.doGet
Set breakpoint alxFinancial.dispatcher.BackTest.doGet
>
Breakpoint hit: "thread=http-nio-8080-exec-5",
alxFinancial.dispatcher.BackTest.doGet(), line=23 bci=0
http-nio-8080-exec-5[1] next
>
Step completed: "thread=http-nio-8080-exec-5",
alxFinancial.dispatcher.BackTest.doGet(), line=24 bci=8
http-nio-8080-exec-5[1] next
>
Step completed: "thread=http-nio-8080-exec-5",
alxFinancial.dispatcher.BackTest.doGet(), line=25 bci=15
I give you guys more information on the version of ant,javac,java,eclipse and tomcat.
ant Apache Ant(TM) version 1.10.3 compiled on March 24 2018
javac javac 1.8.0_131
java java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
eclipse Version: Neon.3 Release (4.6.3)
Build id: 20170314-1500
Server version: Apache Tomcat/8.0.24
Server built: Jul 1 2015 20:19:55 UTC
Server number: 8.0.24.0
OS Name: Linux
OS Version: 4.15.0-34-generic
Architecture: amd64
JVM Version: 1.8.0_131-b11
JVM Vendor: Oracle Corporation
I am really sorry for asking this question but I am stuck.I really tried before but I can't get eclipse to debug my code.
I am getting closer now. If I create a java dynamic web project,include my BackTest.java class in it and Export War File to my tomcat server, it works,I can stop at my breakpoint. Whereas if I use new Java project with existing ant build file I can't get eclipse to debug it. May be some missing library in the WAR file ?
I hope you can help me.
Alex

Related

SimpleMessageListenerContainer Bean not invoking after first message in a particular queue

I am consuming messages and then passing them on to a taskexecutor.. My MessageListener will instantiate a SimpleMessageListenerContainer Bean which in turn will instantiate other beans(consumer etc).
When I start the tomcat server and post a message the SimpleMessageListenerContainer bean is getting invoked correctly but when in the same queue I post another message I see RabbitListenerEndpointContainer is getting called. As a result, my other beans are not getting set. I get the message but MDB is not invoked.
When I post a message in a different queue (without restart) it works as expected.
I see no exceptions saying the listener is shutdown etc. Is there a property I am missing?
The only thing I can think of is the first message is not formed correctly resulting into some problem.
My Container Bean
<bean id="springListenerContainerCSWF"
class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer">
<property name="connectionFactory" ref="cachingConnectionFactory" />
<property name="queues" ref="rabbitDestinationCSWF" />
<property name="messageListener" ref="rabbitMessageListenerCSWF" />
</bean>
Here is the log snippet for first and second message:
Message 1 Log:
DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Storing delivery for consumerTag: 'amq.ctag-Kidy_yvO5xOLL6_7SyuzBw' with deliveryTag: '1' in Consumer#1617944b: tags=[[amq.ctag-Kidy_yvO5xOLL6_7SyuzBw]], channel=Cached Rabbit Channel: AMQChannel(amqp://poc#10.165.1.11:5672/POC,2), conn: Proxy#58651bd2 Shared Rabbit Connection: SimpleConnection#1576020a [delegate=amqp://poc#10.165.1.11:5672/POC, localPort= 61774], acknowledgeMode=AUTO local queue size=0
18:44:29.704 [springListenerContainerABCD_ORDER-1] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Received message: (Body:'[B#3ac56714(byte[16757])' MessageProperties [headers={timestamp_in_ms=1570626869268}, timestamp=Wed Oct 09 18:44:29 IST 2019, contentLength=0, receivedDeliveryMode=NON_PERSISTENT, redelivered=false, receivedExchange=, receivedRoutingKey=Q.CSW.ABCD_PRODORDER.XYZ, deliveryTag=1, consumerTag=amq.ctag-Kidy_yvO5xOLL6_7SyuzBw, consumerQueue=Q.CSW.ABCD_PRODORDER.XYZ])
18:44:29.704 [springListenerContainerCSWF_ORDER-1] INFO
com.dell.ctm.queue.rabbitmessaging.RabbitMQListener - Received message for consumer: salesOrderConsumer
1
8:44:29.704 [springListenerContainerABCD_ORDER-1] DEBUG com.dell.ctm.queue.rabbitmessaging.RabbitMQListener - Message :: Some Message
Message 2 Log:
DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Storing delivery for consumerTag: 'amq.ctag-LDAzqxJDNlI-zjXQz0iiiQ' with deliveryTag: '1' in Consumer#568eb60e: tags=[[amq.ctag-LDAzqxJDNlI-zjXQz0iiiQ]], channel=Cached Rabbit Channel: AMQChannel(amqp://poc#10.161.1.11:5672/POC,7), conn: Proxy#58651bd2 Shared Rabbit Connection: SimpleConnection#1576020a [delegate=amqp://poc#10.165.1.11:5672/POC, localPort= 61774], acknowledgeMode=AUTO local queue size=0
18:46:53.954 [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-1] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Received message: (Body:'[B#21865b3b(byte[16757])' MessageProperties [headers={timestamp_in_ms=1570627013570}, timestamp=Wed Oct 09 18:46:53 IST 2019, contentLength=0, receivedDeliveryMode=NON_PERSISTENT, redelivered=false, receivedExchange=, receivedRoutingKey=Q.CSW.ABCD_PRODORDER.XYZ, deliveryTag=1, consumerTag=amq.ctag-LDAzqxJDNlI-zjXQz0iiiQ, consumerQueue=Q.CSW.ABCD_PRODORDER.XYZ])
18:46:54.018 [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-1] DEBUG org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter - Processing [GenericMessage [payload=byte[16757], headers={amqp_receivedDeliveryMode=NON_PERSISTENT, amqp_receivedRoutingKey=Q.CSW.ABCD_PRODORDER.XYZ, timestamp_in_ms=1570627013570, amqp_deliveryTag=1, amqp_timestamp=Wed Oct 09 18:46:53 IST 2019, amqp_consumerQueue=Q.CSW.ABCD_PRODORDER.XYZ, amqp_redelivered=false, id=f55d83d9-88c0-6105-2d02-95e32ac5e57b, amqp_consumerTag=amq.ctag-LDAzqxJDNlI-zjXQz0iiiQ, timestamp=1570627014018}]]
18:46:54.034 [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-1] INFO com.dell.ctm.queue.rabbitmessaging.RabbitMQListener - Received message for consumer: null
18:46:54.034 [org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-1] DEBUG com.dell.ctm.queue.rabbitmessaging.RabbitMQListener - Message :: Some Message
This is my connection factory
<bean id="rabbitListenerContainerFactory"
class="org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory">
<property name="connectionFactory">
<ref bean="cachingConnectionFactory" />
</property>
<property name="concurrentConsumers" value="50" />
<property name="maxConcurrentConsumers" value="100" />
<property name="startConsumerMinInterval" value="3000" />
</bean>

Tomcat 7 clustering - session replication not working with spring boot and spring security

I have a problem regarding our Tomcat session replication configuration.
At our company, we are using Tomcat 7 servlet containers behind Apache HTTPD 2.4.6 configured for load balancing with mod_jk/tomcat-connectors 1.2.37 (running on CentOS 7 x64). Session replication is working with the Tomcat Manager, meaning if we kill one of our Tomcats after logging in to the HTML manager, we don't need to log in again (we have set it to be <distributable /> in the web.xml. We can see the servers are successfully discovering each other from the catalina.log:
2017.10.06 09:25:15 [INFO] org.apache.catalina.ha.tcp.SimpleTcpCluster memberAdded: Replication member added:org.apache.catalina.tribes.membership.StaticMember[tcp://10.35.217.77:4444,10.35.217.77,4444, alive=0, securePort=-1, UDP Port=-1, id={1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 }, payload={}, command={}, domain={100 101 108 116 97 45 115 116 97 ...(12)}, ]
2017.10.06 09:25:15 [INFO] org.apache.catalina.tribes.group.interceptors.TcpFailureDetector performBasicCheck: Suspect member, confirmed alive.[org.apache.catalina.tribes.membership.StaticMember[tcp://10.35.217.77:4444,10.35.217.77,4444, alive=0, securePort=-1, UDP Port=-1, id={1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 }, payload={}, command={}, domain={100 101 108 116 97 45 115 116 97 ...(12)}, ]]
However, when we deploy a sample Spring Boot application, and kill the Tomcat in which we authenticated a user, the login prompt appears again. We have been trying to resolve the issue for a long time and it's driving us crazy. What are we missing? The configuration is as follows:
Tomcat/context.xml:
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true" />
<ResourceLink name="jdbc/postgres" global="jdbc/postgres"
type="javax.sql.DataSource" />
</Context>
Tomcat/server.xml:
<Server port="8005" shutdown="SHUTDOWN" address="10.35.217.77">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<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/postgres" auth="Container" type="javax.sql.DataSource"
username="postgres" password=""
url="jdbc:postgresql://127.0.0.1:5432/postgres"
driverClassName="org.postgresql.Driver"
initialSize="5" maxWait="5000"
maxActive="120" maxIdle="5"
validationQuery="select 1"
poolPreparedStatements="true".
factory="org.apache.commons.dbcp.BasicDataSourceFactory" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector address="0.0.0.0" port="8080" protocol="HTTP/1.1"
connectionTimeout="30000" redirectPort="8443"
enableLookups="false" maxPostSize="20000"
executor="tcThreadPool" />
<Connector address="10.35.217.77" port="8009" protocol="AJP/1.3"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="cluster" jvmRoute="node1">
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="6" channelStartOptions="3">
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
autoBind="9" selectorTimeout="5000" maxThreads="6"
address="10.35.217.77" port="4444" />
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor" />
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector" />
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor" />
<Interceptor className="org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor">
<Member className="org.apache.catalina.tribes.membership.StaticMember" securePort="-1"
host="10.35.217.79" port="4444" domain="delta-static"
uniqueId="{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}" />
</Interceptor>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=".*\.gif;.*\.jpg;.*\.png;.*\.css" />
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" />
<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener" />
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener" />
</Cluster>
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="cluster" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix="log" rotatable="false"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
The other server.xml is similar, with the .77 and .79 IP adresses being switched (and of course the uniqueId is changed).
SpringBootApp/WebSecurityConfig.java
#Configuration
#EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private static final Logger logger = Logger.getLogger(WebSecurityConfig.class.getName());
#Bean
public UserDetailsContextMapperImpl contextMapper() {
return new UserDetailsContextMapperImpl();
}
#Autowired
PreferenceDao preferenceDao;
#Bean
public ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider(
preferenceDao.findByKey("ldap.domain").getValue(),
preferenceDao.findByKey("ldap.host").getValue()
);
logger.info("Connected to LDAP.");
provider.setConvertSubErrorCodesToExceptions(true);
provider.setUseAuthenticationRequestCredentials(true);
provider.setSearchFilter("(sAMAccountName={0})");
provider.setUserDetailsContextMapper(contextMapper());
return provider;
}
#Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user")
.password("s3cr3t")
.roles("USER");
}
protected void configure(HttpSecurity http) throws Exception {
http.
authorizeRequests()
.antMatchers("/css/**", "/js/**", "/img/**", "/font/**", "/", "/login?logout").permitAll()
.anyRequest().hasAuthority("ROLE_USER")
.and()
.formLogin().loginPage("/login").permitAll()
.and()
.logout().logoutSuccessUrl("/login?logout").permitAll();
}
protected class UserDetailsContextMapperImpl implements UserDetailsContextMapper, Serializable {
#Override
public UserDetails mapUserFromContext(DirContextOperations ctx, String username, Collection<? extends GrantedAuthority> authorities) {
List<GrantedAuthority> mappedAuthorities = new ArrayList<>();
mappedAuthorities.add(new SimpleGrantedAuthority("ROLE_USER"));
return new User(username, "", true, true, true, true, mappedAuthorities);
}
#Override
public void mapUserToContext(UserDetails user, DirContextAdapter ctx) {
//do nothing
}
}
}
Any help would be greatly appreciated.
Seems like I've finally solved it. One of the machines in the cluster was running a previous version of Tomcat. After I've upgraded it from v7.0.54 to v7.0.69 (also updating java), everything works fine.

JTDS deployment into Fuse

I'm having some difficulty registering a JDBC driver, JTDS, into FUSE.
routes.xml
<bean id="myDS" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://?????;databaseName=?????;tds=8.0;lastupdatecount=true" />
<property name="username" value="fuser" />
<property name="password" value="fuser" />
</bean>
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>rest.proxy</Bundle-SymbolicName>
<Require-Bundle>org.apache.cxf.bundle,org.apache.camel.camel-cxf,org.springframework.beans</Require-Bundle>
<Import-Package>net.sourceforge.jtds.jdbc,*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
Fuse commands run to install drivers;
osgi:install -s wrap:mvn:net.sourceforge/jtds/1.3.1
osgi:install -s wrap:mvn:jcifs/jcifs/1.3.17
If I show exports for jtds I get:
JBossFuse:karaf#root> osgi:headers 278
wrap_mvn_net.sourceforge_jtds_1.3.1 (278)
Main-Class = net.sourceforge.jtds.jdbc.Driver
Specification-Title = JDBC
Tool = Bnd-0.0.357
Specification-Version = 3.0
Implementation-Version = 1.3.1
Generated-By-Ops4j-Pax-From = wrap:mvn:net.sourceforge/jtds/1.3.1
Created-By = 1.7.0_25 (Oracle Corporation)
Implementation-Title = jTDS JDBC Driver
Manifest-Version = 1.0
Bnd-LastModified = 1381480171800
Implementation-URL = http://jtds.sourceforge.net
Originally-Created-By = 1.7.0_21-b11 (Oracle Corporation)
Ant-Version = Apache Ant 1.8.2
Bundle-Name = wrap_mvn_net.sourceforge_jtds_1.3.1
Bundle-SymbolicName = wrap_mvn_net.sourceforge_jtds_1.3.1
Bundle-Version = 0
Bundle-ManifestVersion = 2
Import-Package =
javax.crypto;resolution:=optional,
javax.crypto.spec;resolution:=optional,
javax.naming;resolution:=optional,
javax.naming.spi;resolution:=optional,
javax.net;resolution:=optional,
javax.net.ssl;resolution:=optional,
javax.sql;resolution:=optional,
javax.transaction.xa;resolution:=optional,
jcifs;resolution:=optional,
jcifs.smb;resolution:=optional,
net.sourceforge.jtds.jdbc;resolution:=optional,
net.sourceforge.jtds.jdbc.cache;resolution:=optional,
net.sourceforge.jtds.jdbcx;resolution:=optional,
net.sourceforge.jtds.jdbcx.proxy;resolution:=optional,
net.sourceforge.jtds.ssl;resolution:=optional,
net.sourceforge.jtds.util;resolution:=optional,
org.ietf.jgss;resolution:=optional
Export-Package =
**net.sourceforge.jtds.jdbc**;
uses:="net.sourceforge.jtds.util,
net.sourceforge.jtds.jdbc.cache,
jcifs.smb,
jcifs,
javax.net,
net.sourceforge.jtds.ssl,
org.ietf.jgss,
net.sourceforge.jtds.jdbcx,
javax.transaction.xa",
net.sourceforge.jtds.jdbc.cache;uses:=net.sourceforge.jtds.jdbc,
net.sourceforge.jtds.jdbcx;
uses:="javax.naming,
javax.sql,
net.sourceforge.jtds.util,
net.sourceforge.jtds.jdbc,
javax.naming.spi,
javax.transaction.xa,
net.sourceforge.jtds.jdbcx.proxy",
net.sourceforge.jtds.jdbcx.proxy;uses:="net.sourceforge.jtds.jdbc,net.sourceforge.jtds.jdbcx",
net.sourceforge.jtds.ssl;uses:="javax.net.ssl,javax.net,net.sourceforge.jtds.util",
net.sourceforge.jtds.util;uses:="net.sourceforge.jtds.jdbc,javax.crypto.spec,javax.crypto"
And for JCIFS, which is required by JTDS
JBossFuse:karaf#root> osgi:headers 283
wrap_mvn_jcifs_jcifs_1.3.17 (283)
Manifest-Version = 1.0
Bnd-LastModified = 1381486791455
Archiver-Version = Plexus Archiver
Tool = Bnd-0.0.357
Originally-Created-By = Apache Maven
Built-By = ajvanerp
Generated-By-Ops4j-Pax-From = wrap:mvn:jcifs/jcifs/1.3.17
Build-Jdk = 1.6.0_29
Created-By = 1.7.0_25 (Oracle Corporation)
Bundle-Name = wrap_mvn_jcifs_jcifs_1.3.17
Bundle-SymbolicName = wrap_mvn_jcifs_jcifs_1.3.17
Bundle-Version = 0
Bundle-ManifestVersion = 2
Import-Package =
javax.servlet;resolution:=optional,
javax.servlet.http;resolution:=optional,
jcifs;resolution:=optional,
jcifs.dcerpc;resolution:=optional,
jcifs.dcerpc.msrpc;resolution:=optional,
jcifs.dcerpc.ndr;resolution:=optional,
jcifs.http;resolution:=optional,
jcifs.https;resolution:=optional,
jcifs.netbios;resolution:=optional,
jcifs.ntlmssp;resolution:=optional,
jcifs.smb;resolution:=optional,
jcifs.util;resolution:=optional,
jcifs.util.transport;resolution:=optional
Export-Package =
jcifs;uses:="jcifs.util,jcifs.netbios",
jcifs.dcerpc;uses:="jcifs.util,jcifs.dcerpc.ndr,jcifs.dcerpc.msrpc,jcifs.smb",
jcifs.dcerpc.msrpc;uses:="jcifs.smb,jcifs.dcerpc,jcifs.dcerpc.ndr",
jcifs.dcerpc.ndr;uses:=jcifs.util,
jcifs.http;uses:="javax.servlet,jcifs.util,jcifs.smb,jcifs,jcifs.netbios,javax.servlet.http,jcifs.ntlmssp",
jcifs.https;uses:=jcifs.http,
jcifs.netbios;uses:="jcifs.util,jcifs.smb,jcifs",
jcifs.ntlmssp;uses:="jcifs,jcifs.util,jcifs.netbios,jcifs.smb",
jcifs.smb;uses:="jcifs.util,jcifs,jcifs.ntlmssp,jcifs.dcerpc.msrpc,jcifs.dcerpc.ndr,jcifs.dcerpc,jcifs.util.transport,jcifs.netbios",
jcifs.util,
jcifs.util.transport;uses:=jcifs.util
Now, for my bundle that I have deployed I have listed the imports, (I've hightlighted the import of JTDS, so, this has come from the POM setting):
JBossFuse:karaf#root> packages:imports 282
System Bundle (0): javax.xml.bind.annotation; version=2.2.1
Spring Beans (105): org.springframework.beans; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.annotation; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory.access; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory.access.el; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory.annotation; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory.config; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory.parsing; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory.serviceloader; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory.support; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory.wiring; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.factory.xml; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.propertyeditors; version=3.1.3.RELEASE
Spring Beans (105): org.springframework.beans.support; version=3.1.3.RELEASE
activemq-osgi (114): org.apache.activemq.camel.component; version=5.8.0.redhat-60024
camel-core (130): org.apache.camel; version=2.10.0.redhat-60024
Apache ServiceMix :: Specs :: JSR-311 API 1.1.1 (145): javax.ws.rs; version=1.1.1
camel-cxf (194): org.apache.camel.component.cxf; version=2.10.0.redhat-60024
camel-cxf (194): org.apache.camel.component.cxf.blueprint; version=2.10.0.redhat-60024
camel-cxf (194): org.apache.camel.component.cxf.converter; version=2.10.0.redhat-60024
camel-cxf (194): org.apache.camel.component.cxf.cxfbean; version=2.10.0.redhat-60024
camel-cxf (194): org.apache.camel.component.cxf.feature; version=2.10.0.redhat-60024
camel-cxf (194): org.apache.camel.component.cxf.interceptors; version=2.10.0.redhat-60024
camel-cxf (194): org.apache.camel.component.cxf.jaxrs; version=2.10.0.redhat-60024
camel-cxf (194): org.apache.camel.component.cxf.spring; version=2.10.0.redhat-60024
camel-cxf (194): org.apache.camel.component.cxf.util; version=2.10.0.redhat-60024
Spring JDBC (244): org.springframework.jdbc.datasource; version=3.1.3.RELEASE
camel-sql (245): org.apache.camel.component.sql; version=2.10.0.redhat-60024
**wrap_mvn_net.sourceforge_jtds_1.3.1 (278): net.sourceforge.jtds.jdbc; version=0.0.0**
My bundle deploys fine:
[ 282] [Active ] [ ] [Started] [ 60] rest.proxy (0.0.1.SNAPSHOT)
But when I hit the rest proxy exposed by Camel (JAX-RS consumer) it has to make a a database lookup. I get this error:
Caused by: java.sql.SQLException: No suitable driver found for jdbc:jtds:sqlserver://?????;databaseName=?????;tds=8.0;lastupdatecount=true
Now, I'm no expert on OSGI, having used it in the past a little for not for a while. I cannot see anything obvious to what I'm doing wrong.
I've gone through some earlier errors and fixed them by making sure the JARs export the right packages, and the Import package is put in on my Bundle.
Any help much appreciated.
You may find it easier to instantiate the JTDS data source directly within a spring bean.
A quick example of this is available here http://fusesource.com/forums/thread.jspa?threadID=1682
It is definitely possible to run JTDS 1.2x and bonecp, useful for for connection pooling

Spring3.0 Autowired null

I am doing with Spring #MVC3 and I've got a problem. Spring beans are created, but #Autowired doesn't work in a class. Here is my setting and source code:
xxx-servlet-.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="com.lodestone.ccah.controller"/>
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
</beans>
beans.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:website.properties" />
</bean>
<bean id="contextApplicationContextProvider" class="com.lodestone.ccah.util.ApplicationContextProvider"></bean>
<bean id="staticVars" class="com.lodestone.ccah.util.StaticVars">
<property name="awsServerIp" value="${website.AWSServerIP}" />
<property name="timeOutConnection" value="${website.timeOutConnection}" />
<property name="timeOutReceive" value="${website.timeOutReceive}" />
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="${db.url}?useJDBCCompliantTimezoneShift=true" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
<property name="maxIdle" value="10" />
<property name="maxActive" value="100" />
<property name="maxWait" value="10000" />
<property name="validationQuery" value="select 1" />
<property name="testOnBorrow" value="false" />
<property name="testWhileIdle" value="true" />
<property name="timeBetweenEvictionRunsMillis" value="1200000" />
<property name="minEvictableIdleTimeMillis" value="1800000" />
<property name="numTestsPerEvictionRun" value="5" />
<property name="defaultAutoCommit" value="true" />
</bean>
<!-- DAO settings -->
<bean id="mediaDao" class="com.lodestone.ccah.dao.MediaDao">
<!--<property name="dataSource" ref="dataSource"></property>-->
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"></property>
</bean>
<bean id="mediaService" class="com.lodestone.ccah.service.MediaService"></bean>
</beans>
Tomcat Log:
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Thu Mar 08 13:21:49 EST 2012]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [beans.xml]
DEBUG: org.springframework.beans.factory.xml.DefaultDocumentLoader - Using JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl]
DEBUG: org.springframework.beans.factory.xml.PluggableSchemaResolver - Loading schema mappings from [META-INF/spring.schemas]
DEBUG: org.springframework.beans.factory.xml.PluggableSchemaResolver - Loaded schema mappings: {http://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd, http://www.springframework.org/schema/jms/spring-jms-2.5.xsd=org/springframework/jms/config/spring-jms-2.5.xsd, http://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd, http://cxf.apache.org/schemas/configuration/http-conf.xsd=schemas/configuration/http-conf.xsd, http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd=schemas/xmldsig-core-schema.xsd, http://www.springframework.org/schema/security/spring-security-3.0.3.xsd=org/springframework/security/config/spring-security-3.0.3.xsd, http://www.springframework.org/schema/security/spring-security-2.0.1.xsd=org/springframework/security/config/spring-security-2.0.1.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd, http://www.w3.org/2006/07/ws-policy.xsd=schemas/ws-policy-200607.xsd, http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd=org/springframework/oxm/config/spring-oxm-3.0.xsd, http://cxf.apache.org/schemas/jaxrs.xsd=schemas/jaxrs.xsd, http://cxf.apache.org/schemas/configuration/wsrm-manager.xsd=schemas/configuration/wsrm-manager.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.0.xsd, http://schemas.xmlsoap.org/ws/2004/08/addressing=schemas/wsdl/addressing.xsd, http://www.springframework.org/schema/security/spring-security-2.0.xsd=org/springframework/security/config/spring-security-2.0.xsd, http://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd, http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd=schemas/oasis-200401-wss-wssecurity-secext-1.0.xsd, http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd, http://schemas.xmlsoap.org/wsdl/=schemas/wsdl/wsdl.xsd, http://cxf.apache.org/schemas/bindings/object.xsd=schemas/bindings/object.xsd, http://www.springframework.org/schema/mvc/spring-mvc.xsd=org/springframework/web/servlet/config/spring-mvc-3.0.xsd, http://www.springframework.org/schema/flex/spring-flex-1.0.xsd=org/springframework/flex/config/xml/spring-flex-1.0.xsd, http://cxf.apache.org/schemas/configuration/jms.xsd=schemas/configuration/jms.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd=org/springframework/jdbc/config/spring-jdbc-3.0.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc.xsd=org/springframework/jdbc/config/spring-jdbc-3.0.xsd, http://cxf.apache.org/schemas/configuration/http-jetty.xsd=schemas/configuration/http-jetty.xsd, http://schemas.xmlsoap.org/wsdl/http/=schemas/wsdl/http.xsd, http://cxf.apache.org/schemas/wsdl/jms.xsd=schemas/wsdl/jms.xsd, http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd=schemas/oasis-200401-wss-wssecurity-utility-1.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd, http://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd, http://schemas.xmlsoap.org/ws/2005/02/rm/wsrm-policy.xsd=schemas/configuration/wsrm-policy.xsd, http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd=org/springframework/web/servlet/config/spring-mvc-3.0.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd, http://www.springframework.org/schema/security/spring-security-2.0.4.xsd=org/springframework/security/config/spring-security-2.0.4.xsd, http://www.springframework.org/schema/lang/spring-lang-3.0.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd, http://schemas.xmlsoap.org/wsdl/2003-02-11.xsd=schemas/wsdl/wsdl.xsd, http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://cxf.apache.org/schemas/ws/addressing.xsd=schemas/ws-addr-conf.xsd, http://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd, http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd, http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd, http://cxf.apache.org/schemas/wsdl/http-conf.xsd=schemas/wsdl/http-conf.xsd, http://www.w3.org/2001/xml.xsd=schemas/xml.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd, http://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd, http://www.springframework.org/schema/jms/spring-jms.xsd=org/springframework/jms/config/spring-jms-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/oxm/spring-oxm.xsd=org/springframework/oxm/config/spring-oxm-3.0.xsd, http://www.w3.org/2007/02/ws-policy.xsd=schemas/ws-policy-200702.xsd, http://www.springframework.org/schema/task/spring-task.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx-3.0.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://cxf.apache.org/schemas/policy.xsd=schemas/policy.xsd, http://schemas.xmlsoap.org/ws/2004/09/policy/ws-policy.xsd=schemas/ws-policy-200409.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://cxf.apache.org/schemas/configuration/cxf-beans.xsd=schemas/configuration/cxf-beans.xsd, http://www.springframework.org/schema/task/spring-task-3.0.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd, http://cxf.apache.org/schemas/core.xsd=schemas/core.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd, http://www.springframework.org/schema/jms/spring-jms-3.0.xsd=org/springframework/jms/config/spring-jms-3.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://cxf.apache.org/schemas/configuration/security.xsd=schemas/configuration/security.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd, http://www.springframework.org/schema/security/spring-security-3.0.4.xsd=org/springframework/security/config/spring-security-3.0.4.xsd, http://cxf.apache.org/schemas/configuration/soap.xsd=schemas/configuration/soap.xsd, http://www.springframework.org/schema/security/spring-security-2.0.2.xsd=org/springframework/security/config/spring-security-2.0.2.xsd, http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd, http://cxf.apache.org/schemas/jaxws.xsd=schemas/jaxws.xsd, http://cxf.apache.org/schemas/simple.xsd=schemas/simple.xsd, http://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-3.0.4.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/security/spring-security-3.0.xsd=org/springframework/security/config/spring-security-3.0.xsd, http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd=org/directwebremoting/spring/spring-dwr-2.0.xsd, http://cxf.apache.org/schemas/configuration/wsrm-manager-types.xsd=schemas/configuration/wsrm-manager-types.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.0.xsd}
DEBUG: org.springframework.beans.factory.xml.PluggableSchemaResolver - Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.0.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.0.xsd
DEBUG: org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader - Loading bean definitions
DEBUG: org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loaded 7 bean definitions from location pattern [classpath:beans.xml]
DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Bean factory for Root WebApplicationContext: org.springframework.beans.factory.support.DefaultListableBeanFactory#70d9cc1a: defining beans [propertyConfigurer,contextApplicationContextProvider,staticVars,dataSource,mediaDao,jdbcTemplate,mediaService]; root of factory hierarchy
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'propertyConfigurer'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'propertyConfigurer'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'propertyConfigurer' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'propertyConfigurer'
INFO : org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from class path resource [website.properties]
DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource#b56efe]
DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster#789e60f]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#70d9cc1a: defining beans [propertyConfigurer,contextApplicationContextProvider,staticVars,dataSource,mediaDao,jdbcTemplate,mediaService]; root of factory hierarchy
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'propertyConfigurer'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'contextApplicationContextProvider'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'contextApplicationContextProvider'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'contextApplicationContextProvider' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'contextApplicationContextProvider'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'staticVars'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'staticVars'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'staticVars' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'staticVars'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'dataSource'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'dataSource'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'dataSource' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'dataSource'
**DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'mediaDao'**
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'mediaDao'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'mediaDao' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'mediaDao'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'jdbcTemplate'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'jdbcTemplate'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'jdbcTemplate' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'dataSource'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'jdbcTemplate'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'jdbcTemplate'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'mediaService'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'mediaService'
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'mediaService' to allow for resolving potential circular references
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'mediaService'
DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor#29d03e78]
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor'
DEBUG: org.springframework.web.context.ContextLoader - Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 393 ms
Mar 8, 2012 1:21:49 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 8, 2012 1:21:49 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Mar 8, 2012 1:21:49 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16 config=null
Mar 8, 2012 1:21:49 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3687 ms
The problem bean is mediaDao. But it is created in the Spring container. And here is the Java source the issue is happening.
NoteService.java:
public class MediaService {
#Autowired private MediaDao mediaDao;
private static final Logger logger = Logger.getLogger("NoteDao");
/**
* #param note
* #return
*/
public long addNote(Note note) {
logger.info(" MediaService.addNote starts");
long insertedId = -1;
try {
insertedId = mediaDao.add(note);
} catch (SQLException e) {
logger.error(e);
}
logger.info(" MediaService.addNote ends");
return insertedId;
}
}
The mediaDao is null but other Java sources with #Autowired are OK. I don't know what is missing?
My thought is, have you annotated the service with #Service annotation, if not then spring does not recognize that as spring managed class and it may not inject the DAO for you. Either it should Service or Component annotated. Also as told by Dave check the package whether the package is scanned by spring context or not. You have given the component scan for controller package. I am not sure whether the MediaService is also placed in the same package. Just check all these factors.
You're not scanning the package of the class, so the annotation will be ignored. Add its package to a component scan element as you're already doing for the controller package.
The following is the correct form.
#Autowired private MediaDaoInterface mediaDaoInt;

seam with tomcat "entityManager is null"

I have a problem when deploying seam with tomcat. I get this error :
Caused by: java.lang.IllegalStateException: entityManager is null
at org.jboss.seam.framework.EntityQuery.validate(EntityQuery.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
.......................................
Here are my details. I have followed all the details from jboss seam jpa example :
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_1_0.xsd"
version="1.0">
<persistence-unit name="bookingDatabase">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:comp/env/jdbc/TestDB</non-jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
</properties>
</persistence-unit>
</persistence>
This is my component.xml. I think there is no problem with it.
components.xml
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:persistence="http://jboss.com/products/seam/persistence"
xmlns:drools="http://jboss.com/products/seam/drools"
xmlns:bpm="http://jboss.com/products/seam/bpm"
xmlns:security="http://jboss.com/products/seam/security"
xmlns:mail="http://jboss.com/products/seam/mail"
xmlns:web="http://jboss.com/products/seam/web"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://jboss.com/products/seam/cache"
xmlns:async="http://jboss.com/products/seam/async"
xmlns:transaction="http://jboss.com/products/seam/transaction"
xsi:schemaLocation=
"http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd
http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd
http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.2.xsd
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.2.xsd
http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.2.xsd
http://jboss.com/products/seam/cache http://jboss.com/products/seam/cache-2.2.xsd
http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.2.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd
http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.0.xsd ">
<core:manager concurrent-request-timeout="500"
conversation-timeout="120000"
conversation-id-parameter="cid"
parent-conversation-id-parameter="pid"/>
<transaction:entity-transaction entity-manager="#{em}"/>
<persistence:entity-manager-factory name="bookingDatabase"/>
<persistence:managed-persistence-context name="em"
auto-create="true"
entity-manager-factory="#{bookingDatabase}"/>
<security:identity authenticate-method="#{authenticator.authenticate}"/>
<async:quartz-dispatcher/>
<cache:eh-cache-provider name="cacheProvider" auto-create="true"/>
<!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
<web:hot-deploy-filter url-pattern="*.seam"/>
<drools:rule-base name="securityRules">
<drools:rule-files>
<value>/security.drl</value>
</drools:rule-files>
</drools:rule-base>
<security:rule-based-permission-resolver security-rules="#{securityRules}"/>
<security:jpa-identity-store
user-class="org.domain.simpopanpa.entity.UserAccount"
role-class="org.domain.simpopanpa.entity.UserRole"/>
<security:jpa-permission-store
user-permission-class="org.domain.simpopanpa.entity.UserPermission"/>
<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
</event>
<event type="org.jboss.seam.security.loginSuccessful">
<action execute="#{redirect.returnToCapturedView}"/>
</event>
<mail:mail-session host="localhost" port="25"/>
</components>
I have added the context.xml file as described in some forums.
context.xml
<Context path="/someName" docBase="someName"
debug="5" reloadable="true" crossContext="true">
<Resource auth="Container"
name="jdbc/TestDB"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#127.0.0.1:1521:db11g"
username="user"
password="pass"
maxActive="100"
maxIdle="30"
maxWait="10000"/>
</Context>
I use tomcat 7 and jboss seam 2.2.1
You named the persistence context 'em'. The entityquery is per default trying to fetch it by 'entitymanager'. So either change the name in your components.xml or you have to call entityquery.setPersistenceContextName("em").

Resources