[EJB 3.0] - more than one, OneToOne relation gives problem
by thiagu.m
This is my bean class structure
| @Entity
| @Table(name="TBL_PRODUCTS")
| public class TblProducts implements Serializable
| {
| @Id
| @Column(name="PRODUCT_ID")
| private BigDecimal productId;
|
| @Column(name="PRODUCT_NAME")
| private String productName;
|
| @JoinColumn(name="BRAND_NAME")
| private String brandname;
|
| @OneToOne(fetch=FetchType.LAZY,mappedBy="tblProducts")
| private TblCellphone tblCellphone;
|
| @OneToOne(fetch=FetchType.LAZY,mappedBy="tblProducts")
| private TblTelevision tblTelevision;
|
| }
| -------------------------------------------------
| @Entity
| @Table(name="TBL_CELLPHONE")
| public class TblCellphone implements Serializable
| {
| @Id
| @Column(name="PRODUCT_ID")
| private BigDecimal productId;
|
| private String camera;
|
| . . .
|
| @OneToOne(optional=false)
| @JoinColumn(name="PRODUCT_ID")
| private TblProducts tblProducts;
| }
| ----------------------------------------
| @Entity
| @Table(name="TBL_TELEVISION")
| public class TblTelevision implements Serializable
| {
| @Id
| @Column(name="PRODUCT_ID")
| private BigDecimal productId;
|
| @Column(name="SCREEN_SIZE")
| private String screenSize;
|
| . . .
|
| @OneToOne(optional=false)
| @JoinColumn(name="PRODUCT_ID")
| private TblProducts tblProducts;
| }
|
|
|
Here Tblproduct is my main table , I need to make a relation with all other subcategory products table.
But when I try to add the more than one OneToOne relation within product table it gives following error
| java.lang.NullPointerException at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:135) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126) at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246) 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)
is there any help how to overcome this problem
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119299#4119299
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119299
18 years, 6 months
[EJB 3.0] - @Service + @Managment + @SecurityDomain throws Authorization
by sappenin
I have a secured EJB3 @Service bean as follows:
| @Service
| @Management(MyClassInterfaceManagement.class)
| @Local(MyClassInterface.class)
| @SecurityDomain("myrealm")
| @RolesAllowed( {
| "admin", "system"
| })
| @RunAs("system")
| public class MyClass implements MyClassInterface, MyClassInterfaceManagement
| { ... }
|
|
I have the proper things setup in my login-conf.xml file, but when I deploy this class, I get an exception stating:
| 21:11:05,887 WARN [ServiceController] Problem creating service jboss.j2ee:ear=MyEar.ear,jar=MyJar.jar,name=MyClass,service=EJB3,type=ManagementInterface
| javax.ejb.EJBAccessException: Authorization failure
| at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:113)
|
What's wierd is that I can comment out the "@SecurityDomain("mydomain")" annotation, and I don't receive the exception when I start the server, and everything works fine. This seems like a bug, although I'm not sure. Any Idea what is going on?
My assumption is that by commenting out the @SecurityDomain annotation, the Management/Service is defaulting to the security domain specified in my jboss-app.xml file in my ear, which says:
|
| <jboss-app>
| <security-domain>myrealm</security-domain>
| .....
| </jboss-app>
|
|
The applicable login-conf.xml snippets are below. Thoughts?
|
| <application-policy name = "myrealm">
| <authentication>
| <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
| <module-option name = "dsJndiName">java:/myDS</module-option>
| <module-option name = "principalsQuery">select PASSWORD from SYSTEM_USER where USER_ID=?</module-option>
| <module-option name = "rolesQuery">select SYSTEM_USER_ROLE.ROLE_NAME, 'Roles' from SYSTEM_USER_ROLE, SYSTEM_USER_SYSTEM_USER_ROLE, SYSTEM_USER where ((SYSTEM_USER_SYSTEM_USER_ROLE.ROLES_ID = SYSTEM_USER_ROLE.ID) and (SYSTEM_USER_SYSTEM_USER_ROLE.USERS_ID = SYSTEM_USER.ID) AND (SYSTEM_USER.USER_ID = ?))
| </module-option>
| <module-option name = "unauthenticatedIdentity">guest</module-option>
| </login-module>
| <!-- Add this line to your login-config.xml to include the ClientLoginModule propogation -->
| <login-module code="org.jboss.security.ClientLoginModule" flag="required" />
| </authentication>
|
|
|
| <application-policy name = "other">
| <authentication>
| <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
| <module-option name = "dsJndiName">java:/myDS</module-option>
| <module-option name = "principalsQuery">select PASSWORD from SYSTEM_USER where USER_ID=?</module-option>
| <module-option name = "rolesQuery">select SYSTEM_USER_ROLE.ROLE_NAME, 'Roles' from SYSTEM_USER_ROLE, SYSTEM_USER_SYSTEM_USER_ROLE, SYSTEM_USER where ((SYSTEM_USER_SYSTEM_USER_ROLE.ROLES_ID = SYSTEM_USER_ROLE.ID) and (SYSTEM_USER_SYSTEM_USER_ROLE.USERS_ID = SYSTEM_USER.ID) AND (SYSTEM_USER.USER_ID = ?))
| </module-option>
| <module-option name = "unauthenticatedIdentity">guest</module-option>
| </login-module>
| </authentication>
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119296#4119296
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119296
18 years, 6 months
[Persistence, JBoss/CMP, Hibernate, Database] - @ManyToOne uses eager fetching even if FetchType.LAZY used
by jfrankman
I have a many one to relationship and when I run a query to fetch the objects selected in the query, the related objects are still fetched even though the FetchType is lazy. Here are the mappings:
PolicyVO class maps to the FBWorker class:
public class PolicyVO implements Serializable
| {
| @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name = "AGENT", nullable = true, referencedColumnName="AGENTNO" )
| public FBWorker getAgent() {
| return agent;
| }
| }FBWorker class maps to the PolicyVO class:
public class FBWorker implements Serializable
| {
| @Id @Column(name="ID")
| public Long getId()
| {
| return id;
| }
|
| @OneToMany(fetch=FetchType.LAZY,mappedBy="agent")
| public List<PolicyVO> getAgentPolicies()
| {
| return agentPolicies;
| }
| }
Then I run the following JPA query:
select policy from PolicyVO policy
Watching the logs I see that first a query is run that selects the policy data from the database. Then, after the query is complete a query to the FBWorker table is generated and ran for every single policy object. Of course, this is unacceptable. I thought that if FetchType.Lazy is specified that the related class would not be loaded until the accessor method is called. Is there something wrong with the above mappings that makes lazy fetching impossible? I just need to fetch the PolicyVO objects without the extra overhead of fetching the related FBWorker objects.
I should also mention that the "agent" foreign key in the PolicyVO data does not map to the Primary Key of the FBWorker data, it only maps to a field (agentno) that is also unique. I know this is sloppy, but I am dealing with some legacy data here.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119290#4119290
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119290
18 years, 6 months
[JBossWS] - Re: More soap:address problems
by alessio.soldano@jboss.com
"justinkwaugh" wrote : I glanced at the code, and it plainly just ignores the incoming request protocol. Why is this? If I am accessing it via an https:// URL, why would it not rewrite it using https://?
|
You might want to create a JIRA issue for this.
anonymous wrote :
| 2. The path to the endpoint is plain wrong.
|
| I have a context root specified in the jboss-web.xml of my war, and that is all it uses no matter what. It simply ignores the servlet name and rewrites the path with just the context-root even when I specify my own WSDL in the @WebService annotation. My servlet is specified in the web.xml as follows..
|
|
| | <servlet>
| | <servlet-name>MyWebservice</servlet-name>
| | <servlet-class>com.mycompany.webservices.MyWebservice</servlet-class>
| | </servlet>
| | <servlet-mapping>
| | <servlet-name>MyWebservice</servlet-name>
| | <url-pattern>/*</url-pattern>
| | </servlet-mapping>
| |
|
| My jboss-web.xml has the following:
|
|
| | <jboss-web>
| | <context-root>webservice</context-root>
| | </jboss-web>
| |
|
| The correct endpoint should be
| https://myhost:443/webservice/MyWebservice
|
| but no matter what I do, it rewrites it to just
| https://myhost:443/webservice
|
This is the right behaviour IMHO. You should use this to get the path /webservice/MyWebservice:
| <servlet>
| <servlet-name>MyWebservice</servlet-name>
| <servlet-class>com.mycompany.webservices.MyWebservice</servlet-class>
| </servlet>
| <servlet-mapping>
| <servlet-name>MyWebservice</servlet-name>
| <url-pattern>/MyWebservice</url-pattern>
| </servlet-mapping>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119284#4119284
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119284
18 years, 6 months
[JBossWS] - Cannot access web service with HTTP Basic Authentication ena
by jeff norton
I'm running JBoss 4.2 with the latest jbossws libraries. I have a simple web service running and I wanted to secure it with HTTP Basic Authentication (actually anything would do but that seemed the simplest). I followed the steps in http://jbws.dyndns.org/mediawiki/index.php?title=Authentication, but now my client gets an error when creating the service (this is before setting the username and password using the BindingProvider -- but you need the service object on which to do that -- perhaps a chicken/egg problem?)
service = Service.create(wsdlURL, new QName(...));
Now gets:
[exec] org.jboss.ws.metadata.wsdl.WSDLException: Cannot parse wsdlLocation: http://localhost:8080/resonantProcessLibrary?wsdl
| [exec] at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.getDocument(WSDLDefinitionsFactory.java:183)
| [exec] at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsFactory.java:108)
| [exec] at org.jboss.ws.metadata.umdm.ServiceMetaData.getWsdlDefinitions(ServiceMetaData.java:321)
| [exec] at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildMetaData(JAXWSClientMetaDataBuilder.java:85)
| [exec] at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.<init>(ServiceDelegateImpl.java:132)
| [exec] at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:63)
| [exec] at javax.xml.ws.Service.<init>(Service.java:82)
| [exec] at javax.xml.ws.Service.create(Service.java:334)
| [exec] at com.resonant.processlibrary.api.RemoteDocumentRepository.<init>(RemoteDocumentRepository.java:77)
When I try to access the wsdl in a browser using the wsdlURL I get the username/password challenge and after entering the correct credentials I get the WSDL so things seems to be working on the server end. Just cannot get the client to connect. It sort of seems like the username/password are needed to get the WSDL to seup the service but there is no way to provide the username/password until the service is setup. But that's what the example says to do and my code is following it exactly.
One other tidbit. When I use my .Net client to access the webservice I get a 401 (unauthorized) as expected, but when I modify the .NET client to add the credential I then get a 505 (HTTP protocal not supported).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119270#4119270
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119270
18 years, 6 months
[JBoss Seam] - @DataModelSelection Is Update When @Factory Method Gets Call
by elvisisking
I'm writing a very simple Web application and trying to use POJOs instead of SBs. I have a page that displays a parent object and it's children. The children's names are displayed in the cells of a datatable. Each child has an associated SEAM link that is used to redisplay the current page but now using the child as the parent. When I click the child link the page does redisplay but since the @DataModelSelection value is always set to the first child in the collection the wrong child is displayed (unless I click on the first child:-). I've verified that the @DataModelSelection is only updated when the @Factory method is called. See code (modified for simplicity) below. Thanks much for your help.
xhtml code:
<rich:dataTable
value="#{pojo.kids}"
var="child">
<rich:column>
<f:facet name="header">
<h:outputText
styleClass="tableHeaderText"
value="Child Name" />
</f:facet>
<s:link
action="#{pojo.viewChild}"
value="#{child.name}">
</s:link>
</rich:column>
</rich:dataTable>
pojo code:
@Name( "pojo" )
@Scope( ScopeType.SESSION )
public class Pojo implements Serializable {
@Out
@DataModelSelection( "kids" )
private Node child;
private Node node;
@DataModel
private List kids;
@Factory( "kids" )
public List getNodeChildren() throws Exception {
this.kids = this.node.getChildren();
return this.kids;
}
public String viewChild() throws Exception {
this.node = this.child;
return "view";
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119267#4119267
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119267
18 years, 6 months
[JBoss Seam] - Re: Developing with Seam 2 and deploying on WebSphere
by gduq
Other than switching out the entitymanager, which I had to do for the JPA example to work anyway. Heres what I had to do (or at least what I can remember):
| * Copy sources, resources(resources-websphere61 actually) etc into the corresponding folders of the seamgen generated project
| * Copy the jars from exploded-archives-websphere61\jboss-seam-jpa.war\WEB-INF\lib into the project's lib folder
| * modify the build.xml to include these in the war (the hard part)
|
|
| >It sounds like you do not have EJB3 requirements for your app like the poster in the other forum topic. Is that true?
|
| That is correct. But the JPA example uses Seam POJOs. So I wouldn't have used it as a starting point for EJB3.
|
| I will zip up the project and send it (minus the lib folder to keep down the size - but let me know if you want to see it and I'll send it).
|
| Regards,
|
| Gordon
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119264#4119264
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119264
18 years, 6 months
[JBoss OSGi] - Re: OSGi features
by alesj
"tim_ph" wrote : If Spring has it, and JBoss doesn't. It's a big disadvantage.
|
We have it, just not completely done yet.
And we're doing much more than Spring.
We're implementing our own OSGi core framework on top of MC.
They are just using the existing implementations out there.
I'm not saying that's bad, but it's completely different picture.
The OSGi kind of classloading has been in the MC for a while now.
It's just yesterday that we included this new classloading for the first time in our new AS5.
"tim_ph" wrote :
| Updating modules on-the-fly is a dream on any deployment scenario.
|
This was always possible in JBoss, from the introduction of JBoss MicroKernel, based on JMX.
Decoupling of services with the help of MBeans via MBeanServer allowed that.
"tim_ph" wrote :
| Please put that in JBoss or Seam.
Seam is JBoss. ;-)
You probably mean AS5.
It will be there, via our new kernel - the Microcontainer.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119263#4119263
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119263
18 years, 6 months
[JBoss Seam] - Re: Datasource Issue in WebLogic 9.2
by neilac333
Those initial changes were based on this: http://forum.hibernate.org/viewtopic.php?p=2215254&sid=28f8e2bcf55c7278f1.... Granted, the WL version in that post was 8.1, and I am on 9.2. Still, I figured why not give those a shot.
As for the Seam JPA example, I used it as a model for my configuration. Since all this happened, I tried to deploy it. I got this error:
| An error occurred during activation of changes, please see the log for details.
| Message icon - Error [HTTP:101064][WebAppModule(jboss-seam-jpa:jboss-seam-jpa.war)] Error parsing descriptor in Web appplication "D:\bea_dev\domains\domain_dev\jboss-seam-jpa.war" weblogic.application.ModuleException: Unmarshaller failed at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:781) at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:272) at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176) at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93) at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:360) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:56) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:46) at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26) at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191) at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:147) at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:189) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:87) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:718) at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1185) at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:247) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:157) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45) at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181) Caused by: com.bea.xml.XmlException: failed to load java type corresponding to e=web-app@http://java.sun.com/xml/ns/javaee at com.bea.staxb.runtime.internal.UnmarshalResult.getPojoBindingType(UnmarshalResult.java:325) at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:292) at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:302) at com.bea.staxb.runtime.internal.UnmarshalResult.determineRootType(UnmarshalResult.java:283) at com.bea.staxb.runtime.internal.UnmarshalResult.unmarshalDocument(UnmarshalResult.java:153) at com.bea.staxb.runtime.internal.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:65) at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(MarshallerFactory.java:136) at weblogic.descriptor.DescriptorManager.createDescriptor(DescriptorManager.java:280) at weblogic.descriptor.DescriptorManager.createDescriptor(DescriptorManager.java:248) at weblogic.application.descriptor.AbstractDescriptorLoader2.getDescriptorBeanFromReader(AbstractDescriptorLoader2.java:749) at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:378) at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:720) at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:729) at weblogic.servlet.internal.WebAppDescriptor.getWebAppBean(WebAppDescriptor.java:134) at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:775) at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:272) at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176) at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93) at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:360) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:56) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:46) at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26) at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191) at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:147) at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:189) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:87) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:718) at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1185) weblogic.application.ModuleException: Unmarshaller failed
| Message icon - Error failed to load java type corresponding to e=web-app@http://java.sun.com/xml/ns/javaee
|
The thing at the bottom seems to be the only useful thing there. But anyway, that wasn't a lot of help.
So I am still searching...
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119250#4119250
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119250
18 years, 6 months
[Tomcat, HTTPD, Servlets & JSP] - Re: how to call unix shell script from web app?
by ragavgomatam
Code is as below :-
import java.io.*;
|
| /** Demonstrate how to run an external program. **/
| public class MyServlet implements HttpServlet{
|
| /** From the main run an servlet . **/
| public doGet( request,response) {
| try {
| Runtime rt = Runtime.getRuntime (); // step 1
|
| Process process = rt.exec ("/call/some/shell"); // step 2
|
| InputStreamReader reader = // step 3
| new InputStreamReader ( process.getInputStream () );
|
| BufferedReader buf_reader =
| new BufferedReader ( reader ); // step 4.
|
| String line;
| while ((line = buf_reader.readLine ()) != null)
| System.out.println (line);
|
| }
| catch (IOException e) {
| System.out.println (e);
| }
| }
| } // servlet end
Make sure you grab the Process & flush the err stream, input tsream & out put stream...Other wise due to insufficient length of err buffers in OS this would hang
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119242#4119242
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119242
18 years, 6 months