[Microcontainer] - Re: Acessing Microcontainer Beans in Servlet
by obelix1998
This simply does not work :( There is not a single example to be found, how to access the beans defined in jboss-beans.xml from JAVA and I tried many things, none of which is working. It doesn't seem to me such an unusual idea to define beans in the xml and then use these instances within the java code (in my case a servlet). Could you please provide one WORKING example how this really works ?!!!
I defined this in jboss-beans.xml:
<bean name="surferCookieHandler" class="net.pelvit.tracker.jar.imp.SurferCookieHandler">
| </bean>
I added this jboss-app.xml (tracker.beans is my "jar"):
<jboss-app>
| <module>
| <service>tracker.beans</service>
| </module>
| </jboss-app>
The in the code I used the following (as suggested by you):
BasicBootstrap bootstrap;
| bootstrap = new BasicBootstrap();
| bootstrap.run();
| Object target = bootstrap.getKernel().getController().getInstalledContext("surferCookieHandler").getTarget();
|
Please give an example, how to really make this work because as it is, it simply doesn't and I'm beginning to think, I'm wasting my time on this microcontainer :-(
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033927#4033927
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033927
19 years
[JBoss Portal] - error while connecting to oracle db
by vikas01
this is my portal-oracle-ds.xml file
<local-tx-datasource>
<jndi-name>DatabaseConnection</jndi-name>
<connection-url>jdbc:oracle:thin:@localhost:1521:orcl</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>scott</user-name>
tiger
<min-pool-size>1</min-pool-size>
<max-pool-size>10</max-pool-size>
</local-tx-datasource>
i have stored this file in deploy directory
following is the java file which tries to acces the db
public class HelloVikas extends GenericPortlet
{
protected void doView(RenderRequest rRequest, RenderResponse rResponse)
throws IOException, PortletException
{
rResponse.setContentType("text/html");
PrintWriter out = rResponse.getWriter();
out.write("hello mr vikas nahar");
out.close();
try
{
System.out.println("connecting to database");
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("DatabaseConnection");
System.out.println("connected to.....................................");
}
catch (Exception e)
{
System.out.println(e);
}
}
};
and i get the following error:
javax.naming.NameNotFoundException: DatabaseConnection not bound
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033921#4033921
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033921
19 years